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

Confusing source location for "missing fragment specifier" #95463

Open
mikebenfield opened this issue Mar 30, 2022 · 1 comment
Open

Confusing source location for "missing fragment specifier" #95463

mikebenfield opened this issue Mar 30, 2022 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mikebenfield
Copy link
Contributor

mikebenfield commented Mar 30, 2022

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.

@mikebenfield mikebenfield 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 Mar 30, 2022
@estebank estebank added A-parser Area: The parsing of Rust source code to an AST. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Apr 23, 2022
@srleyva
Copy link

srleyva commented Apr 28, 2022

@rustbot claim

@fmease fmease assigned fmease and unassigned srleyva Feb 29, 2024
@fmease fmease removed their assignment Mar 10, 2024
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 A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants