Skip to content

Commit 76ec1aa

Browse files
committed
Fix test for lifetime elision hint
1 parent 2f4d780 commit 76ec1aa

File tree

3 files changed

+31
-66
lines changed

3 files changed

+31
-66
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
// run-rustfix
22

3-
fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
3+
pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
44

5-
fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
5+
pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
66

7-
fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
7+
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
88

9-
fn ok<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
10-
core::mem::swap(&mut slice_a, &mut slice_b);
11-
}
12-
13-
fn main() {
14-
let a = [1u8, 2, 3];
15-
let b = [4u8, 5, 6];
16-
foo(&mut a, &mut b);
17-
}
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
// run-rustfix
22

3-
fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
3+
pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
44

5-
fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
5+
pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
66

7-
fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
7+
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
88

9-
fn ok<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
10-
core::mem::swap(&mut slice_a, &mut slice_b);
11-
}
12-
13-
fn main() {
14-
let a = [1u8, 2, 3];
15-
let b = [4u8, 5, 6];
16-
foo(&mut a, &mut b);
17-
}
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,45 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/issue-90170-elision-mismatch.rs:3:43
2+
--> $DIR/issue-90170-elision-mismatch.rs:3:47
33
|
4-
LL | fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
5-
| --- --- ^ ...but data from `y` flows into `x` here
6-
| |
7-
| these two types are declared with different lifetimes...
4+
LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
5+
| --- --- ^ ...but data from `y` flows into `x` here
6+
| |
7+
| these two types are declared with different lifetimes...
88
|
99
= note: each elided lifetime in input position becomes a distinct lifetime
1010
help: consider introducing a named lifetime parameter
1111
|
12-
LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
13-
| ++++ ++ ++
12+
LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
13+
| ++++ ++ ++
1414

1515
error[E0623]: lifetime mismatch
16-
--> $DIR/issue-90170-elision-mismatch.rs:5:47
16+
--> $DIR/issue-90170-elision-mismatch.rs:5:51
1717
|
18-
LL | fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
19-
| ------ --- ^ ...but data from `y` flows into `x` here
20-
| |
21-
| these two types are declared with different lifetimes...
18+
LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
19+
| ------ --- ^ ...but data from `y` flows into `x` here
20+
| |
21+
| these two types are declared with different lifetimes...
2222
|
2323
= note: each elided lifetime in input position becomes a distinct lifetime
2424
help: consider introducing a named lifetime parameter
2525
|
26-
LL | fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
27-
| ++++ ~~ ++
26+
LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
27+
| ++++ ~~ ++
2828

2929
error[E0623]: lifetime mismatch
30-
--> $DIR/issue-90170-elision-mismatch.rs:7:66
30+
--> $DIR/issue-90170-elision-mismatch.rs:7:70
3131
|
32-
LL | fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
33-
| --- --- ^ ...but data from `y` flows into `x` here
34-
| |
35-
| these two types are declared with different lifetimes...
32+
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
33+
| --- --- ^ ...but data from `y` flows into `x` here
34+
| |
35+
| these two types are declared with different lifetimes...
3636
|
3737
= note: each elided lifetime in input position becomes a distinct lifetime
3838
help: consider introducing a named lifetime parameter
3939
|
40-
LL | fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
41-
| ++ ++
42-
43-
error[E0308]: mismatched types
44-
--> $DIR/issue-90170-elision-mismatch.rs:16:9
45-
|
46-
LL | foo(&mut a, &mut b);
47-
| ^^^^^^ expected struct `Vec`, found array `[u8; 3]`
48-
|
49-
= note: expected mutable reference `&mut Vec<&u8>`
50-
found mutable reference `&mut [u8; 3]`
51-
52-
error[E0308]: mismatched types
53-
--> $DIR/issue-90170-elision-mismatch.rs:16:17
54-
|
55-
LL | foo(&mut a, &mut b);
56-
| ^^^^^^ expected `u8`, found array `[u8; 3]`
57-
|
58-
= note: expected reference `&u8`
59-
found mutable reference `&mut [u8; 3]`
40+
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
41+
| ++ ++
6042

61-
error: aborting due to 5 previous errors
43+
error: aborting due to 3 previous errors
6244

63-
Some errors have detailed explanations: E0308, E0623.
64-
For more information about an error, try `rustc --explain E0308`.
45+
For more information about this error, try `rustc --explain E0623`.

0 commit comments

Comments
 (0)