1 fn fn_val(i: i32) -> i32 { unimplemented!() }
2 fn fn_constref(i: &i32) -> i32 { unimplemented!() }
3 fn fn_mutref(i: &mut i32) { unimplemented!() }
4 fn fooi() -> i32 { unimplemented!() }
5 fn foob() -> bool { unimplemented!() }
7 fn immutable_condition() {
8 // Should warn when all vars mentionned are immutable
11 println!("KO - y is immutable");
15 while y < 10 && x < 3 {
18 println!("KO - x and y immutable");
23 println!("KO - cond immutable");
27 while y < 10 && i < 3 {
29 println!("OK - i is mutable");
32 let mut mut_cond = false;
33 while !mut_cond || cond {
35 println!("OK - mut_cond is mutable");
39 println!("OK - Fn call results may vary");
43 println!("OK - Fn call results may vary");
49 // Should warn when a (mutable) var is not used in while body
50 let (mut i, mut j) = (0, 0);
54 println!("KO - i not mentionned");
57 while i < 3 && j > 0 {
58 println!("KO - i and j not mentionned");
64 println!("KO - shadowed");
67 while i < 3 && j > 0 {
69 println!("OK - i in cond and mentionned");
78 println!("KO - const reference");
83 println!("KO - passed by value");
87 println!("OK - passed by mutable reference");
93 println!("OK - passed by mutable reference");
98 const B: bool = false;
102 println!("Constants are not linted");
106 println!("Constants are not linted");
110 println!("Constants are not linted");
116 fn maybe_i_mutate(i: &Cell<bool>) { unimplemented!() }
118 fn internally_mutable() {
119 let b = Cell::new(true);
121 while b.get() { // b cannot be silently coerced to `bool`
123 println!("OK - Method call within condition");
128 immutable_condition();
131 internally_mutable();