Skip to content

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

@richlowe

Description

@richlowe

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions