rust-lang / rust-lang/rust-clippy
Large enum variant: print size of all other variants?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Description
For enums where all variants are quite large, the lint seems pretty misfirey e.g. I've an enum where the largest member is 7200 bytes, but the second largest is 6800, and the third is probably 6500.
The lint currently only prints the first and second, which is less informative than it could be.
An other option would be to suggest boxing the entire enum if many / most variants are very large, even if it triggers very large allocation for a small number of small variants it seems like it'd not be much of an issue. Maybe that could be part of a "large struct" lint if there is one?
Version
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
Additional Labels
@rustbot label +C-question
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 by locating the Clippy implementation and tests for the large enum variant lint, then read how its diagnostic selects the reported variants. The issue is done when the diagnostic provides useful size information for all relevant large variants, with tests covering enums whose largest variants are similarly sized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100