You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is actually a bug in cargo expand, not in the macro hygiene. The compiler expands to something closer to:
fn main() {
let mut t = 0;
t = 1;
println!("1. t = {}", t);
println!("2. t = {}", t);
{
let t = 2;
println!("3. t = {}", t);
} // the `t` binding inside this scope goes away after the block goes away and the outer `t` is not accessible due to shadowing
println!("4. t = {}", t); // this `t` is the one from earlier
}
Hello. I have just started studying rust (and macros), so may not understand fully how it works.
This code produces following ouptut:
While I expect following output (also looking at
cargo expand
results), becausenew_bind!
macro introduces new let binding in the same scope:I have found similar issues, but am not sure if they are the same.
#32922
#31856
The text was updated successfully, but these errors were encountered: