Skip to content

Confusing source location for "missing fragment specifier"  #95463

Closed
@mikebenfield

Description

@mikebenfield

Here's some code incorrectly defining a macro, because it's missing a fragment specifier. Playground

macro_rules! m {
    ($x [$y: ident]) => {}
}

Here's the error message rustc gives me:

error: missing fragment specifier
 [--> src/lib.rs:2:9
](https://play.rust-lang.org/#)  |
2 |     ($x [$y: ident]) => {}
  |         ^^^^^^^^^^^
  |

It's potentially confusing that the error points to the source after the name with the missing fragment specifier. Especially in a complicated macro, it would be better if it pointed to the item which was actually missing the fragment specifier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.T-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