Skip to content

enum_variant_names too trigger-happy #10599

@couchand

Description

@couchand

Summary

I have an enum representing possible errors from deserialization:

pub enum PromotionError {
    NoPromotionId,
    InvalidPromotionId(String),
    InvalidProductId(String),
}

clippy produces this: warning: all variants have the same postfix: Id and "helpfully" suggests: help: remove the postfixes and use full paths to the variants instead of glob imports

Maybe it's just me but the suggestion here seems completely irrelevant. I'm not even sure what the lint is trying to catch: what's the stylistic concern here?

Lint Name

enum_variant_names

Reproducer

I tried this code:

pub enum PromotionError {
    NoPromotionId,
    InvalidPromotionId(String),
    InvalidProductId(String),
}

I saw this happen:

[<output>](warning: all variants have the same postfix: Id)

I expected to see this happen:

No error.

Version

rustc 1.68.1 (8460ca823 2023-03-20)
binary: rustc
commit-hash: 8460ca823e8367a30dda430efda790588b8c84d3
commit-date: 2023-03-20
host: x86_64-unknown-linux-gnu
release: 1.68.1
LLVM version: 15.0.6

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