forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#63499 - nikomatsakis:issuee-63388-async-fn-…
…elision-self-mut-self, r=cramertj handle elision in async fn correctly We now always make fresh lifetimne parameters for all elided lifetimes, whether they are in the inputs or outputs. But then we generate `'_` in the case of elided lifetimes from the outputs. Example: ```rust async fn foo<'a>(x: &'a u32) -> &u32 { .. } ``` becomes ```rust type Foo<'a, 'b> = impl Future<Output = &'b u32>; fn foo<'a>(x: &'a u32) -> Foo<'a, '_> ``` Fixes rust-lang#63388
- Loading branch information
Showing
43 changed files
with
983 additions
and
1,908 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds | ||
--> $DIR/issue-63388-1.rs:14:10 | ||
| | ||
LL | ) -> &dyn Foo | ||
| ^^^^^^^^ | ||
| | ||
= note: hidden type `impl std::future::Future` captures lifetime '_#27r | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/issue-63388-1.rs:15:5 | ||
| | ||
LL | async fn do_sth<'a>( | ||
| -- lifetime `'a` defined here | ||
LL | &'a self, foo: &dyn Foo | ||
| - lifetime `'_` defined here | ||
LL | ) -> &dyn Foo | ||
LL | / { | ||
LL | | foo | ||
LL | | } | ||
| |_____^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'_` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// edition:2018 | ||
|
||
#![feature(async_await)] | ||
|
||
struct Xyz { | ||
a: u64, | ||
} | ||
|
||
trait Foo {} | ||
|
||
impl Xyz { | ||
async fn do_sth<'a>( | ||
&'a self, foo: &dyn Foo | ||
) -> &dyn Foo //~ ERROR lifetime mismatch | ||
{ | ||
foo | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0623]: lifetime mismatch | ||
--> $DIR/issue-63388-1.rs:14:10 | ||
| | ||
LL | &'a self, foo: &dyn Foo | ||
| -------- this parameter and the return type are declared with different lifetimes... | ||
LL | ) -> &dyn Foo | ||
| ^^^^^^^^ | ||
| | | ||
| ...but data from `foo` is returned here | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/issue-63388-2.rs:14:10 | ||
| | ||
LL | ) -> &dyn Foo | ||
| ^ help: consider using the named lifetime: `&'a` | ||
| | ||
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `foo` or `bar` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0106`. |
Oops, something went wrong.