Stream: t-compiler/rust-analyzer

Topic: Legacy macros can have arbitrary paths


Jonas Schievink [he/him] (May 20 2020 at 22:15, on Zulip):

Neat trick that I think rust-analyzer does not currently handle:

#[macro_export]
macro_rules! mac {
    () => {};
}

pub mod m {
    pub use mac;
}

Of course, macros can also be renamed with this.

matklad (May 20 2020 at 22:29, on Zulip):

We handle

macro_rules! _m {}
pub use _m as m;

Not sure about re-export via other module... it seems like we should do this as well?

Jonas Schievink [he/him] (May 20 2020 at 22:45, on Zulip):

Ah, I see. ModuleDefId doesn't contain a case for macros though, that seems odd?

matklad (May 20 2020 at 22:48, on Zulip):

The idea is that ModuleDefId is for post-expansion things

Jonas Schievink [he/him] (May 20 2020 at 23:18, on Zulip):

It seems that visibility of macro reexports is not handled correctly (ie. even use adds an entry to the DefMap). This information seems completely missing from ItemScope as well.

Jonas Schievink [he/him] (May 20 2020 at 23:42, on Zulip):

Ah nevermind, my fault. This is working correctly.

Last update: Jul 27 2021 at 21:45UTC