Skip to content

Shadowing macro from std doesn't work #17623

Closed
@Veetaha

Description

@Veetaha

Take the following code as an example.

code snippet to reproduce:

macro_rules! vec {
    ($elem:expr; $n:expr) => (std::vec![::core::convert::Into::into($elem); $n]);
    ($($x:expr),* $(,)?) => (std::vec![$(::core::convert::Into::into($x)),* ]);
}

fn main() {
    let actual: Vec<String> = vec!["foo", "bar", "baz"];
    assert_eq!(actual, ["foo", "bar", "baz"]);
}

RA can't understand that this local vec macro shadows the macro from std. The code compiles fine with rustc though.

image

Meta

rust-analyzer version: rust-analyzer version: 0.3.2037-standalone [/home/veetaha/.vscode-server/extensions/rust-lang.rust-analyzer-0.3.2037-linux-x64/server/rust-analyzer]

rustc version: rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionA-nameresname, path and module resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions