Skip to content

Missing comma in enum interacts badly with doc comment advice #142311

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

Closed
richlowe opened this issue Jun 10, 2025 · 1 comment · Fixed by #142341
Closed

Missing comma in enum interacts badly with doc comment advice #142311

richlowe opened this issue Jun 10, 2025 · 1 comment · Fixed by #142341
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@richlowe
Copy link
Contributor

richlowe commented Jun 10, 2025

Code

enum Foo {
    /// Like the noise a sheep makes
    Bar
    /// Like where people drink
    Baa
}

Current output

Compiling playground v0.0.1 (/playground)
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
 --> src/lib.rs:4:5
  |
3 |     Bar
  |        - expected one of `(`, `,`, `=`, `{`, or `}`
4 |     /// Like where people drink
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token
  |
help: add a space before the last `/` to write a regular comment
  |
4 |     // / Like where people drink
  |       +
help: missing `,`
  |
3 |     Bar,
  |        +

error: could not compile `playground` (lib) due to 1 previous error

Desired output

Compiling playground v0.0.1 (/playground)
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
 --> src/lib.rs:4:5
  |
3 |     Bar
  |        - expected one of `(`, `,`, `=`, `{`, or `}`
4 |     /// Like where people drink
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token
help: missing `,`
  |
3 |     Bar,
  |        +

error: could not compile `playground` (lib) due to 1 previous error

Rationale and extra context

The output about the doc comment is a red herring, and shouldn't be there

Other cases

Rust Version

rustc 1.88.0-beta.5 (645b44edd 2025-06-01)
binary: rustc
commit-hash: 645b44edd3717f02838d07ba9bdd2554b0cdc0c5
commit-date: 2025-06-01
host: x86_64-unknown-illumos
release: 1.88.0-beta.5
LLVM version: 20.1.5

(I also saw this in the playground at https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=bafef64b4eb91a9b0df98d2e4c6c660b)

Anything else?

No response

@richlowe richlowe added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 10, 2025
@xizheyin
Copy link
Contributor

@rustbot claim

@bors bors closed this as completed in d68432a Jun 16, 2025
rust-timer added a commit that referenced this issue Jun 16, 2025
Rollup merge of #142341 - xizheyin:142311, r=fee1-dead

Don't suggest converting `///` to `//` when expecting `,`

Fixes #142311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants