]> git.lizzy.rs Git - rust.git/commitdiff
Add missing suggestions and help message to tests
authormcarton <cartonmartin+git@gmail.com>
Tue, 7 Jun 2016 16:33:11 +0000 (18:33 +0200)
committermcarton <cartonmartin+git@gmail.com>
Tue, 7 Jun 2016 16:33:24 +0000 (18:33 +0200)
tests/compile-fail/methods.rs
tests/compile-fail/needless_return.rs
tests/compile-fail/strings.rs
tests/compile-fail/while_loop.rs

index 78ffbb1a58a46efbd57b733e801fae1353616814..89267462f5dfcac76cd9093af5cdaf50b4237627 100644 (file)
@@ -356,13 +356,19 @@ fn starts_with() {
 
 fn use_extend_from_slice() {
     let mut v : Vec<&'static str> = vec![];
-    v.extend(&["Hello", "World"]); //~ERROR use of `extend`
+    v.extend(&["Hello", "World"]);
+    //~^ ERROR use of `extend`
+    //~| HELP try this
+    //~| SUGGESTION v.extend_from_slice(&["Hello", "World"]);
     v.extend(&vec!["Some", "more"]);
-    //~^ERROR use of `extend`
+    //~^ ERROR use of `extend`
     //~| HELP try this
     //~| SUGGESTION v.extend_from_slice(&vec!["Some", "more"]);
 
-    v.extend(vec!["And", "even", "more"].iter()); //~ERROR use of `extend`
+    v.extend(vec!["And", "even", "more"].iter());
+    //~^ ERROR use of `extend`
+    //~| HELP try this
+    //FIXME: the suggestion if broken because of the macro
     let o : Option<&'static str> = None;
     v.extend(o);
     v.extend(Some("Bye"));
index fe29d991661e5df68dbd9356d56895d3dc400ef2..80fed2818ef54505846ece77a7c50aee51d72772 100644 (file)
@@ -23,26 +23,41 @@ fn test_no_semicolon() -> bool {
 
 fn test_if_block() -> bool {
     if true {
-        return true;       //~ERROR unneeded return statement
+        return true;
+        //~^ ERROR unneeded return statement
+        //~| HELP remove `return` as shown
+        //~| SUGGESTION true
     } else {
-        return false;      //~ERROR unneeded return statement
+        return false;
+        //~^ ERROR unneeded return statement
+        //~| HELP remove `return` as shown
+        //~| SUGGESTION false
     }
 }
 
 fn test_match(x: bool) -> bool {
     match x {
         true => {
-            return false;  //~ERROR unneeded return statement
+            return false;
+            //~^ ERROR unneeded return statement
+            //~| HELP remove `return` as shown
+            //~| SUGGESTION false
         }
         false => {
-            return true;   //~ERROR unneeded return statement
+            return true;
+            //~^ ERROR unneeded return statement
+            //~| HELP remove `return` as shown
+            //~| SUGGESTION true
         }
     }
 }
 
 fn test_closure() {
     let _ = || {
-        return true;       //~ERROR unneeded return statement
+        return true;
+        //~^ ERROR unneeded return statement
+        //~| HELP remove `return` as shown
+        //~| SUGGESTION true
     };
 }
 
index 542b6db4abb4e9d0028c6d469a2a7dfda1cc71f1..d08f8b891bc9907a7faf30561bec88a6e4570994 100644 (file)
@@ -63,8 +63,11 @@ fn main() {
     add_assign_only();
     both();
 
-    // the add is only caught for String
+    // the add is only caught for `String`
     let mut x = 1;
-    x = x + 1; //~ WARN assign_op_pattern
+    ; x = x + 1;
+    //~^ WARN assign_op_pattern
+    //~| HELP replace
+    //~| SUGGESTION ; x += 1;
     assert_eq!(2, x);
 }
index 7c5582ba9bfa80c5edf0d28b5b215313554ad634..4c1090876b40c007005b4ef0901a7b2cb57c1249 100644 (file)
@@ -80,17 +80,26 @@ fn main() {
     }
 
     let mut iter = 1..20;
-    while let Option::Some(x) = iter.next() { //~ERROR this loop could be written as a `for` loop
+    while let Option::Some(x) = iter.next() {
+    //~^ ERROR this loop could be written as a `for` loop
+    //~| HELP try
+    //~| SUGGESTION for x in iter {
         println!("{}", x);
     }
 
     let mut iter = 1..20;
-    while let Some(x) = iter.next() { //~ERROR this loop could be written as a `for` loop
+    while let Some(x) = iter.next() {
+    //~^ ERROR this loop could be written as a `for` loop
+    //~| HELP try
+    //~| SUGGESTION for x in iter {
         println!("{}", x);
     }
 
     let mut iter = 1..20;
-    while let Some(_) = iter.next() {} //~ERROR this loop could be written as a `for` loop
+    while let Some(_) = iter.next() {}
+    //~^ ERROR this loop could be written as a `for` loop
+    //~| HELP try
+    //~| SUGGESTION for _ in iter {
 
     let mut iter = 1..20;
     while let None = iter.next() {} // this is fine (if nonsensical)
@@ -130,7 +139,10 @@ fn main() {
 // cause this function to trigger it
 fn no_panic<T>(slice: &[T]) {
     let mut iter = slice.iter();
-    loop { //~ERROR
+    loop {
+    //~^ ERROR
+    //~| HELP try
+    //~| SUGGESTION while let Some(ele) = iter.next() { .. }
         let _ = match iter.next() {
             Some(ele) => ele,
             None => break