RS.CLIPPY.MAYBE_INFINITE_ITER

Possible infinite iteration

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: maybe_infinite_iter. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for iteration that may be infinite.

Why is this bad?

While there may be places where this is acceptable (e.g., in event streams), in most cases this is simply an error.

Known problems

The code may have a condition to stop iteration, but this lint is not clever enough to analyze it.

Example

let infinite_iter = 0..;
[0..].iter().zip(infinite_iter.take_while(|x| *x > 5));