Skip to content

Commit 383fbee

Browse files
committed
Use revisions for NLL in lifetimes
1 parent fe91cfd commit 383fbee

File tree

108 files changed

+398
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+398
-145
lines changed

src/test/ui/lifetimes/issue-79187-2.stderr src/test/ui/lifetimes/issue-79187-2.base.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-79187-2.rs:8:5
2+
--> $DIR/issue-79187-2.rs:12:5
33
|
44
LL | take_foo(|a| a);
55
| ^^^^^^^^ lifetime mismatch
66
|
77
= note: expected type `for<'r> Fn<(&'r i32,)>`
88
found type `Fn<(&i32,)>`
99
note: this closure does not fulfill the lifetime requirements
10-
--> $DIR/issue-79187-2.rs:8:14
10+
--> $DIR/issue-79187-2.rs:12:14
1111
|
1212
LL | take_foo(|a| a);
1313
| ^^^^^
1414
note: the lifetime requirement is introduced here
15-
--> $DIR/issue-79187-2.rs:5:21
15+
--> $DIR/issue-79187-2.rs:9:21
1616
|
1717
LL | fn take_foo(_: impl Foo) {}
1818
| ^^^
1919

2020
error[E0308]: mismatched types
21-
--> $DIR/issue-79187-2.rs:9:5
21+
--> $DIR/issue-79187-2.rs:16:5
2222
|
2323
LL | take_foo(|a: &i32| a);
2424
| ^^^^^^^^ lifetime mismatch
2525
|
2626
= note: expected reference `&i32`
2727
found reference `&i32`
2828
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
29-
--> $DIR/issue-79187-2.rs:9:14
29+
--> $DIR/issue-79187-2.rs:16:14
3030
|
3131
LL | take_foo(|a: &i32| a);
3232
| ^^^^^^^^^^^
3333
note: the lifetime requirement is introduced here
34-
--> $DIR/issue-79187-2.rs:5:21
34+
--> $DIR/issue-79187-2.rs:9:21
3535
|
3636
LL | fn take_foo(_: impl Foo) {}
3737
| ^^^
3838

3939
error[E0308]: mismatched types
40-
--> $DIR/issue-79187-2.rs:10:5
40+
--> $DIR/issue-79187-2.rs:20:5
4141
|
4242
LL | take_foo(|a: &i32| -> &i32 { a });
4343
| ^^^^^^^^ lifetime mismatch
4444
|
4545
= note: expected reference `&i32`
4646
found reference `&i32`
4747
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
48-
--> $DIR/issue-79187-2.rs:10:14
48+
--> $DIR/issue-79187-2.rs:20:14
4949
|
5050
LL | take_foo(|a: &i32| -> &i32 { a });
5151
| ^^^^^^^^^^^^^^^^^^^^^^^
5252
note: the lifetime requirement is introduced here
53-
--> $DIR/issue-79187-2.rs:5:21
53+
--> $DIR/issue-79187-2.rs:9:21
5454
|
5555
LL | fn take_foo(_: impl Foo) {}
5656
| ^^^

src/test/ui/lifetimes/issue-79187-2.nll.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/issue-79187-2.rs:9:24
2+
--> $DIR/issue-79187-2.rs:16:24
33
|
44
LL | take_foo(|a: &i32| a);
55
| - - ^ returning this value requires that `'1` must outlive `'2`
@@ -8,7 +8,7 @@ LL | take_foo(|a: &i32| a);
88
| let's call the lifetime of this reference `'1`
99

1010
error: lifetime may not live long enough
11-
--> $DIR/issue-79187-2.rs:10:34
11+
--> $DIR/issue-79187-2.rs:20:34
1212
|
1313
LL | take_foo(|a: &i32| -> &i32 { a });
1414
| - - ^ returning this value requires that `'1` must outlive `'2`
@@ -17,7 +17,7 @@ LL | take_foo(|a: &i32| -> &i32 { a });
1717
| let's call the lifetime of this reference `'1`
1818

1919
error: implementation of `FnOnce` is not general enough
20-
--> $DIR/issue-79187-2.rs:8:5
20+
--> $DIR/issue-79187-2.rs:12:5
2121
|
2222
LL | take_foo(|a| a);
2323
| ^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
@@ -26,48 +26,48 @@ LL | take_foo(|a| a);
2626
= note: ...but it actually implements `FnOnce<(&'2 i32,)>`, for some specific lifetime `'2`
2727

2828
error[E0308]: mismatched types
29-
--> $DIR/issue-79187-2.rs:8:5
29+
--> $DIR/issue-79187-2.rs:12:5
3030
|
3131
LL | take_foo(|a| a);
3232
| ^^^^^^^^^^^^^^^ one type is more general than the other
3333
|
3434
= note: expected type `for<'r> Fn<(&'r i32,)>`
3535
found type `Fn<(&i32,)>`
3636
note: this closure does not fulfill the lifetime requirements
37-
--> $DIR/issue-79187-2.rs:8:14
37+
--> $DIR/issue-79187-2.rs:12:14
3838
|
3939
LL | take_foo(|a| a);
4040
| ^^^^^
4141
note: the lifetime requirement is introduced here
42-
--> $DIR/issue-79187-2.rs:5:21
42+
--> $DIR/issue-79187-2.rs:9:21
4343
|
4444
LL | fn take_foo(_: impl Foo) {}
4545
| ^^^
4646

4747
error[E0308]: mismatched types
48-
--> $DIR/issue-79187-2.rs:9:5
48+
--> $DIR/issue-79187-2.rs:16:5
4949
|
5050
LL | take_foo(|a: &i32| a);
5151
| ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
5252
|
5353
= note: expected reference `&i32`
5454
found reference `&i32`
5555
note: the lifetime requirement is introduced here
56-
--> $DIR/issue-79187-2.rs:5:21
56+
--> $DIR/issue-79187-2.rs:9:21
5757
|
5858
LL | fn take_foo(_: impl Foo) {}
5959
| ^^^
6060

6161
error[E0308]: mismatched types
62-
--> $DIR/issue-79187-2.rs:10:5
62+
--> $DIR/issue-79187-2.rs:20:5
6363
|
6464
LL | take_foo(|a: &i32| -> &i32 { a });
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
6666
|
6767
= note: expected reference `&i32`
6868
found reference `&i32`
6969
note: the lifetime requirement is introduced here
70-
--> $DIR/issue-79187-2.rs:5:21
70+
--> $DIR/issue-79187-2.rs:9:21
7171
|
7272
LL | fn take_foo(_: impl Foo) {}
7373
| ^^^

src/test/ui/lifetimes/issue-79187-2.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1+
// revisions: base nll
2+
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
15
trait Foo {}
26

37
impl<F> Foo for F where F: Fn(&i32) -> &i32 {}
48

59
fn take_foo(_: impl Foo) {}
610

711
fn main() {
8-
take_foo(|a| a); //~ ERROR mismatched types
9-
take_foo(|a: &i32| a); //~ ERROR mismatched types
10-
take_foo(|a: &i32| -> &i32 { a }); //~ ERROR mismatched types
12+
take_foo(|a| a);
13+
//[base]~^ ERROR mismatched types
14+
//[nll]~^^ ERROR implementation of `FnOnce` is not general enough
15+
//[nll]~| ERROR mismatched types
16+
take_foo(|a: &i32| a);
17+
//[base]~^ ERROR mismatched types
18+
//[nll]~^^ ERROR lifetime may not live long enough
19+
//[nll]~| ERROR mismatched types
20+
take_foo(|a: &i32| -> &i32 { a });
21+
//[base]~^ ERROR mismatched types
22+
//[nll]~^^ ERROR lifetime may not live long enough
23+
//[nll]~| ERROR mismatched types
1124

1225
// OK
1326
take_foo(identity(|a| a));

src/test/ui/lifetimes/issue-79187.stderr src/test/ui/lifetimes/issue-79187.base.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: implementation of `FnOnce` is not general enough
2-
--> $DIR/issue-79187.rs:5:5
2+
--> $DIR/issue-79187.rs:9:5
33
|
44
LL | thing(f);
55
| ^^^^^ implementation of `FnOnce` is not general enough

src/test/ui/lifetimes/issue-79187.nll.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-79187.rs:5:5
2+
--> $DIR/issue-79187.rs:9:5
33
|
44
LL | thing(f);
55
| ^^^^^^^^ one type is more general than the other
66
|
77
= note: expected type `for<'r> FnOnce<(&'r u32,)>`
88
found type `FnOnce<(&u32,)>`
99
note: this closure does not fulfill the lifetime requirements
10-
--> $DIR/issue-79187.rs:4:13
10+
--> $DIR/issue-79187.rs:8:13
1111
|
1212
LL | let f = |_| ();
1313
| ^^^^^^
1414
note: the lifetime requirement is introduced here
15-
--> $DIR/issue-79187.rs:1:18
15+
--> $DIR/issue-79187.rs:5:18
1616
|
1717
LL | fn thing(x: impl FnOnce(&u32)) {}
1818
| ^^^^^^^^^^^^
1919

2020
error: implementation of `FnOnce` is not general enough
21-
--> $DIR/issue-79187.rs:5:5
21+
--> $DIR/issue-79187.rs:9:5
2222
|
2323
LL | thing(f);
2424
| ^^^^^^^^ implementation of `FnOnce` is not general enough

src/test/ui/lifetimes/issue-79187.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
// revisions: base nll
2+
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
15
fn thing(x: impl FnOnce(&u32)) {}
26

37
fn main() {
48
let f = |_| ();
5-
thing(f); //~ERROR implementation of `FnOnce` is not general enough
9+
thing(f);
10+
//[nll]~^ ERROR mismatched types
11+
//~^^ ERROR implementation of `FnOnce` is not general enough
612
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// FIXME(nll): On NLL stabilization, this should be replace
2+
// `issue-90170-elision-mismatch.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
// compile-flags: -Zborrowck=mir
6+
7+
// run-rustfix
8+
9+
pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
10+
11+
pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
12+
13+
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// FIXME(nll): On NLL stabilization, this should be replace
2+
// `issue-90170-elision-mismatch.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
// compile-flags: -Zborrowck=mir
6+
7+
// run-rustfix
8+
9+
pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
10+
11+
pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
12+
13+
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
14+
15+
fn main() {}

src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/issue-90170-elision-mismatch.rs:3:40
2+
--> $DIR/issue-90170-elision-mismatch-nll.rs:9:40
33
|
44
LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
55
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`
@@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
1313
| ++++ ++ ++
1414

1515
error: lifetime may not live long enough
16-
--> $DIR/issue-90170-elision-mismatch.rs:5:44
16+
--> $DIR/issue-90170-elision-mismatch-nll.rs:11:44
1717
|
1818
LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
1919
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`
@@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
2727
| ++++ ~~ ++
2828

2929
error: lifetime may not live long enough
30-
--> $DIR/issue-90170-elision-mismatch.rs:7:63
30+
--> $DIR/issue-90170-elision-mismatch-nll.rs:13:63
3131
|
3232
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
3333
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`

src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// FIXME(nll): On NLL stabilization, this should be replaced by
2+
// `issue-90170-elision-mismatch-nll.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
16
// run-rustfix
27

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

src/test/ui/lifetimes/issue-90170-elision-mismatch.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// FIXME(nll): On NLL stabilization, this should be replaced by
2+
// `issue-90170-elision-mismatch-nll.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
16
// run-rustfix
27

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

src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/issue-90170-elision-mismatch.rs:3:47
2+
--> $DIR/issue-90170-elision-mismatch.rs:8:47
33
|
44
LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
55
| --- --- ^ ...but data from `y` flows into `x` here
@@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
1313
| ++++ ++ ++
1414

1515
error[E0623]: lifetime mismatch
16-
--> $DIR/issue-90170-elision-mismatch.rs:5:51
16+
--> $DIR/issue-90170-elision-mismatch.rs:10:51
1717
|
1818
LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
1919
| ------ --- ^ ...but data from `y` flows into `x` here
@@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
2727
| ++++ ~~ ++
2828

2929
error[E0623]: lifetime mismatch
30-
--> $DIR/issue-90170-elision-mismatch.rs:7:70
30+
--> $DIR/issue-90170-elision-mismatch.rs:12:70
3131
|
3232
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
3333
| --- --- ^ ...but data from `y` flows into `x` here

src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0759]: `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
2+
--> $DIR/issue-90600-expected-return-static-indirect.rs:11:32
33
|
44
LL | fn inner(mut foo: &[u8]) {
55
| ----- this data with an anonymous lifetime `'_`...

src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0597]: `foo` does not live long enough
2-
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
2+
--> $DIR/issue-90600-expected-return-static-indirect.rs:11:32
33
|
44
LL | let refcell = RefCell::new(&mut foo);
55
| ^^^^^^^^ borrowed value does not live long enough
6-
LL |
6+
...
77
LL | let read = &refcell as &RefCell<dyn Read>;
88
| -------- cast requires that `foo` is borrowed for `'static`
99
...
1010
LL | }
1111
| - `foo` dropped here while still borrowed
1212

1313
error: lifetime may not live long enough
14-
--> $DIR/issue-90600-expected-return-static-indirect.rs:9:16
14+
--> $DIR/issue-90600-expected-return-static-indirect.rs:14:16
1515
|
1616
LL | fn inner(mut foo: &[u8]) {
1717
| - let's call the lifetime of this reference `'1`

src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
// revisions: base nll
2+
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
15
use std::cell::RefCell;
26
use std::io::Read;
37

48
fn main() {}
59

610
fn inner(mut foo: &[u8]) {
711
let refcell = RefCell::new(&mut foo);
8-
//~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
12+
//[base]~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
13+
//[nll]~^^ ERROR `foo` does not live long enough
914
let read = &refcell as &RefCell<dyn Read>;
15+
//[nll]~^ ERROR lifetime may not live long enough
1016

1117
read_thing(read);
1218
}

0 commit comments

Comments
 (0)