Open
Description
I tried this code:
/// ```should_panic
/// std::process::exit(1);
/// ```
fn f() {}
cargo test
I expected to see this happen: test fails.
Instead, this happened: test passes.
This also applies to explicit aborts, the process being killed by a signal, Miri aborting execution due to UB, etc. I've just found UB in my doctest that was accidentally hidden by this, and I only stumbled upon it because
WARNING: No rustdoc doctest environment variable provided so doctests will be run in the same process
happened when running under cross and apparently that affects how should_panic
works.
This applies to both separate doctest binaries and edition 2024-style merged doctests.
Meta
rustc --version --verbose
:
rustc 1.90.0-nightly (28f1c8079 2025-06-24)
binary: rustc
commit-hash: 28f1c807911c63f08d98e7b468cfcf15a441e34b
commit-date: 2025-06-24
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
@rustbot label +A-doctests +T-rustdoc
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status