rust-lang / rust-lang/rust-clippy
new lint: passthrough enumerate
Open
Nobody has claimed this yet.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
check for calls. enumerate() where the index is only passed through deeper down the iter chain without actually being used
Advantage
simpler code
Drawbacks
No response
Example
pub fn foo(x: Vec<Option<String>>) {
let is = x
.clone()
.into_iter()
.enumerate() // move form here
.map(|(i, o)| (i, o.unwrap_or_default())) // "i" not used, only passed through
.filter(|(_i, o)| o.len() > 3)
.collect::<Vec<_>>();
let could_be = x
.into_iter()
.map(|o| o.unwrap_or_default())
.enumerate() // to here
.filter(|(_i, o)| o.len() > 3)
.collect::<Vec<_>>();
}
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
The issue provides only Rust examples and names no implementation files or tests. Start by locating existing Clippy lints that inspect enumerate() and their corresponding UI tests, then trace how lint suggestions are recorded. Done means the new lint detects the shown passthrough pattern and has coverage for the relevant cases.
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
- 38/100