]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/while_immutable_condition.txt
Rollup merge of #89891 - ojeda:modular-alloc, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / src / docs / while_immutable_condition.txt
1 ### What it does
2 Checks whether variables used within while loop condition
3 can be (and are) mutated in the body.
4
5 ### Why is this bad?
6 If the condition is unchanged, entering the body of the loop
7 will lead to an infinite loop.
8
9 ### Known problems
10 If the `while`-loop is in a closure, the check for mutation of the
11 condition variables in the body can cause false negatives. For example when only `Upvar` `a` is
12 in the condition and only `Upvar` `b` gets mutated in the body, the lint will not trigger.
13
14 ### Example
15 ```
16 let i = 0;
17 while i > 10 {
18     println!("let me loop forever!");
19 }
20 ```