mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
lint: immutable condition: add internally mutable test
This commit is contained in:
parent
1ea84c80c1
commit
814827113e
1 changed files with 14 additions and 0 deletions
|
@ -94,8 +94,22 @@ fn used_immutable() {
|
|||
}
|
||||
}
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
fn maybe_i_mutate(i: &Cell<bool>) { unimplemented!() }
|
||||
|
||||
fn internally_mutable() {
|
||||
let b = Cell::new(true);
|
||||
|
||||
while b.get() { // b cannot be silently coerced to `bool`
|
||||
maybe_i_mutate(&b);
|
||||
println!("OK - Method call within condition");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
immutable_condition();
|
||||
unused_var();
|
||||
used_immutable();
|
||||
internally_mutable();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue