Confusing error when name for macro definition (macro_rules!
) is missing
#126694
Labels
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.
Code
Current output
Desired output
Rationale and extra context
The error is confusing since it looks like some kind of import is needed to use
macro_rules
.While reading the note carefully could clear this up, it is not optimal since the wording of the note is IMO still a bit confusing (I couldn't directly map "name for this
macro_rules!
" to "you forgot to give your macro a name"), especially since the error seems to state something completely different. Furthermore, the suggested fix is not optimal since you need to remember the syntax even if you understand the error. This could be easily fixed, though (see desired output).I'm aware that the error itself might be harder to change if
macro_rules!
could actually refer to a different macro in theory (?). In this case, I think adjusting the note similar to the suggestion should be sufficient.Note: I ran into this since it is the snippet provided by rust analyzer for
macro_rules!
. Since the snippet directly caused the error and I didn't have the correct syntax remembered, I needed a bit of time to find the fix.Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: