rust-lang / rust-lang/rust-clippy

Missing FusedIterator implementations

Open
#17,608 2 comments 0 reactions 1 assignee View on GitHub

@saberoueslati is already working on this.

Since Aug 23, 2026.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

This lint would detect types implementing Iterator that don't implement FusedIterator, and lint on them.

Advantage

As the docs for FusedIterator note:

This trait should be implemented by all iterators that behave this way because it allows optimizing Iterator::fuse().

In general, my expectation is that the vast majority of iterators users implement are fused -- so similar to the missing debug impl rustc lint, this also makes sense. An allow for iterators that intentionally aren't fused provides an opportunity to think about writing some explicit docs to that effect as well.

cc https://github.com/rust-lang/rust/pull/160838

Drawbacks

Likely to be pretty noisy at initial adoption, I suspect many ecosystem ad-hoc implemented iterators are not FusedIterator. It may be that this should be limited to just public iterator types or private ones with a .fuse() call we can find.

Example
struct Foo {} //~ WARN potentially missing FusedIterator implementation

impl Iterator for Foo { ... }

with the fix being:

impl FusedIterator for Foo {}
Comparison with existing lints

No response

Additional Context

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.