diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index 78ffbb1a5..89267462f 100644 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -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")); diff --git a/tests/compile-fail/needless_return.rs b/tests/compile-fail/needless_return.rs index fe29d9916..80fed2818 100644 --- a/tests/compile-fail/needless_return.rs +++ b/tests/compile-fail/needless_return.rs @@ -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 }; } diff --git a/tests/compile-fail/strings.rs b/tests/compile-fail/strings.rs index 542b6db4a..d08f8b891 100644 --- a/tests/compile-fail/strings.rs +++ b/tests/compile-fail/strings.rs @@ -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); } diff --git a/tests/compile-fail/while_loop.rs b/tests/compile-fail/while_loop.rs index 7c5582ba9..4c1090876 100644 --- a/tests/compile-fail/while_loop.rs +++ b/tests/compile-fail/while_loop.rs @@ -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(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