Skip to content

R-A does not resolve macro calls correctly when the name clashes with core::macros::bultin macros. #13683

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

Closed
LouisGariepy opened this issue Nov 27, 2022 · 0 comments · Fixed by #14781
Labels
A-macro macro expansion A-nameres name, path and module resolution C-bug Category: bug

Comments

@LouisGariepy
Copy link

LouisGariepy commented Nov 27, 2022

rust-analyzer version: v0.4.1299

rustc version: 1.65.0

MRE

To reproduce the problem, create a new crate (I'll call it my_crate for the sake of this example) with a main.rs and a lib.rs.

The lib.rs:

// lib.rs

/// Some crazy documentation
#[macro_export]
macro_rules! column {
    () => {
        "hello"
    };
}

The main.rs

// main.rs
use my_crate::column; // <-- This macro's name clashes with `core::macros::builtin::column`

fn main() {
    // R-A resolves this as the `core::macros::builtin::column` macro (which returns a u32), 
    // so it thinks something is wrong with this code.
    // rustc is able to compile this just fine (i.e. it resolves our own `column` macro correctly)
    let _ = column!().chars();
}

What I expected to happen

I expected R-A to analyze understand that our macro shadows the built-in one. This is the correct Rust behavior.

Aliasing our macro import with as solves the problem, but should not be required.

What actually happens

R-A complains about {unknown} methods, and when the macro call is hovered, it offers the documentation for the bult-in macro instead of our own macro.

And yet, the code compiles just fine, because it is completely valid.

Screenshot from 2022-11-26 20-34-23

Screenshot from 2022-11-26 20-34-53

Screenshot from 2022-11-26 20-36-03

@LouisGariepy LouisGariepy changed the title R-A is not able to resolve macros that clash with core::macros::bultin ones at call site. R-A does not resolve macro calls correctly when the name clashes with core::macros::bultin macros. Nov 27, 2022
@Veykril Veykril added A-nameres name, path and module resolution C-bug Category: bug labels Nov 27, 2022
@Veykril Veykril added the A-macro macro expansion label Jan 19, 2023
@bors bors closed this as completed in 9b33874 May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion A-nameres name, path and module resolution C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants