Skip to content

Commit 34a3154

Browse files
committed
Use revisions for NLL in async-await
1 parent 0fbb315 commit 34a3154

15 files changed

+76
-31
lines changed

src/test/ui/async-await/issue-76547.stderr renamed to src/test/ui/async-await/issue-76547.base.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/issue-76547.rs:20:13
2+
--> $DIR/issue-76547.rs:24:13
33
|
44
LL | async fn fut(bufs: &mut [&mut [u8]]) {
55
| ---------------- these two types are declared with different lifetimes...
66
LL | ListFut(bufs).await
77
| ^^^^ ...but data from `bufs` flows into `bufs` here
88

99
error[E0623]: lifetime mismatch
10-
--> $DIR/issue-76547.rs:34:14
10+
--> $DIR/issue-76547.rs:39:14
1111
|
1212
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
1313
| ---------------- these two types are declared with different lifetimes...

src/test/ui/async-await/issue-76547.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/issue-76547.rs:20:13
2+
--> $DIR/issue-76547.rs:24:13
33
|
44
LL | async fn fut(bufs: &mut [&mut [u8]]) {
55
| - - let's call the lifetime of this reference `'2`
@@ -9,7 +9,7 @@ LL | ListFut(bufs).await
99
| ^^^^ this usage requires that `'1` must outlive `'2`
1010

1111
error: lifetime may not live long enough
12-
--> $DIR/issue-76547.rs:34:14
12+
--> $DIR/issue-76547.rs:39:14
1313
|
1414
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
1515
| - - let's call the lifetime of this reference `'2`

src/test/ui/async-await/issue-76547.rs

Lines changed: 8 additions & 2 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
// Test for diagnostic improvement issue #76547
26
// edition:2018
37

@@ -18,7 +22,8 @@ impl<'a> Future for ListFut<'a> {
1822

1923
async fn fut(bufs: &mut [&mut [u8]]) {
2024
ListFut(bufs).await
21-
//~^ ERROR lifetime mismatch
25+
//[base]~^ ERROR lifetime mismatch
26+
//[nll]~^^ ERROR lifetime may not live long enough
2227
}
2328

2429
pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]);
@@ -32,7 +37,8 @@ impl<'a> Future for ListFut2<'a> {
3237

3338
async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
3439
ListFut2(bufs).await
35-
//~^ ERROR lifetime mismatch
40+
//[base]~^ ERROR lifetime mismatch
41+
//[nll]~^^ ERROR lifetime may not live long enough
3642
}
3743

3844
fn main() {}

src/test/ui/async-await/issues/issue-62097.stderr renamed to src/test/ui/async-await/issues/issue-62097.base.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/issue-62097.rs:12:31
2+
--> $DIR/issue-62097.rs:16:31
33
|
44
LL | pub async fn run_dummy_fn(&self) {
55
| ^^^^^ this data with an anonymous lifetime `'_`...
6+
LL |
67
LL | foo(|| self.bar()).await;
78
| --- ...is used and required to live as long as `'static` here
89
|
910
note: `'static` lifetime requirement introduced by this bound
10-
--> $DIR/issue-62097.rs:4:19
11+
--> $DIR/issue-62097.rs:8:19
1112
|
1213
LL | F: FnOnce() + 'static
1314
| ^^^^^^^

src/test/ui/async-await/issues/issue-62097.nll.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
2-
--> $DIR/issue-62097.rs:13:13
2+
--> $DIR/issue-62097.rs:18:13
33
|
44
LL | foo(|| self.bar()).await;
55
| ^^ ---- `self` is borrowed here
66
| |
77
| may outlive borrowed value `self`
88
|
99
note: function requires argument type to outlive `'static`
10-
--> $DIR/issue-62097.rs:13:9
10+
--> $DIR/issue-62097.rs:18:9
1111
|
1212
LL | foo(|| self.bar()).await;
1313
| ^^^^^^^^^^^^^^^^^^
@@ -17,13 +17,14 @@ LL | foo(move || self.bar()).await;
1717
| ++++
1818

1919
error[E0521]: borrowed data escapes outside of associated function
20-
--> $DIR/issue-62097.rs:13:9
20+
--> $DIR/issue-62097.rs:18:9
2121
|
2222
LL | pub async fn run_dummy_fn(&self) {
2323
| -----
2424
| |
2525
| `self` is a reference that is only valid in the associated function body
2626
| let's call the lifetime of this reference `'1`
27+
LL |
2728
LL | foo(|| self.bar()).await;
2829
| ^^^^^^^^^^^^^^^^^^
2930
| |

src/test/ui/async-await/issues/issue-62097.rs

Lines changed: 8 additions & 1 deletion
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
// edition:2018
26
async fn foo<F>(fun: F)
37
where
@@ -9,8 +13,11 @@ where
913
struct Struct;
1014

1115
impl Struct {
12-
pub async fn run_dummy_fn(&self) { //~ ERROR E0759
16+
pub async fn run_dummy_fn(&self) {
17+
//[base]~^ ERROR E0759
1318
foo(|| self.bar()).await;
19+
//[nll]~^ ERROR closure may outlive the current function
20+
//[nll]~| ERROR borrowed data escapes outside of associated function
1421
}
1522

1623
pub fn bar(&self) {}

src/test/ui/async-await/issues/issue-63388-1.stderr renamed to src/test/ui/async-await/issues/issue-63388-1.base.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/issue-63388-1.rs:14:9
2+
--> $DIR/issue-63388-1.rs:19:9
33
|
44
LL | &'a self, foo: &dyn Foo
55
| -------- this parameter and the return type are declared with different lifetimes...
66
LL | ) -> &dyn Foo
77
| --------
8-
LL | {
8+
...
99
LL | foo
1010
| ^^^ ...but data from `foo` is returned here
1111

src/test/ui/async-await/issues/issue-63388-1.nll.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
error: lifetime may not live long enough
2-
--> $DIR/issue-63388-1.rs:13:5
2+
--> $DIR/issue-63388-1.rs:17:5
33
|
44
LL | async fn do_sth<'a>(
55
| -- lifetime `'a` defined here
66
LL | &'a self, foo: &dyn Foo
77
| - let's call the lifetime of this reference `'1`
88
LL | ) -> &dyn Foo
99
LL | / {
10+
LL | |
1011
LL | | foo
12+
LL | |
1113
LL | | }
1214
| |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
1315

src/test/ui/async-await/issues/issue-63388-1.rs

Lines changed: 7 additions & 1 deletion
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
// edition:2018
26

37
struct Xyz {
@@ -11,7 +15,9 @@ impl Xyz {
1115
&'a self, foo: &dyn Foo
1216
) -> &dyn Foo
1317
{
14-
foo //~ ERROR lifetime mismatch
18+
//[nll]~^ ERROR lifetime may not live long enough
19+
foo
20+
//[base]~^ ERROR lifetime mismatch
1521
}
1622
}
1723

src/test/ui/async-await/issues/issue-72312.stderr renamed to src/test/ui/async-await/issues/issue-72312.base.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/issue-72312.rs:10:24
2+
--> $DIR/issue-72312.rs:14:24
33
|
44
LL | pub async fn start(&self) {
55
| ^^^^^ this data with an anonymous lifetime `'_`...
@@ -8,12 +8,12 @@ LL | &self;
88
| ----- ...is used here...
99
|
1010
note: ...and is required to live as long as `'static` here
11-
--> $DIR/issue-72312.rs:13:9
11+
--> $DIR/issue-72312.rs:20:9
1212
|
1313
LL | require_static(async move {
1414
| ^^^^^^^^^^^^^^
1515
note: `'static` lifetime requirement introduced by this bound
16-
--> $DIR/issue-72312.rs:2:22
16+
--> $DIR/issue-72312.rs:6:22
1717
|
1818
LL | fn require_static<T: 'static>(val: T) -> T {
1919
| ^^^^^^^

src/test/ui/async-await/issues/issue-72312.nll.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0521]: borrowed data escapes outside of associated function
2-
--> $DIR/issue-72312.rs:13:24
2+
--> $DIR/issue-72312.rs:20:24
33
|
44
LL | pub async fn start(&self) {
55
| -----
@@ -9,6 +9,10 @@ LL | pub async fn start(&self) {
99
...
1010
LL | require_static(async move {
1111
| ________________________^
12+
LL | |
13+
LL | |
14+
LL | |
15+
LL | |
1216
LL | | &self;
1317
LL | | });
1418
| | ^

src/test/ui/async-await/issues/issue-72312.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1+
// ignore-compare-mode-nll
2+
// revisions: base nll
3+
// [nll]compile-flags: -Zborrowck=mir
4+
15
// edition:2018
26
fn require_static<T: 'static>(val: T) -> T {
3-
//~^ NOTE 'static` lifetime requirement introduced by this bound
7+
//[base]~^ NOTE 'static` lifetime requirement introduced by this bound
48
val
59
}
610

711
struct Problem;
812

913
impl Problem {
10-
pub async fn start(&self) { //~ ERROR E0759
11-
//~^ NOTE this data with an anonymous lifetime `'_`
12-
//~| NOTE in this expansion of desugaring of `async` block or function
13-
require_static(async move { //~ NOTE ...and is required to live as long as `'static` here
14-
&self; //~ NOTE ...is used here...
14+
pub async fn start(&self) {
15+
//[base]~^ ERROR E0759
16+
//[base]~| NOTE this data with an anonymous lifetime `'_`
17+
//[base]~| NOTE in this expansion of desugaring of `async` block or function
18+
//[nll]~^^^^ NOTE let's call
19+
//[nll]~| NOTE `self` is a reference
20+
require_static(async move {
21+
//[base]~^ NOTE ...and is required to live as long as `'static` here
22+
//[nll]~^^ ERROR borrowed data escapes
23+
//[nll]~| NOTE `self` escapes
24+
//[nll]~| NOTE argument requires
25+
&self; //[base]~ NOTE ...is used here...
1526
});
1627
}
1728
}

src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr renamed to src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/ret-impl-trait-one.rs:10:85
2+
--> $DIR/ret-impl-trait-one.rs:14:85
33
|
44
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
55
| ______________________________________________________------_____-------------------_^
66
| | |
77
| | this parameter and the return type are declared with different lifetimes...
88
LL | |
9+
LL | |
910
LL | | (a, b)
1011
LL | | }
1112
| |_^ ...but data from `a` is returned here
1213

1314
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
14-
--> $DIR/ret-impl-trait-one.rs:16:80
15+
--> $DIR/ret-impl-trait-one.rs:21:80
1516
|
1617
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
1718
| ____________________________________--__________________________________________^

src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ret-impl-trait-one.rs:10:85
2+
--> $DIR/ret-impl-trait-one.rs:14:85
33
|
44
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
55
| ________________________________--__--_______________________________________________^
66
| | | |
77
| | | lifetime `'b` defined here
88
| | lifetime `'a` defined here
99
LL | |
10+
LL | |
1011
LL | | (a, b)
1112
LL | | }
1213
| |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
1314
|
1415
= help: consider adding the following bound: `'a: 'b`
1516

1617
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
17-
--> $DIR/ret-impl-trait-one.rs:16:80
18+
--> $DIR/ret-impl-trait-one.rs:21:80
1819
|
1920
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
2021
| ____________________________________--__________________________________________^

src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs

Lines changed: 6 additions & 1 deletion
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
// edition:2018
26

37
// Test that a feature gate is needed to use `impl Trait` as the
@@ -8,7 +12,8 @@ impl<T> Trait<'_> for T { }
812

913
// Fails to recognize that both 'a and 'b are mentioned and should thus be accepted
1014
async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
11-
//~^ ERROR lifetime mismatch
15+
//[base]~^ ERROR lifetime mismatch
16+
//[nll]~^^ ERROR lifetime may not live long enough
1217
(a, b)
1318
}
1419

0 commit comments

Comments
 (0)