rust icon indicating copy to clipboard operation
rust copied to clipboard

Confusing source location for "missing fragment specifier"

Open mikebenfield opened this issue 2 years ago • 1 comments

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 avatar Mar 30 '22 06:03 mikebenfield

@rustbot claim

srleyva avatar Apr 28 '22 05:04 srleyva

Some more context at https://github.com/rust-lang/rust/issues/129077

tgross35 avatar Aug 14 '24 22:08 tgross35