Closed
Description
I tried this code:
//! ```
//! # std::fs::write("foo.txt", "Hello, world!").unwrap();
//! fn main() {
//! println!("{}", std::fs::read_to_string("foo.txt").unwrap())
//! }
//! ```
With Rust 1.86.0, running cargo test
compiles and runs the doctest successfully.
On the beta channel, the doctest fails to compile:
running 1 test
test src/lib.rs - (line 1) ... FAILED
failures:
---- src/lib.rs - (line 1) stdout ----
error: expected one of `!` or `::`, found `(`
--> src/lib.rs:2:15
|
2 | std::fs::write("foo.txt", "Hello, world!").unwrap();
| ^ expected one of `!` or `::`
error: aborting due to 1 previous error
Couldn't compile the test.
failures:
src/lib.rs - (line 1)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s
Meta
rustc +beta --version --verbose
:
rustc 1.87.0-beta.3 (a22ecb51f 2025-04-07)
binary: rustc
commit-hash: a22ecb51f85284abc5b18a32b27696b0e3e9cf85
commit-date: 2025-04-07
host: x86_64-pc-windows-msvc
release: 1.87.0-beta.3
LLVM version: 20.1.1
Metadata
Metadata
Assignees
Labels
Area: Documentation tests, run by rustdocCategory: This is a bug.Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcMedium priorityRelevant to the rustdoc team, which will review and decide on the PR/issue.Performance or correctness regression from stable to beta.
Type
Projects
Status
Done