You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
1.99 beta crater regression with two doc comments in one line #162129
A-doctestsArea: Documentation tests, run by rustdocS-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.
I'vre tried running a cargo test bisection, unsure if the result is correct because the regression I see is different from the one reported here. Is this issue about something else?
Details
test result: ok. 34 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests renormalization_agent
running 1 test
test src/lib.rs - (line 32) ... error: expected item, found keyword `let`
--> src/lib.rs:35:1
|
35 | let ticks: Vec<f64> = (0..1024).map(|i| (i as f64 * 0.1).sin()).collect();
| ^^^
| |
| `let` cannot be used for global variables
| help: consider using `static` or `const` instead of `let`
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
error: aborting due to 1 previous error
Couldn't compile the test.FAILED
failures:
failures:
src/lib.rs - (line 32)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
searched nightlies: from nightly-2026-07-05 to nightly-2026-09-02
regressed nightly: nightly-2026-07-28
searched commit range: dc3f851...09ee43b
regressed commit: dfbea5b
This is the exact same regression as what I posted above. The relevant code part is
//! ```//! use renormalization_agent::AgentScaleMap;//!//! let ticks: Vec<f64> = (0..1024).map(|i| (i as f64 * 0.1).sin()).collect();//! let mut map = AgentScaleMap::new(ticks);//! map.extract_mean("mean");//! map.coarse_grain(4).unwrap();//! map.extract_mean("mean");//!//! let obs = map.observables.iter().find(|o| o.name == "mean").unwrap();//! assert_eq!(obs.values.len(), 2); // one per scale//! ```
and in both this and the reduction above there is a line with two doc comments, which now causes a parser error, but was accepted in 1.98.
//! ```//! let x = 0; //! assert!(true);//! ```//!//! ```//! #[should_panic]//! ```
Output before that PR:
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.00s
Doc-tests foo
running 2 tests
test src/lib.rs - (line 5) ... ok
test src/lib.rs - (line 1) ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
all doctests ran in 0.85s; merged doctests compilation took 0.28s
Output after:
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.22s
Doc-tests foo
running 2 tests
test src/lib.rs - (line 5) ... FAILED
test src/lib.rs - (line 1) ... FAILED
failures:
---- src/lib.rs - (line 5) stdout ----
error: expected item after attributes
--> src/lib.rs:6:1
|
6 | #[should_panic]
| ^^^^^^^^^^^^^^^ expected an item after this
error: aborting due to 1 previous error
Couldn't compile the test.
---- src/lib.rs - (line 1) stdout ----
error: expected item, found keyword `let`
--> src/lib.rs:2:1
|
2 | let x = 0; //! assert!(true);
| ^^^
| |
| `let` cannot be used for global variables
| help: consider using `static` or `const` instead of `let`
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
error: aborting due to 1 previous error
Couldn't compile the test.
failures:
src/lib.rs - (line 1)
src/lib.rs - (line 5)
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
error: doctest failed, to rerun pass `--doc`
From linked/closed #162349 (where it's more clear what triggers the behavior). This can happen when the doctest is invalid:
This doctest should not parse. So, if this test used to pass, it did so erroneously, perhaps by the doc comment attaching to some item appended to the doctest.
I came here from google/search with a confusing error output from this code:
/// ```rust
/// use std::path::PathBuf;
///
/// let mut path = PathBuf::from("/bin");
/// path.push("/sh");
/// assert_eq!(path, PathBuf::from("/sh"));
/// ```
///
/// Use instead:
///
/// ```rust
/// use std::path::PathBuf;
///
/// // If this was unintentional, remove the leading separator
/// let mut path = PathBuf::from("/bin");
/// path.push("sh");
/// assert_eq!(path, PathBuf::from("/bin/sh"));
///
/// // If this was intentional, create a new path instead
/// let mut path = PathBuf::from("/bin");
/// // ...
/// *path = PathBuf::from("/sh")
/// assert_eq!(path, PathBuf::from("/sh"));
/// ```
Which is invalid (for several reasons). It's missing a semi-colon for one. But the message was confusing:
|
3161 | let mut path = PathBuf::from("/bin");
| ^^^ `let` cannot be used for global variables
|
= help: consider using `static` and a `Mutex` instead of `let mut`
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
Especially since one the line it's pointing at is valid in a different example. Commenting to help with future search/comprehension.
A-doctestsArea: Documentation tests, run by rustdocS-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.
Activity
theemathas commentedon Sep 1, 2026
I don't see any PR in that rollup that seems relevant...
apiraino commentedon Sep 2, 2026
I'vre tried running a
cargo testbisection, unsure if the result is correct because the regression I see is different from the one reported here. Is this issue about something else?Details
searched nightlies: from nightly-2026-07-05 to nightly-2026-09-02
regressed nightly: nightly-2026-07-28
searched commit range: dc3f851...09ee43b
regressed commit: dfbea5b
bisected with cargo-bisect-rustc v0.6.11
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --preserve --start 1.98.0 -- testcyrgani commentedon Sep 2, 2026
This is the exact same regression as what I posted above. The relevant code part is
and in both this and the reduction above there is a line with two doc comments, which now causes a parser error, but was accepted in 1.98.
theemathas commentedon Sep 3, 2026
Another instance of this: https://crater-reports.s3.amazonaws.com/beta-1.99-5/1.99.0-beta.1/gh/martinbudden.Crate-vector_quaternion_matrix/log.txt
Relevant source code: https://github.com/martinbudden/crate-vector-quaternion-matrix/blob/f90a9c4eb649ee4526b280f635765fe3bb75dd6a/src/matrix4x4.rs#L885-L896
jnkel commentedon Sep 3, 2026
The behavior changed in #159849 (cc @petrochenkov), same as #162131.
Tested code:
Output before that PR:
Output after:
let" #162349 as a duplicate of this issueJonathanBrouwer commentedon Sep 6, 2026
Added a regression test on nightly: #162386
Rollup merge of rust-lang#162386 - JonathanBrouwer:doctest-attribute,…
Unrolled build for #162386 in rollup 162434
Rollup merge of #162386 - JonathanBrouwer:doctest-attribute, r=mejrs
apiraino commentedon Sep 18, 2026
@petrochenkov do you think #159849 should get a
relnoteslabel, given it was caught here and in these as well in #162131 (note: pending T-lang discussion), #162349, and #162352thanks
JonathanBrouwer commentedon Sep 18, 2026
If this ends up getting lang accepted, it should definitely be in relnotes, so I've added the label:
#162955
schneems commentedon Oct 7, 2026
From linked/closed #162349 (where it's more clear what triggers the behavior). This can happen when the doctest is invalid:
I came here from google/search with a confusing error output from this code:
Which is invalid (for several reasons). It's missing a semi-colon for one. But the message was confusing:
Especially since one the line it's pointing at is valid in a different example. Commenting to help with future search/comprehension.
JonathanBrouwer commentedon Oct 9, 2026
This problem already happens on stable, so is unrelated to this issue. Please make a new issue for this.
This issue is a duplicate of #162131 (comment) which was T-lang accepted