Skip to content

False Positive: clippy::double_parens on #[cfg_attr(feature = "feature", derive(Something))] #15940

@tgrushka

Description

@tgrushka

Summary

Clippy complains on cfg_attr annotations such as:

#[cfg_attr(feature = "testing", derive(Dummy))]

Obviously, the parentheses are required.

Lint Name

clippy::double_parens

Reproducer

I tried this code:

#[derive(Debug, Clone, sqlx::FromRow, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "testing", derive(Dummy))]
pub struct Person {
    pub email: Option<String>,
    #[cfg_attr(
        feature = "testing",
        dummy(faker = "either(PhoneNumber(), CellNumber())", wrapper = "WrappedVal")
    )]
    pub home_phone: Option<String>,
...
}

I saw this happen:

warning: unnecessary parentheses
  --> src/models/person.rs:48:40
   |
48 | #[cfg_attr(feature = "testing", derive(Dummy))]
   |                                        ^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
   = note: `#[warn(clippy::double_parens)]` on by default
   = note: this warning originates in the derive macro `Dummy` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen:

No lint.

Version

rustc 1.92.0-nightly (695857bc3 2025-10-21)
binary: rustc
commit-hash: 695857bc3f72ec4f59c79f323460fe488c38a53f
commit-date: 2025-10-21
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.3

Additional Labels

No response

Metadata

Metadata

Assignees

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