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

The function contains macro_rules for macro_export cannot be found in crate:: #16490

Closed
A4-Tacks opened this issue Feb 4, 2024 · 1 comment
Closed
Labels
C-bug Category: bug

Comments

@A4-Tacks
Copy link

A4-Tacks commented Feb 4, 2024

src/main.rs

fn main() {
    #[macro_export]
    macro_rules! foo {
        () => {
            1
        };
    }
    let _m = crate::foo!();
    let _n = crate::bar();
    // crate::
    //      bar()~
    //      main()~
}
fn bar() -> i32 {
    #[macro_export]
    macro_rules! bar {
        () => {
            3
        };
    }
    crate::bar!()
}

rust-analyzer version: rust-analyzer 1.74.0 (79e9716c 2023-11-13) and rust-analyzer 1.77.0-nightly (bf8716f1 2023-12-24)

rustc version: rustc 1.74.0 (79e9716c9 2023-11-13) and rustc 1.77.0-nightly (bf8716f1c 2023-12-24)

relevant settings: NONE

@A4-Tacks A4-Tacks added the C-bug Category: bug label Feb 4, 2024
@Veykril
Copy link
Member

Veykril commented Feb 4, 2024

This pattern is intentionally not supported as this requires rust-analyzer to look into all function bodies for name resolution. (the pattern being a macro_export that leaks outside of the function body. Additionally this pattern might error in a future rust edition rust-lang/rust#120363

@Veykril Veykril closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants