Skip to content

Handle macro invocations expanding to new macro definitions #2516

@CohenArthur

Description

@CohenArthur

rust-lang/rfcs#1560 (comment)

mod a {
    macro_rules! m { () => {
        macro_rules! m { () => {
            fn f() {}
        } }
    } }
}
mod b {
    use a::*;
    c::m! {} // If we expand this first, it would resolve to `a::m!` and then
             // `b::m!` would expand to `fn f() {}`, ensuring correctness.
}
mod c {
    use a::*;
    b::m! {} // If we expand this first, it would resolve to `a::m!` and then
             // `c::m!` would expand to `fn f() {}`, ensuring correctness.
}

One way to go about it is to run the Early name resolver and expander in a fixed point, and store errors in a container instead of emitting them immediately. Then, once the fixed point is reached, emit the errors if there are any

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions