Skip to content

[allow(clippy::disallowed_macros)] fails for proc-macro attributes #13521

Open
@bnjbvr

Description

@bnjbvr

Summary

If I have a proc macro attribute, that's part of the disallowed-macros list, and I add an #[allow(clippy::disallowed_macros)] on top of usage of the macro, Clippy still detects it as usage of a disallowed macro.

Lint Name

disallowed-macros

Reproducer

As a simpler repro, I've used this repo with a new clippy.toml file in /macros that contained:

disallowed-macros = [
    "my_proc_macros_lib::attrib_macro_logger_1"
]

I tried this code in /macros/src/main.rs:

#[allow(clippy::disallowed_macros)]
#[my_proc_macros_lib::attrib_macro_logger_1(key = "value")]
fn jeej() {}

I saw this happen:

warning: use of a disallowed macro `my_proc_macros_lib::attrib_macro_logger_1`
  --> src/main.rs:23:1
   |
23 | #[my_proc_macros_lib::attrib_macro_logger_1(key = "value")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
   = note: `#[warn(clippy::disallowed_macros)]` on by default

I expected to see this happen:

(no clippy complaint about this particular use)

Version

rustc 1.83.0-nightly (3ae715c 2024-10-07)
binary: rustc
commit-hash: 3ae715c
commit-date: 2024-10-07
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions