Skip to content

Confusing error with doc comments in parameter list #54801

Closed
@lzybkr

Description

@lzybkr

The following code:

pub fn f(
    /// Comment
    id: u8)
{}

Results in the following error:

error: expected pattern, found `/// Comment`
 --> src/lib.rs:2:5
  |
2 |     /// Comment
  |     ^^^^^^^^^^^ expected pattern

At best, the error is confusing. Ideally it should not be an error, but if doc comments are not allowed in a parameter list, the error should be clearer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions