We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
mut_range_bound
1 parent 7515d9c commit dc6f7dcCopy full SHA for dc6f7dc
clippy_lints/src/loops/mod.rs
@@ -397,6 +397,21 @@ declare_clippy_lint! {
397
/// ### Why is this bad?
398
/// One might think that modifying the mutable variable changes the loop bounds
399
///
400
+ /// ### Known problems
401
+ /// False positive when mutation is followed by a `break`, but the `break` is not immediately
402
+ /// after the mutation:
403
+ ///
404
+ /// ```rust
405
+ /// let mut x = 5;
406
+ /// for _ in 0..x {
407
+ /// x += 1; // x is a range bound that is mutated
408
+ /// ..; // some other expression
409
+ /// break; // leaves the loop, so mutation is not an issue
410
+ /// }
411
+ /// ```
412
413
+ /// False positive on nested loops ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072))
414
415
/// ### Example
416
/// ```rust
417
/// let mut foo = 42;
0 commit comments