about summary refs log tree commit diff
path: root/tests/ui/infinite_loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/infinite_loop.rs')
-rw-r--r--tests/ui/infinite_loop.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs
index 38e64b9ac0a..281e12c7b93 100644
--- a/tests/ui/infinite_loop.rs
+++ b/tests/ui/infinite_loop.rs
@@ -1,3 +1,5 @@
+//@no-rustfix
+
 fn fn_val(i: i32) -> i32 {
     unimplemented!()
 }
@@ -5,6 +7,8 @@ fn fn_constref(i: &i32) -> i32 {
     unimplemented!()
 }
 fn fn_mutref(i: &mut i32) {
+    //~^ ERROR: this argument is a mutable reference, but not used mutably
+    //~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
     unimplemented!()
 }
 fn fooi() -> i32 {
@@ -18,11 +22,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 +38,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 +84,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 +114,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 +189,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 +199,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 +208,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;
         }