Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add link to implementation description
  • Loading branch information
ehuss committed Aug 19, 2024
commit f5dc745c849cd75fcb9df694f12cb5471b1bf409
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