Skip to content

1.99 beta crater regression with two doc comments in one line #162129

Closed as not planned

Description

@cyrgani

log: https://crater-reports.s3.amazonaws.com/beta-1.99-5/1.99.0-beta.1/gh/SuperInstance.renormalization-agent/log.txt
reduction:

//! ```
//! let x = 0; //! assert!(true);
//! ```

Bisection points to #159966. This used to compile in 1.98 (and the second part was ignored entirely), but became an error in 1.99.

Activity

  1. added
    T-rustdoc
    regression-from-stable-to-beta
    A-doctests
    S-has-mcve
    S-has-bisection
    on Sep 1, 2026
  2. added
    needs-triage
    I-prioritize
    on Sep 1, 2026
  3. theemathas commented on Sep 1, 2026

    @theemathas
    Contributor

    I don't see any PR in that rollup that seems relevant...

  4. apiraino commented on Sep 2, 2026

    @apiraino
    Contributor

    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

    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 -- test 
  5. cyrgani commented on Sep 2, 2026

    @cyrgani
    ContributorAuthor

    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.

  6. jnkel commented on Sep 3, 2026

    @jnkel
    Contributor

    The behavior changed in #159849 (cc @petrochenkov), same as #162131.

    Tested code:

    //! ```
    //! 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`
    
  7. JonathanBrouwer commented on Sep 6, 2026

    @JonathanBrouwer
    Member

    Added a regression test on nightly: #162386

  8. added a commit that references this issue on Sep 7, 2026
  9. added a commit that references this issue on Sep 7, 2026
  10. apiraino commented on Sep 18, 2026

    @apiraino
    Contributor

    @petrochenkov do you think #159849 should get a relnotes label, given it was caught here and in these as well in #162131 (note: pending T-lang discussion), #162349, and #162352

    thanks

  11. JonathanBrouwer commented on Sep 18, 2026

    @JonathanBrouwer
    Member

    If this ends up getting lang accepted, it should definitely be in relnotes, so I've added the label:
    #162955

  12. added this to the 1.99.0 milestone on Sep 25, 2026
  13. schneems commented on Oct 7, 2026

    @schneems
    Contributor

    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.

  14. JonathanBrouwer commented on Oct 9, 2026

    @JonathanBrouwer
    Member

    I came here from google/search with a confusing error output from this code:

    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

  15. removed
    needs-triage
    on Oct 9, 2026
  16. removed
    I-prioritize
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsS-has-bisectionS-has-mcveT-rustdocregression-from-stable-to-beta

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions