rust-lang / rust-lang/rust-clippy
Missing FusedIterator implementations
@saberoueslati is already working on this.
Since Aug 23, 2026.
- 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
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.
Assessment
This issue has not been assessed yet.