Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle macro invocations expanding to new macro definitions #2516

Closed
CohenArthur opened this issue Aug 3, 2023 · 2 comments
Closed

Handle macro invocations expanding to new macro definitions #2516

CohenArthur opened this issue Aug 3, 2023 · 2 comments
Assignees

Comments

@CohenArthur
Copy link
Member

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

@matthewjasper
Copy link
Contributor

cc #2233

@CohenArthur
Copy link
Member Author

uh, yeah, not sure why I didn't add this issue's testcase to your issue! thank you @matthewjasper I'll close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants