This is because macro_rules! is broken incorrectly when it comes to macros that expand to statements.
The problem basically is that it considers each statement independently for hygiene purposes. In other words, the third operator literally does not see the binding defined in the first line.
In some cases, you can get around this by wrapping the statements in a block:
macro_rules! why { ( [ $saved:ident ] $body:block ) => { { let $saved = 3; $body let _a = $saved; } } }
source share