diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-20 17:10:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-20 17:10:34 +0100 |
| commit | 413f490677d7d58e6d3a14c9fc5d9be11e5d668d (patch) | |
| tree | 4327d1f3b5944d0d2bdad7313ec83946cd92cd9e /src | |
| parent | 405cf2044210f5f2286d6b526882744d403ea805 (diff) | |
| parent | 698631e16c390c29bacc778e35aba1dc27bed57f (diff) | |
| download | rust-413f490677d7d58e6d3a14c9fc5d9be11e5d668d.tar.gz rust-413f490677d7d58e6d3a14c9fc5d9be11e5d668d.zip | |
Rollup merge of #92183 - tmandry:issue-74256, r=estebank
Point at correct argument when async fn output type lifetime disagrees with signature
Fixes most of #74256.
## Problems fixed
This PR fixes a couple of related problems in the error reporting code.
### Highlighting the wrong argument
First, the error reporting code was looking at the desugared return type of an `async fn` to decide which parameter to highlight. For example, a function like
```rust
async fn async_fn(self: &Struct, f: &u32) -> &u32
{ f }
```
desugars to
```rust
async fn async_fn<'a, 'b>(self: &'a Struct, f: &'b u32)
-> impl Future<Output = &'a u32> + 'a + 'b
{ f }
```
Since `f: &'b u32` is returned but the output type is `&'a u32`, the error would occur when checking that `'a: 'b`.
The reporting code would look to see if the "offending" lifetime `'b` was included in the return type, and because the code was looking at the desugared future type, it was included. So it defaulted to reporting that the source of the other lifetime `'a` (the `self` type) was the problem, when it was really the type of `f`. (Note that if it had chosen instead to look at `'a` first, it too would have been included in the output type, and it would have arbitrarily reported the error (correctly this time) on the type of `f`.)
Looking at the actual future type isn't useful for this reason; it captures all input lifetimes. Using the written return type for `async fn` solves this problem and results in less confusing error messages for the user.
This isn't a perfect fix, unfortunately; writing the "manually desugared" form of the above function still results in the wrong parameter being highlighted. Looking at the output type of every `impl Future` return type doesn't feel like a very principled approach, though it might work. The problem would remain for function signatures that look like the desugared one above but use different traits. There may be deeper changes required to pinpoint which part of each type is conflicting.
### Lying about await point capture causing lifetime conflicts
The second issue fixed by this PR is the unnecessary complexity in `try_report_anon_anon_conflict`. It turns out that the root cause I suggested in https://github.com/rust-lang/rust/issues/76547#issuecomment-692863608 wasn't really the root cause. Adding special handling to report that a variable was captured over an await point only made the error messages less correct and pointed to a problem other than the one that actually occurred.
Given the above discussion, it's easy to see why: `async fn`s capture all input lifetimes in their return type, so holding an argument across an await point should never cause a lifetime conflict! Removing the special handling simplified the code and improved the error messages (though they still aren't very good!)
## Future work
* Fix error reporting on the "desugared" form of this code
* Get the `suggest_adding_lifetime_params` suggestion firing on these examples
* cc #42703, I think
r? `@estebank`
Diffstat (limited to 'src')
9 files changed, 133 insertions, 174 deletions
diff --git a/src/test/ui/async-await/issue-76547.stderr b/src/test/ui/async-await/issue-76547.stderr index 9bfb0f28028..ac5f99970c8 100644 --- a/src/test/ui/async-await/issue-76547.stderr +++ b/src/test/ui/async-await/issue-76547.stderr @@ -2,23 +2,17 @@ error[E0623]: lifetime mismatch --> $DIR/issue-76547.rs:20:13 | LL | async fn fut(bufs: &mut [&mut [u8]]) { - | --------- - - | | | - | | this `async fn` implicitly returns an `impl Future<Output = ()>` - | this parameter and the returned future are declared with different lifetimes... + | ---------------- these two types are declared with different lifetimes... LL | ListFut(bufs).await - | ^^^^ ...but data from `bufs` is held across an await point here + | ^^^^ ...but data from `bufs` flows into `bufs` here error[E0623]: lifetime mismatch --> $DIR/issue-76547.rs:34:14 | LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { - | --------- --- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = i32>` - | this parameter and the returned future are declared with different lifetimes... + | ---------------- these two types are declared with different lifetimes... LL | ListFut2(bufs).await - | ^^^^ ...but data from `bufs` is held across an await point here + | ^^^^ ...but data from `bufs` flows into `bufs` here error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.stderr index ac29cca9d3f..8f602a1492a 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.stderr @@ -2,14 +2,12 @@ error[E0623]: lifetime mismatch --> $DIR/issue-63388-1.rs:14:9 | LL | &'a self, foo: &dyn Foo - | -------- this parameter and the returned future are declared with different lifetimes... + | -------- this parameter and the return type are declared with different lifetimes... LL | ) -> &dyn Foo | -------- - | | - | this `async fn` implicitly returns an `impl Future<Output = &dyn Foo>` LL | { LL | foo - | ^^^ ...but data from `foo` is held across an await point here + | ^^^ ...but data from `foo` is returned here error: aborting due to previous error diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr index 464f283095d..149692a2c69 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr @@ -4,9 +4,8 @@ error[E0623]: lifetime mismatch LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { | ------ ^^^^^^^^^^^^^^^^^^^ | | | - | | ...but data from `a` is held across an await point here - | | this `async fn` implicitly returns an `impl Future<Output = impl Trait<'a> + 'b>` - | this parameter and the returned future are declared with different lifetimes... + | | ...but data from `a` is returned here + | this parameter and the return type are declared with different lifetimes... error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/ret-impl-trait-one.rs:16:65 diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index e6846fb4049..299a2d2f2d3 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -2,28 +2,25 @@ error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ---- ---- ^ ...but data from `f` is held across an await point here - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &Foo>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- ^ ...but data from `f` is returned here + | | + | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ----- ----------------- ^ ...but data from `f` is held across an await point here - | | | - | | this `async fn` implicitly returns an `impl Future<Output = (Pin<&Foo>, &Foo)>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ----------------- ^ ...but data from `f` is returned here + | | + | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | ----- --- ^^^ ...but data from `arg` is held across an await point here - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &()>` - | this parameter and the returned future are declared with different lifetimes... + | ------ --- ^^^ ...but data from `arg` is returned here + | | + | this parameter and the return type are declared with different lifetimes... error: aborting due to 3 previous errors diff --git a/src/test/ui/self/elision/lt-ref-self-async.stderr b/src/test/ui/self/elision/lt-ref-self-async.stderr index 3221d270850..7448e8484b4 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.stderr @@ -2,67 +2,61 @@ error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:13:9 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:19:9 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:23:9 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:27:9 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:31:9 | LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:35:9 | LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr index b6ca986923d..6056cc46d3d 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -2,67 +2,61 @@ error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:13:9 | LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:19:9 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:23:9 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:27:9 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:31:9 | LL | async fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:35:9 | LL | async fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 { - | --------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct-async.stderr b/src/test/ui/self/elision/ref-mut-struct-async.stderr index eda15d76390..61034ae4d47 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.stderr @@ -2,56 +2,51 @@ error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:13:9 | LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ----------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:17:9 | LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ----------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:21:9 | LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ----------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:25:9 | LL | async fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 { - | ----------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:29:9 | LL | async fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 { - | ----------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index b42caa88c6f..0eab16e685d 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -2,78 +2,71 @@ error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:23:9 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:29:9 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:33:9 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:37:9 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:41:9 | LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:45:9 | LL | async fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { - | ----- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:49:9 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ----- --- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u8>` - | this parameter and the returned future are declared with different lifetimes... + | --- --- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct-async.stderr b/src/test/ui/self/elision/ref-struct-async.stderr index 599becd3080..aa1d7453e83 100644 --- a/src/test/ui/self/elision/ref-struct-async.stderr +++ b/src/test/ui/self/elision/ref-struct-async.stderr @@ -2,56 +2,51 @@ error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:13:9 | LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:17:9 | LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:21:9 | LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:25:9 | LL | async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { - | ------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:29:9 | LL | async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { - | ------- ---- - | | | - | | this `async fn` implicitly returns an `impl Future<Output = &u32>` - | this parameter and the returned future are declared with different lifetimes... + | ---- ---- + | | + | this parameter and the return type are declared with different lifetimes... LL | f - | ^ ...but data from `f` is held across an await point here + | ^ ...but data from `f` is returned here error: aborting due to 5 previous errors |
