-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Want better error message for attempted hygiene violation #148580
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-hygieneArea: Macro hygieneArea: Macro hygieneA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-hygieneArea: Macro hygieneArea: Macro hygieneA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
Rationale and extra context
The current message is quite gaslight-y, I think.
My suggestion would help novices who don't know that hygiene is even a thing.
It would also help experts who are doing something exciting with macros. I found myself confused by this earlier today. (Ref https://gitlab.torproject.org/Diziet/rust-derive-deftly/-/issues/130)
Hygiene things are particularly hard to debug because the hygiene is invisible in
cargo expandoutput etc.Other cases
I found a whole bunch of exciting tickets relating to macro hygiene. Some of them have scenarios where this new help message would have perhaps helped the user. Eg #46489 #47988
Rust Version
Today's stable on the Rust playground.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1ee109560f0d9e2f216a02e346679f1c