Skip to content

infer break use-as alias after macro expansion #2443

Closed
@edwin0cheng

Description

@edwin0cheng
#![allow(non_camel_case_types)]

mod m {
    macro_rules! _foo {
        ($x:ident) => { type $x = u64; }
    }
    pub(crate) use _foo as foo;
}

m::foo!(foo);
use foo as bar;

fn f() -> bar { 0 }
fn b() -> foo { 0 }

fn main() {  
    let _a  = f();      // _a : {unknown}
    let _b  = b();     // _b: u64
}

It is because use foo as bar is resolved before expansion of m::foo!(foo), and we didn't rewrite the aliased PerNs of bar. Note that legacy macro invocation (i.e. unquatified identifier like foo!) is not affected, because it is expanded before any item resolutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions