rust-lang / rust-lang/rust-clippy

lint calling `next` twice on a non-fuse iterator without checking the result

Open
#1,448 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint E-hard L-correctness T-middle
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.