Fix wrong tests and improve some other

This commit is contained in:
mcarton 2016-06-05 18:07:12 +02:00
parent 1aab0e6729
commit 65c4e391ee
6 changed files with 24 additions and 14 deletions

View file

@ -11,24 +11,32 @@ fn foo() -> bool { true }
fn main() { fn main() {
// weird `else if` formatting: // weird `else if` formatting:
if foo() { 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 _ = { let _ = {
if foo() { 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 { else {
} }
}; };
if foo() { 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() { // the span of the above error should continue here
} }
if foo() { 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 else
if foo() { // the span of the above error should continue here if foo() { // the span of the above error should continue here
} }

View file

@ -6,13 +6,13 @@
fn test() -> i32 { fn test() -> i32 {
let _y = 0; // no warning 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 x //~ERROR returning the result of a let binding
} }
fn test_inner() -> i32 { fn test_inner() -> i32 {
if true { if true {
let x = 5; let x = 5; //~NOTE this expression can be directly returned
x //~ERROR returning the result of a let binding x //~ERROR returning the result of a let binding
} else { } else {
0 0

View file

@ -38,5 +38,7 @@ fn main() {
***y + **x; ***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!
} }

View file

@ -10,7 +10,7 @@ fn x(y: &i32) -> i32 {
fn main() { fn main() {
let a = 5; let a = 5;
let b = x(&a); 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 = &String::from("hi");
let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not 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]` let g_val = g(&Vec::new()); // should not error, because `&Vec<T>` derefs to `&[T]`

View file

@ -62,7 +62,7 @@ fn main() {
//~|SUGGESTION get_number(); //~|SUGGESTION get_number();
Struct { ..get_struct() }; //~ERROR statement can be reduced Struct { ..get_struct() }; //~ERROR statement can be reduced
//~^HELP replace it with //~^HELP replace it with
//~|SUGGESTION get_number(); //~|SUGGESTION get_struct();
Enum::Tuple(get_number()); //~ERROR statement can be reduced Enum::Tuple(get_number()); //~ERROR statement can be reduced
//~^HELP replace it with //~^HELP replace it with
//~|SUGGESTION get_number(); //~|SUGGESTION get_number();
@ -74,7 +74,7 @@ fn main() {
//~|SUGGESTION 5;get_number(); //~|SUGGESTION 5;get_number();
*&get_number(); //~ERROR statement can be reduced *&get_number(); //~ERROR statement can be reduced
//~^HELP replace it with //~^HELP replace it with
//~|SUGGESTION &get_number(); //~|SUGGESTION get_number();
&get_number(); //~ERROR statement can be reduced &get_number(); //~ERROR statement can be reduced
//~^HELP replace it with //~^HELP replace it with
//~|SUGGESTION get_number(); //~|SUGGESTION get_number();

View file

@ -57,12 +57,12 @@ fn main() {
//~| 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`? //~| NOTE or maybe you should use `std::mem::replace`?
let t = a; ; let t = a;
a = b; a = b;
b = t; b = t;
//~^^^ ERROR this looks like you are swapping `a` and `b` manually //~^^^ ERROR this looks like you are swapping `a` and `b` manually
//~| HELP try //~| 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`? //~| NOTE or maybe you should use `std::mem::replace`?
let mut c = Foo(42); let mut c = Foo(42);
@ -74,11 +74,11 @@ fn main() {
//~| 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`? //~| NOTE or maybe you should use `std::mem::replace`?
let t = c.0; ; let t = c.0;
c.0 = a; c.0 = a;
a = t; a = t;
//~^^^ ERROR this looks like you are swapping `c.0` and `a` manually //~^^^ ERROR this looks like you are swapping `c.0` and `a` manually
//~| HELP try //~| 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`? //~| NOTE or maybe you should use `std::mem::replace`?
} }