Skip to content

#[allow(clippy::enum_variant_names)] not recognized when applied to individual variants #10695

@pommicket

Description

@pommicket

Summary

The #[allow(clippy::enum_variant_names)] attribute is ignored when it's used on just an enum variant (it works fine if applied the whole enum).

Reproducer

I tried this code:

#[allow(dead_code)]
enum MyEnum {
    #[allow(clippy::enum_variant_names)]
    MyEnumIsGood,
    Yes,
    Hi,
}
fn main() {}

I expected to see this happen:

(No output from clippy)

Instead, this happened:

warning: variant name starts with the enum's name
 --> src/main.rs:4:5
  |
4 |     MyEnumIsGood,
  |     ^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
  = note: `#[warn(clippy::enum_variant_names)]` on by default

Version

both stable and nightly

rustc 1.71.0-nightly (fec9adcdb 2023-04-21)
binary: rustc
commit-hash: fec9adcdbc21469ef105162cc8cabf81c72d06be
commit-date: 2023-04-21
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Additional Labels

@rustbot label +I-false-positive

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