diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/infinite_loop.rs')
-rw-r--r-- | src/tools/clippy/tests/ui/infinite_loop.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/infinite_loop.rs b/src/tools/clippy/tests/ui/infinite_loop.rs index 38e64b9ac..765c67011 100644 --- a/src/tools/clippy/tests/ui/infinite_loop.rs +++ b/src/tools/clippy/tests/ui/infinite_loop.rs @@ -1,3 +1,5 @@ +//@no-rustfix + fn fn_val(i: i32) -> i32 { unimplemented!() } @@ -18,11 +20,15 @@ fn immutable_condition() { // Should warn when all vars mentioned are immutable let y = 0; while y < 10 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop println!("KO - y is immutable"); } let x = 0; while y < 10 && x < 3 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop let mut k = 1; k += 2; println!("KO - x and y immutable"); @@ -30,6 +36,8 @@ fn immutable_condition() { let cond = false; while !cond { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop println!("KO - cond immutable"); } @@ -74,15 +82,21 @@ fn unused_var() { let (mut i, mut j) = (0, 0); while i < 3 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop j = 3; println!("KO - i not mentioned"); } while i < 3 && j > 0 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop println!("KO - i and j not mentioned"); } while i < 3 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop let mut i = 5; fn_mutref(&mut i); println!("KO - shadowed"); @@ -98,11 +112,15 @@ fn used_immutable() { let mut i = 0; while i < 3 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop fn_constref(&i); println!("KO - const reference"); } while i < 3 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop fn_val(i); println!("KO - passed by value"); } @@ -169,6 +187,8 @@ impl Counter { fn print_n(&self, n: usize) { while self.count < n { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop println!("KO - {} is not mutated", self.count); } } @@ -177,6 +197,8 @@ impl Counter { fn while_loop_with_break_and_return() { let y = 0; while y < 10 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop if y == 0 { break; } @@ -184,6 +206,8 @@ fn while_loop_with_break_and_return() { } while y < 10 { + //~^ ERROR: variables in the condition are not mutated in the loop body + //~| NOTE: this may lead to an infinite or to a never running loop if y == 0 { return; } |