Seems like the bug is with $:block macro expansion #76300
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
E-needs-mcve
Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
I tried this code:
the problem is tracked in the paste crate here, but the paste deveoper thinks it is a bug in rustc
dtolnay/paste#50
This fails to compile. It uses the paste crate for symbol expansion inside macros
Erroring out as
This compiles fine, without using paste, The only difference is the use of the paste! macro which does symbol expansion, though no actual symbol expansion code exists in the macro at this point. Just the mere act of invoking paste!{} caused the error.
And fix it as
Changing stringify!($real_fn) to "something" then compiles fine.
Below is the code that compiles without using paste! {}
The developer of the paste!{} crate thinks this is a bug in rustc and commented as below
This looks like a rustc bug. Putting println!("{:#?}", input) at the beginning of the paste implementation to see what tokens the compiler is passing in as macro input, it shows:
where the two path tokens have totally different hygiene context (the #0 vs #22) and so do not resolve to each other.
It seems like the bug is with$:block, so you should be able to work around it by not using $ :block.
I expected to see this happen: explanation
Instead, this happened: explanation
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: