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"));
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
};
}
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);
}
}
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)
// 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