Skip to content

Commit b16bd7c

Browse files
committed
Use revisions for NLL in traits
1 parent 34a3154 commit b16bd7c

6 files changed

+110
-26
lines changed

src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr renamed to src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
error[E0308]: mismatched types
2-
--> $DIR/type-checking-test-3.rs:13:13
2+
--> $DIR/type-checking-test-3.rs:16:13
33
|
44
LL | let _ = x as &dyn Bar<'a>; // Error
55
| ^ lifetime mismatch
66
|
77
= note: expected trait object `dyn Bar<'a>`
88
found trait object `dyn Bar<'static>`
99
note: the lifetime `'a` as defined here...
10-
--> $DIR/type-checking-test-3.rs:12:16
10+
--> $DIR/type-checking-test-3.rs:15:16
1111
|
1212
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
1313
| ^^
1414
= note: ...does not necessarily outlive the static lifetime
1515

1616
error[E0308]: mismatched types
17-
--> $DIR/type-checking-test-3.rs:18:13
17+
--> $DIR/type-checking-test-3.rs:22:13
1818
|
1919
LL | let _ = x as &dyn Bar<'static>; // Error
2020
| ^ lifetime mismatch
2121
|
2222
= note: expected trait object `dyn Bar<'static>`
2323
found trait object `dyn Bar<'a>`
2424
note: the lifetime `'a` as defined here...
25-
--> $DIR/type-checking-test-3.rs:17:16
25+
--> $DIR/type-checking-test-3.rs:21:16
2626
|
2727
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
2828
| ^^
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/type-checking-test-3.rs:16:13
3+
|
4+
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
5+
| -- lifetime `'a` defined here
6+
LL | let _ = x as &dyn Bar<'a>; // Error
7+
| ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
8+
9+
error: lifetime may not live long enough
10+
--> $DIR/type-checking-test-3.rs:22:13
11+
|
12+
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
13+
| -- lifetime `'a` defined here
14+
LL | let _ = x as &dyn Bar<'static>; // Error
15+
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
16+
17+
error: aborting due to 2 previous errors
18+

src/test/ui/traits/trait-upcasting/type-checking-test-3.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// revisions: base nll
12
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
25
#![feature(trait_upcasting)]
36
#![allow(incomplete_features)]
47

@@ -11,12 +14,14 @@ fn test_correct(x: &dyn Foo<'static>) {
1114

1215
fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
1316
let _ = x as &dyn Bar<'a>; // Error
14-
//~^ ERROR mismatched types
17+
//[base]~^ ERROR mismatched types
18+
//[nll]~^^ ERROR lifetime may not live long enough
1519
}
1620

1721
fn test_wrong2<'a>(x: &dyn Foo<'a>) {
1822
let _ = x as &dyn Bar<'static>; // Error
19-
//~^ ERROR mismatched types
23+
//[base]~^ ERROR mismatched types
24+
//[nll]~^^ ERROR lifetime may not live long enough
2025
}
2126

2227
fn main() {}

src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr renamed to src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error[E0308]: mismatched types
2-
--> $DIR/type-checking-test-4.rs:17:13
2+
--> $DIR/type-checking-test-4.rs:20:13
33
|
44
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
55
| ^ lifetime mismatch
66
|
77
= note: expected trait object `dyn Bar<'static, 'a>`
88
found trait object `dyn Bar<'static, 'static>`
99
note: the lifetime `'a` as defined here...
10-
--> $DIR/type-checking-test-4.rs:16:16
10+
--> $DIR/type-checking-test-4.rs:19:16
1111
|
1212
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
1313
| ^^
1414
= note: ...does not necessarily outlive the static lifetime
1515

1616
error[E0308]: mismatched types
17-
--> $DIR/type-checking-test-4.rs:22:13
17+
--> $DIR/type-checking-test-4.rs:26:13
1818
|
1919
LL | let _ = x as &dyn Bar<'a, 'static>; // Error
2020
| ^ lifetime mismatch
2121
|
2222
= note: expected trait object `dyn Bar<'a, 'static>`
2323
found trait object `dyn Bar<'static, 'static>`
2424
note: the lifetime `'a` as defined here...
25-
--> $DIR/type-checking-test-4.rs:21:16
25+
--> $DIR/type-checking-test-4.rs:25:16
2626
|
2727
LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
2828
| ^^
2929
= note: ...does not necessarily outlive the static lifetime
3030

3131
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
32-
--> $DIR/type-checking-test-4.rs:27:27
32+
--> $DIR/type-checking-test-4.rs:32:27
3333
|
3434
LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
3535
| ------------ this data with lifetime `'a`...
@@ -42,12 +42,12 @@ LL | y.get_b() // ERROR
4242
| - ...is used here...
4343
|
4444
note: ...and is required to live as long as `'static` here
45-
--> $DIR/type-checking-test-4.rs:29:5
45+
--> $DIR/type-checking-test-4.rs:34:5
4646
|
4747
LL | y.get_b() // ERROR
4848
| ^^^^^^^^^
4949
note: `'static` lifetime requirement introduced by the return type
50-
--> $DIR/type-checking-test-4.rs:26:48
50+
--> $DIR/type-checking-test-4.rs:31:48
5151
|
5252
LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
5353
| ^^^^^^^ `'static` requirement introduced here
@@ -56,39 +56,39 @@ LL | y.get_b() // ERROR
5656
| --------- because of this returned expression
5757

5858
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
59-
--> $DIR/type-checking-test-4.rs:33:5
59+
--> $DIR/type-checking-test-4.rs:39:5
6060
|
6161
LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
6262
| ------------ this data with lifetime `'a`...
6363
LL | <_ as Bar>::get_b(x) // ERROR
6464
| ^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here
6565
|
6666
note: `'static` lifetime requirement introduced by the return type
67-
--> $DIR/type-checking-test-4.rs:32:48
67+
--> $DIR/type-checking-test-4.rs:38:48
6868
|
6969
LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
7070
| ^^^^^^^ `'static` requirement introduced here
7171
LL | <_ as Bar>::get_b(x) // ERROR
7272
| -------------------- because of this returned expression
7373

7474
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
75-
--> $DIR/type-checking-test-4.rs:38:15
75+
--> $DIR/type-checking-test-4.rs:45:15
7676
|
7777
LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
7878
| ------------ this data with lifetime `'a`...
7979
LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR
8080
| ----------^^------------- ...is used and required to live as long as `'static` here
8181
|
8282
note: `'static` lifetime requirement introduced by the return type
83-
--> $DIR/type-checking-test-4.rs:37:48
83+
--> $DIR/type-checking-test-4.rs:44:48
8484
|
8585
LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
8686
| ^^^^^^^ `'static` requirement introduced here
8787
LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR
8888
| ---------------------------- because of this returned expression
8989

9090
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
91-
--> $DIR/type-checking-test-4.rs:43:27
91+
--> $DIR/type-checking-test-4.rs:51:27
9292
|
9393
LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
9494
| ------------ this data with lifetime `'a`...
@@ -104,12 +104,12 @@ LL | z.get_b() // ERROR
104104
| - ...is used here...
105105
|
106106
note: ...and is required to live as long as `'static` here
107-
--> $DIR/type-checking-test-4.rs:47:5
107+
--> $DIR/type-checking-test-4.rs:55:5
108108
|
109109
LL | z.get_b() // ERROR
110110
| ^^^^^^^^^
111111
note: `'static` lifetime requirement introduced by the return type
112-
--> $DIR/type-checking-test-4.rs:42:48
112+
--> $DIR/type-checking-test-4.rs:50:48
113113
|
114114
LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
115115
| ^^^^^^^ `'static` requirement introduced here
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/type-checking-test-4.rs:20:13
3+
|
4+
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
5+
| -- lifetime `'a` defined here
6+
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
8+
9+
error: lifetime may not live long enough
10+
--> $DIR/type-checking-test-4.rs:26:13
11+
|
12+
LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
13+
| -- lifetime `'a` defined here
14+
LL | let _ = x as &dyn Bar<'a, 'static>; // Error
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
16+
17+
error: lifetime may not live long enough
18+
--> $DIR/type-checking-test-4.rs:34:5
19+
|
20+
LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
21+
| -- lifetime `'a` defined here
22+
...
23+
LL | y.get_b() // ERROR
24+
| ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
25+
26+
error: lifetime may not live long enough
27+
--> $DIR/type-checking-test-4.rs:39:5
28+
|
29+
LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
30+
| -- lifetime `'a` defined here
31+
LL | <_ as Bar>::get_b(x) // ERROR
32+
| ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
33+
34+
error: lifetime may not live long enough
35+
--> $DIR/type-checking-test-4.rs:45:5
36+
|
37+
LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
38+
| -- lifetime `'a` defined here
39+
LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
41+
42+
error: lifetime may not live long enough
43+
--> $DIR/type-checking-test-4.rs:55:5
44+
|
45+
LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
46+
| -- lifetime `'a` defined here
47+
...
48+
LL | z.get_b() // ERROR
49+
| ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
50+
51+
error: aborting due to 6 previous errors
52+

src/test/ui/traits/trait-upcasting/type-checking-test-4.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// revisions: base nll
12
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
25
#![feature(trait_upcasting)]
36
#![allow(incomplete_features)]
47

@@ -15,36 +18,42 @@ fn test_correct(x: &dyn Foo<'static>) {
1518

1619
fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
1720
let _ = x as &dyn Bar<'static, 'a>; // Error
18-
//~^ ERROR mismatched types
21+
//[base]~^ ERROR mismatched types
22+
//[nll]~^^ ERROR lifetime may not live long enough
1923
}
2024

2125
fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
2226
let _ = x as &dyn Bar<'a, 'static>; // Error
23-
//~^ ERROR mismatched types
27+
//[base]~^ ERROR mismatched types
28+
//[nll]~^^ ERROR lifetime may not live long enough
2429
}
2530

2631
fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
2732
let y = x as &dyn Bar<'_, '_>;
28-
//~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
33+
//[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
2934
y.get_b() // ERROR
35+
//[nll]~^ ERROR lifetime may not live long enough
3036
}
3137

3238
fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
3339
<_ as Bar>::get_b(x) // ERROR
34-
//~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
40+
//[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
41+
//[nll]~^^ ERROR lifetime may not live long enough
3542
}
3643

3744
fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
3845
<_ as Bar<'_, '_>>::get_b(x) // ERROR
39-
//~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
46+
//[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
47+
//[nll]~^^ ERROR lifetime may not live long enough
4048
}
4149

4250
fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
4351
let y = x as &dyn Bar<'_, '_>;
44-
//~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
52+
//[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
4553
y.get_b(); // ERROR
4654
let z = y;
4755
z.get_b() // ERROR
56+
//[nll]~^ ERROR lifetime may not live long enough
4857
}
4958

5059
fn main() {}

0 commit comments

Comments
 (0)