Skip to content

Commit b9f241d

Browse files
committed
Use revisions for NLL in impl-trait
1 parent 707d2eb commit b9f241d

7 files changed

+65
-45
lines changed

src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// edition:2018
22
// check-pass
3-
// revisions: migrate mir
4-
//[mir]compile-flags: -Z borrowck=mir
53

64
trait Trait<'a, 'b> {}
75
impl<T> Trait<'_, '_> for T {}

src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr renamed to src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
2-
--> $DIR/must_outlive_least_region_or_bound.rs:3:35
2+
--> $DIR/must_outlive_least_region_or_bound.rs:7:35
33
|
44
LL | fn elided(x: &i32) -> impl Copy { x }
55
| ---- ^
@@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x }
1212
| ++++
1313

1414
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
15-
--> $DIR/must_outlive_least_region_or_bound.rs:6:44
15+
--> $DIR/must_outlive_least_region_or_bound.rs:10:44
1616
|
1717
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
1818
| -- ^
@@ -25,15 +25,15 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
2525
| ++++
2626

2727
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
28-
--> $DIR/must_outlive_least_region_or_bound.rs:9:46
28+
--> $DIR/must_outlive_least_region_or_bound.rs:13:46
2929
|
3030
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
3131
| ---- ^ ...is used here...
3232
| |
3333
| this data with an anonymous lifetime `'_`...
3434
|
3535
note: ...and is required to live as long as `'static` here
36-
--> $DIR/must_outlive_least_region_or_bound.rs:9:24
36+
--> $DIR/must_outlive_least_region_or_bound.rs:13:24
3737
|
3838
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
3939
| ^^^^^^^^^^^^^^^^^^^
@@ -47,15 +47,15 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
4747
| ~~~~~~~~~~~~
4848

4949
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
50-
--> $DIR/must_outlive_least_region_or_bound.rs:11:55
50+
--> $DIR/must_outlive_least_region_or_bound.rs:17:55
5151
|
5252
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
5353
| ------- ^ ...is used here...
5454
| |
5555
| this data with lifetime `'a`...
5656
|
5757
note: ...and is required to live as long as `'static` here
58-
--> $DIR/must_outlive_least_region_or_bound.rs:11:33
58+
--> $DIR/must_outlive_least_region_or_bound.rs:17:33
5959
|
6060
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
6161
| ^^^^^^^^^^^^^^^^^^^
@@ -69,15 +69,15 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x }
6969
| ~~~~~~~~~~~~
7070

7171
error[E0621]: explicit lifetime required in the type of `x`
72-
--> $DIR/must_outlive_least_region_or_bound.rs:13:24
72+
--> $DIR/must_outlive_least_region_or_bound.rs:21:24
7373
|
7474
LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
7575
| ---- ^^^^^^^^^^^^^^ lifetime `'a` required
7676
| |
7777
| help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
7878

7979
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
80-
--> $DIR/must_outlive_least_region_or_bound.rs:24:65
80+
--> $DIR/must_outlive_least_region_or_bound.rs:36:65
8181
|
8282
LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) }
8383
| ---- this data with an anonymous lifetime `'_`... ^ ...is used and required to live as long as `'static` here
@@ -92,13 +92,13 @@ LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x)
9292
| ++++
9393

9494
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
95-
--> $DIR/must_outlive_least_region_or_bound.rs:29:69
95+
--> $DIR/must_outlive_least_region_or_bound.rs:43:69
9696
|
9797
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
9898
| ------- this data with lifetime `'a`... ^ ...is used here...
9999
|
100100
note: ...and is required to live as long as `'static` here
101-
--> $DIR/must_outlive_least_region_or_bound.rs:29:34
101+
--> $DIR/must_outlive_least_region_or_bound.rs:43:34
102102
|
103103
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
104104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -112,10 +112,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x
112112
| ~~~~~~~~~~~~
113113

114114
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
115-
--> $DIR/must_outlive_least_region_or_bound.rs:34:5
115+
--> $DIR/must_outlive_least_region_or_bound.rs:50:5
116116
|
117117
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
118-
| -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here
118+
| -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here
119119
LL | move |_| println!("{}", y)
120120
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
121121
|
@@ -125,7 +125,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32
125125
| ++++
126126

127127
error[E0310]: the parameter type `T` may not live long enough
128-
--> $DIR/must_outlive_least_region_or_bound.rs:38:51
128+
--> $DIR/must_outlive_least_region_or_bound.rs:54:51
129129
|
130130
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
131131
| ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
@@ -136,15 +136,15 @@ LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 's
136136
| +++++++++
137137

138138
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
139-
--> $DIR/must_outlive_least_region_or_bound.rs:16:50
139+
--> $DIR/must_outlive_least_region_or_bound.rs:24:50
140140
|
141141
LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
142142
| ---- ^ ...is used and required to live as long as `'static` here
143143
| |
144144
| this data with an anonymous lifetime `'_`...
145145
|
146146
note: `'static` lifetime requirement introduced by the return type
147-
--> $DIR/must_outlive_least_region_or_bound.rs:16:28
147+
--> $DIR/must_outlive_least_region_or_bound.rs:24:28
148148
|
149149
LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
150150
| ^^^^^^^^^ ----------- because of this returned expression
@@ -156,15 +156,15 @@ LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
156156
| ++++
157157

158158
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
159-
--> $DIR/must_outlive_least_region_or_bound.rs:18:59
159+
--> $DIR/must_outlive_least_region_or_bound.rs:27:59
160160
|
161161
LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
162162
| ------- ^ ...is used and required to live as long as `'static` here
163163
| |
164164
| this data with lifetime `'a`...
165165
|
166166
note: `'static` lifetime requirement introduced by the return type
167-
--> $DIR/must_outlive_least_region_or_bound.rs:18:37
167+
--> $DIR/must_outlive_least_region_or_bound.rs:27:37
168168
|
169169
LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
170170
| ^^^^^^^^^ ----------- because of this returned expression
@@ -176,15 +176,15 @@ LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
176176
| ++++
177177

178178
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
179-
--> $DIR/must_outlive_least_region_or_bound.rs:20:60
179+
--> $DIR/must_outlive_least_region_or_bound.rs:30:60
180180
|
181181
LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
182182
| ---- ^ ...is used and required to live as long as `'static` here
183183
| |
184184
| this data with an anonymous lifetime `'_`...
185185
|
186186
note: `'static` lifetime requirement introduced by the return type
187-
--> $DIR/must_outlive_least_region_or_bound.rs:20:40
187+
--> $DIR/must_outlive_least_region_or_bound.rs:30:40
188188
|
189189
LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
190190
| ^^^^^^^ ----------- because of this returned expression
@@ -200,13 +200,13 @@ LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) }
200200
| ~~~~~~~~~~~~
201201

202202
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
203-
--> $DIR/must_outlive_least_region_or_bound.rs:22:69
203+
--> $DIR/must_outlive_least_region_or_bound.rs:33:69
204204
|
205205
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
206206
| ------- this data with lifetime `'a`... ^ ...is used and required to live as long as `'static` here
207207
|
208208
note: `'static` lifetime requirement introduced by the return type
209-
--> $DIR/must_outlive_least_region_or_bound.rs:22:49
209+
--> $DIR/must_outlive_least_region_or_bound.rs:33:49
210210
|
211211
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
212212
| ^^^^^^^ ----------- because of this returned expression

src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
2-
--> $DIR/must_outlive_least_region_or_bound.rs:3:35
2+
--> $DIR/must_outlive_least_region_or_bound.rs:7:35
33
|
44
LL | fn elided(x: &i32) -> impl Copy { x }
55
| ---- ^
@@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x }
1212
| ++++
1313

1414
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
15-
--> $DIR/must_outlive_least_region_or_bound.rs:6:44
15+
--> $DIR/must_outlive_least_region_or_bound.rs:10:44
1616
|
1717
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
1818
| -- ^
@@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
2525
| ++++
2626

2727
error: lifetime may not live long enough
28-
--> $DIR/must_outlive_least_region_or_bound.rs:9:46
28+
--> $DIR/must_outlive_least_region_or_bound.rs:13:46
2929
|
3030
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
3131
| - ^ returning this value requires that `'1` must outlive `'static`
@@ -42,7 +42,7 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x }
4242
| ~~~~~~~~~~~~
4343

4444
error: lifetime may not live long enough
45-
--> $DIR/must_outlive_least_region_or_bound.rs:11:55
45+
--> $DIR/must_outlive_least_region_or_bound.rs:17:55
4646
|
4747
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
4848
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
@@ -57,15 +57,15 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x }
5757
| ~~~~~~~~~~~~
5858

5959
error[E0621]: explicit lifetime required in the type of `x`
60-
--> $DIR/must_outlive_least_region_or_bound.rs:13:41
60+
--> $DIR/must_outlive_least_region_or_bound.rs:21:41
6161
|
6262
LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
6363
| ---- ^ lifetime `'a` required
6464
| |
6565
| help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
6666

6767
error: lifetime may not live long enough
68-
--> $DIR/must_outlive_least_region_or_bound.rs:24:55
68+
--> $DIR/must_outlive_least_region_or_bound.rs:36:55
6969
|
7070
LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) }
7171
| - ^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
@@ -82,7 +82,7 @@ LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x)
8282
| ++++
8383

8484
error: lifetime may not live long enough
85-
--> $DIR/must_outlive_least_region_or_bound.rs:29:69
85+
--> $DIR/must_outlive_least_region_or_bound.rs:43:69
8686
|
8787
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
8888
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
@@ -97,10 +97,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x
9797
| ~~~~~~~~~~~~
9898

9999
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
100-
--> $DIR/must_outlive_least_region_or_bound.rs:34:5
100+
--> $DIR/must_outlive_least_region_or_bound.rs:50:5
101101
|
102102
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
103-
| -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here
103+
| -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here
104104
LL | move |_| println!("{}", y)
105105
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
106106
|
@@ -110,7 +110,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32
110110
| ++++
111111

112112
error[E0310]: the parameter type `T` may not live long enough
113-
--> $DIR/must_outlive_least_region_or_bound.rs:40:5
113+
--> $DIR/must_outlive_least_region_or_bound.rs:56:5
114114
|
115115
LL | x
116116
| ^ ...so that the type `T` will meet its required lifetime bounds
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// ignore-compare-mode-nll
2+
// revisions: base nll
3+
// [nll]compile-flags: -Zborrowck=mir
4+
15
use std::fmt::Debug;
26

37
fn elided(x: &i32) -> impl Copy { x }
@@ -6,27 +10,39 @@ fn elided(x: &i32) -> impl Copy { x }
610
fn explicit<'a>(x: &'a i32) -> impl Copy { x }
711
//~^ ERROR: captures lifetime that does not appear in bounds
812

9-
fn elided2(x: &i32) -> impl Copy + 'static { x } //~ ERROR E0759
13+
fn elided2(x: &i32) -> impl Copy + 'static { x }
14+
//[base]~^ ERROR E0759
15+
//[nll]~^^ ERROR lifetime may not live long enough
1016

11-
fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } //~ ERROR E0759
17+
fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
18+
//[base]~^ ERROR E0759
19+
//[nll]~^^ ERROR lifetime may not live long enough
1220

1321
fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
1422
//~^ ERROR explicit lifetime required in the type of `x`
1523

16-
fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } //~ ERROR E0759
24+
fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) }
25+
//[base]~^ ERROR E0759
1726

18-
fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } //~ ERROR E0759
27+
fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) }
28+
//[base]~^ ERROR E0759
1929

20-
fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } //~ ERROR E0759
30+
fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
31+
//[base]~^ ERROR E0759
2132

22-
fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } //~ ERROR E0759
33+
fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
34+
//[base]~^ ERROR E0759
2335

24-
fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } //~ ERROR E0759
36+
fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) }
37+
//[base]~^ ERROR E0759
38+
//[nll]~^^ ERROR lifetime may not live long enough
2539

2640
trait LifetimeTrait<'a> {}
2741
impl<'a> LifetimeTrait<'a> for &'a i32 {}
2842

29-
fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~ ERROR E0759
43+
fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
44+
//[base]~^ ERROR E0759
45+
//[nll]~^^ ERROR lifetime may not live long enough
3046

3147
// Tests that a closure type containing 'b cannot be returned from a type where
3248
// only 'a was expected.
@@ -36,8 +52,9 @@ fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
3652
}
3753

3854
fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
39-
//~^ ERROR the parameter type `T` may not live long enough
55+
//[base]~^ ERROR the parameter type `T` may not live long enough
4056
x
57+
//[nll]~^ ERROR the parameter type `T` may not live long enough
4158
}
4259

4360
fn main() {}

src/test/ui/impl-trait/type_parameters_captured.stderr renamed to src/test/ui/impl-trait/type_parameters_captured.base.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0310]: the parameter type `T` may not live long enough
2-
--> $DIR/type_parameters_captured.rs:7:20
2+
--> $DIR/type_parameters_captured.rs:11:20
33
|
44
LL | fn foo<T>(x: T) -> impl Any + 'static {
55
| ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds

src/test/ui/impl-trait/type_parameters_captured.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0310]: the parameter type `T` may not live long enough
2-
--> $DIR/type_parameters_captured.rs:9:5
2+
--> $DIR/type_parameters_captured.rs:13:5
33
|
44
LL | x
55
| ^ ...so that the type `T` will meet its required lifetime bounds
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
// ignore-compare-mode-nll
2+
// revisions: base nll
3+
// [nll]compile-flags: -Zborrowck=mir
4+
15
use std::fmt::Debug;
26

37
trait Any {}
48
impl<T> Any for T {}
59

610
// Check that type parameters are captured and not considered 'static
711
fn foo<T>(x: T) -> impl Any + 'static {
8-
//~^ ERROR the parameter type `T` may not live long enough
12+
//[base]~^ ERROR the parameter type `T` may not live long enough
913
x
14+
//[nll]~^ ERROR the parameter type `T` may not live long enough
1015
}
1116

1217
fn main() {}

0 commit comments

Comments
 (0)