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
There seems to be a restriction that macro_use cannot shadow a macro_use macro when expanded from within a macro_rules macro.
#[macro_use(foo)]externcrate m;macro_rules! m1 {() => {
#[macro_use(foo)]//~ ERROR `foo` is already in scope
extern crate m as _;}}m1!();
emits:
error: `foo` is already in scope
╭▸ src/lib.rs:4:17
│
4 │ #[macro_use(foo)] //~ ERROR `foo` is already in scope
│ ━━━
‡
7 │ m1!();
│ ───── in this macro invocation
│
├ note: macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)
╰ note: this error originates in the macro `m1` (in Nightly builds, run with -Z macro-backtrace for more info)
I couldn't find a rule (or combination of rules) that would cover this situation.
Activity
petrochenkov commentedon Mar 17, 2026
cc rust-lang/rust#148025