Code
macro_rules! print_it { {} => { println!("{:?}", it); } }
fn main() {
let it = ();
print_it!();
}
Current output
error[E0425]: cannot find value `it` in this scope
--> src/main.rs:1:50
|
1 | macro_rules! print_it { {} => { println!("{:?}", it); } }
| ^^ not found in this scope
...
5 | print_it!();
| ----------- in this macro invocation
Desired output
error[E0425]: cannot find value `it` in this scope
--> src/main.rs:1:50
|
1 | macro_rules! print_it { {} => { println!("{:?}", it); } }
| ^^ not found in this scope
...
5 | print_it!();
| ----------- in this macro invocation
help: An identifier with the same name is defined here, but is not accessible due to macro hygiene
4 | let it = ();
| ^^
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 expand output 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
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