while_immutable_cond: check condition for mutation
This commit is contained in:
parent
ce37099bd3
commit
63425de77d
2 changed files with 20 additions and 5 deletions
|
|
@ -192,11 +192,23 @@ fn while_loop_with_break_and_return() {
|
|||
}
|
||||
}
|
||||
|
||||
fn immutable_condition_false_positive(mut n: u64) -> u32 {
|
||||
let mut count = 0;
|
||||
while {
|
||||
n >>= 1;
|
||||
n != 0
|
||||
} {
|
||||
count += 1;
|
||||
}
|
||||
count
|
||||
}
|
||||
|
||||
fn main() {
|
||||
immutable_condition();
|
||||
unused_var();
|
||||
used_immutable();
|
||||
internally_mutable();
|
||||
immutable_condition_false_positive(5);
|
||||
|
||||
let mut c = Counter { count: 0 };
|
||||
c.inc_n(5);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue