Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctests reject extra semicolons as of nightly-2021-11-21 (and beta) #91398

Closed
TheBlueMatt opened this issue Nov 30, 2021 · 3 comments
Closed
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@TheBlueMatt
Copy link

The following fails to compile in doctests as Rust 2015 on Beta and latest nightly, but passes doctests fine on stable:

//! ```
//! # struct FakeLogger {};
//! #
//! # fn main() {
//! eprintln!("HI");
//! # }
//! ```

fn main() {
    println!("Hello, world!");
}

Probably related to #91014, #91026, and #91134.

@jyn514
Copy link
Member

jyn514 commented Nov 30, 2021

@TheBlueMatt I don't think this is a bug, that's invalid code. Rustdoc just didn't happen to catch it before.

error: expected item, found `;`
 --> src/lib.rs:2:21
  |
2 | struct FakeLogger {};
  |                     ^ help: remove this semicolon
  |
  = help: braced struct declarations are not followed by a semicolon

error: aborting due to previous error

@jyn514 jyn514 added A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 30, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 30, 2021

If you move it inside a function, the test correctly passes.

//! ```
//! fn f() {
//! # struct FakeLogger {};
//! }
//! #
//! # fn main() {
//! eprintln!("HI");
//! # }
//! ```

@TheBlueMatt
Copy link
Author

Oh, duh, yes, you're totally right, I just saw a compile failure on new rustc and not old rustc and immediately assumed it was a rustc bug. Indeed, this is our bug, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants