Skip to content

macro rules shadowing error should emit where the macro being shadowed lives #49084

Open
@gnzlbg

Description

@gnzlbg

The macro-expanded `macro_rules!`s may not shadow existing macros should mention where the macro being shadowed was defined.

For example compiling stdsimd I get the following error:

error: `is_x86_feature_detected` is already in scope
   --> crates/stdsimd/src/../../../stdsimd/arch/detect/arch/x86.rs:21:1
    |
21  | / macro_rules! is_x86_feature_detected {
22  | |     ("aes") => {
23  | |         cfg!(target_feature = "aes") || $crate::arch::detect::check_for(
24  | |             $crate::arch::detect::Feature::aes)  };
...   |
165 | |     };
166 | | }
    | |_^
    |
    = note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560)

error: aborting due to previous error

which tells me that I am defining a macro that is already defined somewhere, but it is not telling me where. That would make this diagnostic much better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions