rust-lang / rust-lang/rust-clippy
lint calling `next` twice on a non-fuse iterator without checking the result
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
(iter.next(), iter.next()) should only done for fused iterators. A lint could catch calling next on an iterator without accessing the previous result at all. A more complex analysis probably needs to work on MIR, and is prone to false positives. Let's do the easy one first.
See the FusedIterator trait for details: https://doc.rust-lang.org/std/iter/trait.FusedIterator.html
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 reading the FusedIterator trait details linked in the issue and clarify the intended lint for consecutive next calls whose earlier result is unused. Define done as detecting the simple non-fused case while avoiding the more complex MIR analysis and its false positives.
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