Skip to content

Commit

Permalink
Add link to implementation description
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Aug 19, 2024
1 parent 91a2bf7 commit f5dc745
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rust-2024/rustdoc-doctests.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ pub fn subtract(left: u64, right: u64) -> u64 {
}
```

In this example, the two doctests will now be compiled in a single executable. Rustdoc will essentially place each example in a separate function within a single binary. The tests still run in independent processes as they did before, so any global state (like global statics) should still continue to work correctly.
In this example, the two doctests will now be compiled in a single executable. Rustdoc will essentially place each example in a separate function within a single binary. The tests still run in independent processes as they did before, so any global state (like global statics) should still continue to work correctly.[^implementation]

This change is only available in the 2024 Edition to avoid potential incompatibilities with existing doctests which may not work in a combined executable. However, these incompatibilities are expected to be extremely rare.

[doctests]: ../../rustdoc/write-documentation/documentation-tests.html
[libtest harness]: ../../rustc/tests/index.html

[^implementation]: For more information on the details of how this work, see [Doctests - How were they improved?](https://blog.guillaume-gomez.fr/articles/2024-08-17+Doctests+-+How+were+they+improved%3F).

### Standalone tag

In some situations it is not possible for rustdoc to combine examples in a single executable. Rustdoc will attempt to automatically detect if this is not possible, for example:
Expand Down

0 comments on commit f5dc745

Please sign in to comment.