Skip to content

Commit 7c40cfd

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

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

clippy_lints/src/loops/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,18 @@ 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+
/// ```
405+
/// x += 1; // x is a range bound that is mutated
406+
/// some_other_expr();
407+
/// break; // leaves the loop, so mutation is not an issue
408+
/// ```
409+
///
410+
/// False positive on nested loops ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072))
411+
///
400412
/// ### Example
401413
/// ```rust
402414
/// let mut foo = 42;

0 commit comments

Comments
 (0)