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
}
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
***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!
}
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]`
//~|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();
//~|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();
//~| 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);
//~| 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`?
}