rust-lang / rust-lang/rust-clippy
`enum_variant_names` too trigger-happy
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the enum_variant_names lint and the PromotionError reproducer in the issue. Determine what stylistic concern the lint is intended to detect and why this example triggers it. Done means the diagnostic behavior and suggestion appropriately reflect that intent, with the reported case covered by the relevant lint tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100