Use revisions for NLL in async-await

This commit is contained in:
Jack Huey 2022-05-21 15:46:25 -04:00
parent 0fbb315be7
commit 34a3154bd9
15 changed files with 76 additions and 31 deletions

View File

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/issue-76547.rs:20:13
--> $DIR/issue-76547.rs:24:13
|
LL | async fn fut(bufs: &mut [&mut [u8]]) {
| ---------------- these two types are declared with different lifetimes...
@ -7,7 +7,7 @@ LL | ListFut(bufs).await
| ^^^^ ...but data from `bufs` flows into `bufs` here
error[E0623]: lifetime mismatch
--> $DIR/issue-76547.rs:34:14
--> $DIR/issue-76547.rs:39:14
|
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
| ---------------- these two types are declared with different lifetimes...

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-76547.rs:20:13
--> $DIR/issue-76547.rs:24:13
|
LL | async fn fut(bufs: &mut [&mut [u8]]) {
| - - let's call the lifetime of this reference `'2`
@ -9,7 +9,7 @@ LL | ListFut(bufs).await
| ^^^^ this usage requires that `'1` must outlive `'2`
error: lifetime may not live long enough
--> $DIR/issue-76547.rs:34:14
--> $DIR/issue-76547.rs:39:14
|
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
| - - let's call the lifetime of this reference `'2`

View File

@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// Test for diagnostic improvement issue #76547
// edition:2018
@ -18,7 +22,8 @@ impl<'a> Future for ListFut<'a> {
async fn fut(bufs: &mut [&mut [u8]]) {
ListFut(bufs).await
//~^ ERROR lifetime mismatch
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
}
pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]);
@ -32,7 +37,8 @@ impl<'a> Future for ListFut2<'a> {
async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
ListFut2(bufs).await
//~^ ERROR lifetime mismatch
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() {}

View File

@ -1,13 +1,14 @@
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/issue-62097.rs:12:31
--> $DIR/issue-62097.rs:16:31
|
LL | pub async fn run_dummy_fn(&self) {
| ^^^^^ this data with an anonymous lifetime `'_`...
LL |
LL | foo(|| self.bar()).await;
| --- ...is used and required to live as long as `'static` here
|
note: `'static` lifetime requirement introduced by this bound
--> $DIR/issue-62097.rs:4:19
--> $DIR/issue-62097.rs:8:19
|
LL | F: FnOnce() + 'static
| ^^^^^^^

View File

@ -1,5 +1,5 @@
error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
--> $DIR/issue-62097.rs:13:13
--> $DIR/issue-62097.rs:18:13
|
LL | foo(|| self.bar()).await;
| ^^ ---- `self` is borrowed here
@ -7,7 +7,7 @@ LL | foo(|| self.bar()).await;
| may outlive borrowed value `self`
|
note: function requires argument type to outlive `'static`
--> $DIR/issue-62097.rs:13:9
--> $DIR/issue-62097.rs:18:9
|
LL | foo(|| self.bar()).await;
| ^^^^^^^^^^^^^^^^^^
@ -17,13 +17,14 @@ LL | foo(move || self.bar()).await;
| ++++
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-62097.rs:13:9
--> $DIR/issue-62097.rs:18:9
|
LL | pub async fn run_dummy_fn(&self) {
| -----
| |
| `self` is a reference that is only valid in the associated function body
| let's call the lifetime of this reference `'1`
LL |
LL | foo(|| self.bar()).await;
| ^^^^^^^^^^^^^^^^^^
| |

View File

@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// edition:2018
async fn foo<F>(fun: F)
where
@ -9,8 +13,11 @@ where
struct Struct;
impl Struct {
pub async fn run_dummy_fn(&self) { //~ ERROR E0759
pub async fn run_dummy_fn(&self) {
//[base]~^ ERROR E0759
foo(|| self.bar()).await;
//[nll]~^ ERROR closure may outlive the current function
//[nll]~| ERROR borrowed data escapes outside of associated function
}
pub fn bar(&self) {}

View File

@ -1,11 +1,11 @@
error[E0623]: lifetime mismatch
--> $DIR/issue-63388-1.rs:14:9
--> $DIR/issue-63388-1.rs:19:9
|
LL | &'a self, foo: &dyn Foo
| -------- this parameter and the return type are declared with different lifetimes...
LL | ) -> &dyn Foo
| --------
LL | {
...
LL | foo
| ^^^ ...but data from `foo` is returned here

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-63388-1.rs:13:5
--> $DIR/issue-63388-1.rs:17:5
|
LL | async fn do_sth<'a>(
| -- lifetime `'a` defined here
@ -7,7 +7,9 @@ LL | &'a self, foo: &dyn Foo
| - let's call the lifetime of this reference `'1`
LL | ) -> &dyn Foo
LL | / {
LL | |
LL | | foo
LL | |
LL | | }
| |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`

View File

@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// edition:2018
struct Xyz {
@ -11,7 +15,9 @@ impl Xyz {
&'a self, foo: &dyn Foo
) -> &dyn Foo
{
foo //~ ERROR lifetime mismatch
//[nll]~^ ERROR lifetime may not live long enough
foo
//[base]~^ ERROR lifetime mismatch
}
}

View File

@ -1,5 +1,5 @@
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/issue-72312.rs:10:24
--> $DIR/issue-72312.rs:14:24
|
LL | pub async fn start(&self) {
| ^^^^^ this data with an anonymous lifetime `'_`...
@ -8,12 +8,12 @@ LL | &self;
| ----- ...is used here...
|
note: ...and is required to live as long as `'static` here
--> $DIR/issue-72312.rs:13:9
--> $DIR/issue-72312.rs:20:9
|
LL | require_static(async move {
| ^^^^^^^^^^^^^^
note: `'static` lifetime requirement introduced by this bound
--> $DIR/issue-72312.rs:2:22
--> $DIR/issue-72312.rs:6:22
|
LL | fn require_static<T: 'static>(val: T) -> T {
| ^^^^^^^

View File

@ -1,5 +1,5 @@
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-72312.rs:13:24
--> $DIR/issue-72312.rs:20:24
|
LL | pub async fn start(&self) {
| -----
@ -9,6 +9,10 @@ LL | pub async fn start(&self) {
...
LL | require_static(async move {
| ________________________^
LL | |
LL | |
LL | |
LL | |
LL | | &self;
LL | | });
| | ^

View File

@ -1,17 +1,28 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// edition:2018
fn require_static<T: 'static>(val: T) -> T {
//~^ NOTE 'static` lifetime requirement introduced by this bound
//[base]~^ NOTE 'static` lifetime requirement introduced by this bound
val
}
struct Problem;
impl Problem {
pub async fn start(&self) { //~ ERROR E0759
//~^ NOTE this data with an anonymous lifetime `'_`
//~| NOTE in this expansion of desugaring of `async` block or function
require_static(async move { //~ NOTE ...and is required to live as long as `'static` here
&self; //~ NOTE ...is used here...
pub async fn start(&self) {
//[base]~^ ERROR E0759
//[base]~| NOTE this data with an anonymous lifetime `'_`
//[base]~| NOTE in this expansion of desugaring of `async` block or function
//[nll]~^^^^ NOTE let's call
//[nll]~| NOTE `self` is a reference
require_static(async move {
//[base]~^ NOTE ...and is required to live as long as `'static` here
//[nll]~^^ ERROR borrowed data escapes
//[nll]~| NOTE `self` escapes
//[nll]~| NOTE argument requires
&self; //[base]~ NOTE ...is used here...
});
}
}

View File

@ -1,17 +1,18 @@
error[E0623]: lifetime mismatch
--> $DIR/ret-impl-trait-one.rs:10:85
--> $DIR/ret-impl-trait-one.rs:14:85
|
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
| ______________________________________________________------_____-------------------_^
| | |
| | this parameter and the return type are declared with different lifetimes...
LL | |
LL | |
LL | | (a, b)
LL | | }
| |_^ ...but data from `a` is returned here
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> $DIR/ret-impl-trait-one.rs:16:80
--> $DIR/ret-impl-trait-one.rs:21:80
|
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
| ____________________________________--__________________________________________^

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/ret-impl-trait-one.rs:10:85
--> $DIR/ret-impl-trait-one.rs:14:85
|
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
| ________________________________--__--_______________________________________________^
@ -7,6 +7,7 @@ LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trai
| | | lifetime `'b` defined here
| | lifetime `'a` defined here
LL | |
LL | |
LL | | (a, b)
LL | | }
| |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
@ -14,7 +15,7 @@ LL | | }
= help: consider adding the following bound: `'a: 'b`
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> $DIR/ret-impl-trait-one.rs:16:80
--> $DIR/ret-impl-trait-one.rs:21:80
|
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
| ____________________________________--__________________________________________^

View File

@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// edition:2018
// Test that a feature gate is needed to use `impl Trait` as the
@ -8,7 +12,8 @@ impl<T> Trait<'_> for T { }
// Fails to recognize that both 'a and 'b are mentioned and should thus be accepted
async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
//~^ ERROR lifetime mismatch
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
(a, b)
}