Skip to content

Commit dc6f7dc

Browse files
committed
Add known problems to mut_range_bound docs
1 parent 7515d9c commit dc6f7dc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clippy_lints/src/loops/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,21 @@ declare_clippy_lint! {
397397
/// ### Why is this bad?
398398
/// One might think that modifying the mutable variable changes the loop bounds
399399
///
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+
///
400415
/// ### Example
401416
/// ```rust
402417
/// let mut foo = 42;

0 commit comments

Comments
 (0)