-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
disallowed_names
triggers within external macro generated code. I noticed this when trying to remove err
from a crate as it is used within syn::parse_macro_input!
.
Lint Name
disallowed_names
Reproducer
I tried this code:
#![deny(clippy::disallowed_names)]
#[proc_macro]
pub fn foo(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let output = input.clone();
let _ = syn::parse_macro_input!(input as syn::DeriveInput);
output
}
with the config:
disallowed-names = ["err"]
I saw this happen:
error: use of a disallowed/placeholder name `err`
--> src/lib.rs:6:13
|
6 | let _ = syn::parse_macro_input!(input as syn::DeriveInput);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(clippy::disallowed_names)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `syn::parse_macro_input` (in Nightly builds, run with -Z macro-backtrace for more info)
I expected to see this happen:
No error since the identifier is within an external macro.
Version
rustc 1.88.0-nightly (2e6882ac5 2025-05-05)
binary: rustc
commit-hash: 2e6882ac5be27a73293d6f7ae56397fdf32848de
commit-date: 2025-05-05
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4
Additional Labels
No response
vE5li
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have