File tree Expand file tree Collapse file tree 6 files changed +24
-14
lines changed Expand file tree Collapse file tree 6 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -11,24 +11,32 @@ fn foo() -> bool { true }
11
11
fn main ( ) {
12
12
// weird `else if` formatting:
13
13
if foo ( ) {
14
- } if foo ( ) { //~ERROR this looks like an `else if` but the `else` is missing
14
+ } if foo ( ) {
15
+ //~^ ERROR this looks like an `else if` but the `else` is missing
16
+ //~| NOTE add the missing `else` or
15
17
}
16
18
17
19
let _ = {
18
20
if foo ( ) {
19
- } if foo ( ) { //~ERROR this looks like an `else if` but the `else` is missing
21
+ } if foo ( ) {
22
+ //~^ ERROR this looks like an `else if` but the `else` is missing
23
+ //~| NOTE add the missing `else` or
20
24
}
21
25
else {
22
26
}
23
27
} ;
24
28
25
29
if foo ( ) {
26
- } else //~ERROR this is an `else if` but the formatting might hide it
30
+ } else
31
+ //~^ ERROR this is an `else if` but the formatting might hide it
32
+ //~| NOTE remove the `else` or
27
33
if foo ( ) { // the span of the above error should continue here
28
34
}
29
35
30
36
if foo ( ) {
31
- } //~ERROR this is an `else if` but the formatting might hide it
37
+ }
38
+ //~^ ERROR this is an `else if` but the formatting might hide it
39
+ //~| NOTE remove the `else` or
32
40
else
33
41
if foo ( ) { // the span of the above error should continue here
34
42
}
Original file line number Diff line number Diff line change 6
6
7
7
fn test ( ) -> i32 {
8
8
let _y = 0 ; // no warning
9
- let x = 5 ; //~NOTE
9
+ let x = 5 ; //~NOTE this expression can be directly returned
10
10
x //~ERROR returning the result of a let binding
11
11
}
12
12
13
13
fn test_inner ( ) -> i32 {
14
14
if true {
15
- let x = 5 ;
15
+ let x = 5 ; //~NOTE this expression can be directly returned
16
16
x //~ERROR returning the result of a let binding
17
17
} else {
18
18
0
Original file line number Diff line number Diff line change @@ -38,5 +38,7 @@ fn main() {
38
38
* * * y + * * x;
39
39
}
40
40
41
- let mut z = mut_ptr ! ( & mut 3u32 ) ; //~ NOTE in this expansion of mut_ptr!
41
+ let mut z = mut_ptr ! ( & mut 3u32 ) ;
42
+ //~^ NOTE in this expansion of mut_ptr!
43
+ //~| NOTE in this expansion of mut_ptr!
42
44
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ fn x(y: &i32) -> i32 {
10
10
fn main ( ) {
11
11
let a = 5 ;
12
12
let b = x ( & a) ;
13
- let c = x ( & & a) ; //~ ERROR: needless_borrow
13
+ let c = x ( & & a) ; //~ ERROR: this expression borrows a reference that is immediately dereferenced by the compiler
14
14
let s = & String :: from ( "hi" ) ;
15
15
let s_ident = f ( & s) ; // should not error, because `&String` implements Copy, but `String` does not
16
16
let g_val = g ( & Vec :: new ( ) ) ; // should not error, because `&Vec<T>` derefs to `&[T]`
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ fn main() {
62
62
//~|SUGGESTION get_number();
63
63
Struct { ..get_struct ( ) } ; //~ERROR statement can be reduced
64
64
//~^HELP replace it with
65
- //~|SUGGESTION get_number ();
65
+ //~|SUGGESTION get_struct ();
66
66
Enum :: Tuple ( get_number ( ) ) ; //~ERROR statement can be reduced
67
67
//~^HELP replace it with
68
68
//~|SUGGESTION get_number();
@@ -74,7 +74,7 @@ fn main() {
74
74
//~|SUGGESTION 5;get_number();
75
75
* & get_number ( ) ; //~ERROR statement can be reduced
76
76
//~^HELP replace it with
77
- //~|SUGGESTION & get_number();
77
+ //~|SUGGESTION get_number();
78
78
& get_number ( ) ; //~ERROR statement can be reduced
79
79
//~^HELP replace it with
80
80
//~|SUGGESTION get_number();
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ fn main() {
17
17
//~| SUGGESTION std::mem::swap(&mut a, &mut b);
18
18
//~| NOTE or maybe you should use `std::mem::replace`?
19
19
20
- let t = a;
20
+ ; let t = a;
21
21
a = b;
22
22
b = t;
23
23
//~^^^ ERROR this looks like you are swapping `a` and `b` manually
24
24
//~| HELP try
25
- //~| SUGGESTION std::mem::swap(&mut a, &mut b);
25
+ //~| SUGGESTION ; std::mem::swap(&mut a, &mut b);
26
26
//~| NOTE or maybe you should use `std::mem::replace`?
27
27
28
28
let mut c = Foo ( 42 ) ;
@@ -34,11 +34,11 @@ fn main() {
34
34
//~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
35
35
//~| NOTE or maybe you should use `std::mem::replace`?
36
36
37
- let t = c. 0 ;
37
+ ; let t = c. 0 ;
38
38
c. 0 = a;
39
39
a = t;
40
40
//~^^^ ERROR this looks like you are swapping `c.0` and `a` manually
41
41
//~| HELP try
42
- //~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
42
+ //~| SUGGESTION ; std::mem::swap(&mut c.0, &mut a);
43
43
//~| NOTE or maybe you should use `std::mem::replace`?
44
44
}
You can’t perform that action at this time.
0 commit comments