]> git.lizzy.rs Git - rust.git/commitdiff
Fix wrong tests and improve some other
authormcarton <cartonmartin+git@gmail.com>
Sun, 5 Jun 2016 16:07:12 +0000 (18:07 +0200)
committermcarton <cartonmartin+git@gmail.com>
Tue, 7 Jun 2016 15:32:36 +0000 (17:32 +0200)
tests/compile-fail/formatting.rs
tests/compile-fail/let_return.rs
tests/compile-fail/mut_mut.rs
tests/compile-fail/needless_borrow.rs
tests/compile-fail/no_effect.rs
tests/compile-fail/swap.rs

index 14a23111ec7e54def16121c710316c0a89103842..2436f64d216fba9563d4f91c681bbfa87683bd2e 100644 (file)
@@ -11,24 +11,32 @@ fn foo() -> bool { true }
 fn main() {
     // weird `else if` formatting:
     if foo() {
-    } if foo() { //~ERROR this looks like an `else if` but the `else` is missing
+    } if foo() {
+    //~^ ERROR this looks like an `else if` but the `else` is missing
+    //~| NOTE add the missing `else` or
     }
 
     let _ = {
         if foo() {
-        } if foo() { //~ERROR this looks like an `else if` but the `else` is missing
+        } if foo() {
+        //~^ ERROR this looks like an `else if` but the `else` is missing
+        //~| NOTE add the missing `else` or
         }
         else {
         }
     };
 
     if foo() {
-    } else //~ERROR this is an `else if` but the formatting might hide it
+    } else
+    //~^ ERROR this is an `else if` but the formatting might hide it
+    //~| NOTE remove the `else` or
     if foo() { // the span of the above error should continue here
     }
 
     if foo() {
-    } //~ERROR this is an `else if` but the formatting might hide it
+    }
+    //~^ ERROR this is an `else if` but the formatting might hide it
+    //~| NOTE remove the `else` or
     else
     if foo() { // the span of the above error should continue here
     }
index 33d2d6a823afc19cb5f739e929a163d9723ddd46..477786813dbaf19dfda8d2a8a877d355f931deca 100644 (file)
@@ -6,13 +6,13 @@
 
 fn test() -> i32 {
     let _y = 0; // no warning
-    let x = 5;   //~NOTE
+    let x = 5;   //~NOTE this expression can be directly returned
     x            //~ERROR returning the result of a let binding
 }
 
 fn test_inner() -> i32 {
     if true {
-        let x = 5;
+        let x = 5;   //~NOTE this expression can be directly returned
         x            //~ERROR returning the result of a let binding
     } else {
         0
index 8d9bceb0d0d8ad1ae48c22efb0457ef40316bbe0..92344110d2ccdcbf237b11ba59115fb8d4ca3db1 100644 (file)
@@ -38,5 +38,7 @@ fn main() {
         ***y + **x;
     }
 
-    let mut z = mut_ptr!(&mut 3u32); //~ NOTE in this expansion of mut_ptr!
+    let mut z = mut_ptr!(&mut 3u32);
+    //~^ NOTE in this expansion of mut_ptr!
+    //~| NOTE in this expansion of mut_ptr!
 }
index 602e1e0859b8f83b26d0e07027cece6507853e41..88099297b98ab661ea9f496832883c88eb9d0e65 100644 (file)
@@ -10,7 +10,7 @@ fn x(y: &i32) -> i32 {
 fn main() {
     let a = 5;
     let b = x(&a);
-    let c = x(&&a); //~ ERROR: needless_borrow
+    let c = x(&&a); //~ ERROR: this expression borrows a reference that is immediately dereferenced by the compiler
     let s = &String::from("hi");
     let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not
     let g_val = g(&Vec::new()); // should not error, because `&Vec<T>` derefs to `&[T]`
index c1d9b1754284cf72bbb98713a796e80c484ccae6..76c7fa54c019687e8545dd5552afb0642105299c 100644 (file)
@@ -62,7 +62,7 @@ fn main() {
     //~|SUGGESTION get_number();
     Struct { ..get_struct() }; //~ERROR statement can be reduced
     //~^HELP replace it with
-    //~|SUGGESTION get_number();
+    //~|SUGGESTION get_struct();
     Enum::Tuple(get_number()); //~ERROR statement can be reduced
     //~^HELP replace it with
     //~|SUGGESTION get_number();
@@ -74,7 +74,7 @@ fn main() {
     //~|SUGGESTION 5;get_number();
     *&get_number(); //~ERROR statement can be reduced
     //~^HELP replace it with
-    //~|SUGGESTION &get_number();
+    //~|SUGGESTION get_number();
     &get_number(); //~ERROR statement can be reduced
     //~^HELP replace it with
     //~|SUGGESTION get_number();
index c41354675566ea721b3a1e4374cee2163db2e05b..c8ff2b610d01b8d6f2a7932cac58c2997a29329e 100644 (file)
@@ -57,12 +57,12 @@ fn main() {
     //~| SUGGESTION std::mem::swap(&mut a, &mut b);
     //~| NOTE or maybe you should use `std::mem::replace`?
 
-    let t = a;
+    let t = a;
     a = b;
     b = t;
     //~^^^ ERROR this looks like you are swapping `a` and `b` manually
     //~| HELP try
-    //~| SUGGESTION std::mem::swap(&mut a, &mut b);
+    //~| SUGGESTION std::mem::swap(&mut a, &mut b);
     //~| NOTE or maybe you should use `std::mem::replace`?
 
     let mut c = Foo(42);
@@ -74,11 +74,11 @@ fn main() {
     //~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
     //~| NOTE or maybe you should use `std::mem::replace`?
 
-    let t = c.0;
+    let t = c.0;
     c.0 = a;
     a = t;
     //~^^^ ERROR this looks like you are swapping `c.0` and `a` manually
     //~| HELP try
-    //~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
+    //~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
     //~| NOTE or maybe you should use `std::mem::replace`?
 }