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#59286 - cramertj:async-fn-ret-ty, r=varkor
Refactor async fn return type lowering async fn now lowers directly to an existential type declaration rather than reusing the `impl Trait` return type lowering. As part of this, it lowers all argument-position elided lifetimes using the in-band-lifetimes machinery, creating fresh parameter names for each of them, using each lifetime parameter as a generic argument to the generated existential type. This doesn't currently successfully allow multiple argument-position elided lifetimes since `existential type` doesn't yet support multiple lifetimes where neither outlive the other: ```rust existential type Foo<'a, 'b>:; // error: ambiguous lifetime bound in `impl Trait` fn foo<'a, 'b>(_: &'a u8, _: &'b u8) -> Foo<'a, 'b> { () } ``` This requires a separate fix. Fix rust-lang#59001 Fix rust-lang#58885 Fix rust-lang#55324 Fix rust-lang#54974 Progress on rust-lang#56238 r? @nikomatsakis
- Loading branch information
Showing
13 changed files
with
553 additions
and
336 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -1,32 +1,20 @@ | ||
error[E0709]: multiple different lifetimes used in arguments of `async fn` | ||
--> $DIR/async-fn-multiple-lifetimes.rs:7:47 | ||
error: ambiguous lifetime bound in `async fn` | ||
--> $DIR/async-fn-multiple-lifetimes.rs:7:65 | ||
| | ||
LL | async fn multiple_named_lifetimes<'a, 'b>(_: &'a u8, _: &'b u8) {} | ||
| ^^ ^^ different lifetime here | ||
| | | ||
| first lifetime here | ||
| ^ neither `'a` nor `'b` outlives the other | ||
| | ||
= help: `async fn` can only accept borrowed values with identical lifetimes | ||
= note: multiple unrelated lifetimes are not allowed in `async fn`. | ||
= note: if you're using argument-position elided lifetimes, consider switching to a single named lifetime. | ||
|
||
error[E0707]: multiple elided lifetimes used in arguments of `async fn` | ||
--> $DIR/async-fn-multiple-lifetimes.rs:16:39 | ||
error: ambiguous lifetime bound in `async fn` | ||
--> $DIR/async-fn-multiple-lifetimes.rs:16:52 | ||
| | ||
LL | async fn multiple_elided_lifetimes(_: &u8, _: &u8) {} | ||
| ^ ^ different lifetime here | ||
| | | ||
| first lifetime here | ||
| ^ the elided lifetimes here do not outlive one another | ||
| | ||
= help: consider giving these arguments named lifetimes | ||
= note: multiple unrelated lifetimes are not allowed in `async fn`. | ||
= note: if you're using argument-position elided lifetimes, consider switching to a single named lifetime. | ||
|
||
error[E0106]: missing lifetime specifier | ||
--> $DIR/async-fn-multiple-lifetimes.rs:16:39 | ||
| | ||
LL | async fn multiple_elided_lifetimes(_: &u8, _: &u8) {} | ||
| ^ expected lifetime parameter | ||
| | ||
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `_` or `_` | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0106, E0707, E0709. | ||
For more information about an error, try `rustc --explain E0106`. |
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,16 @@ | ||
// compile-pass | ||
// edition:2018 | ||
|
||
#![feature(async_await, await_macro, futures_api)] | ||
|
||
use std::sync::Arc; | ||
|
||
trait SomeTrait: Send + Sync + 'static { | ||
fn do_something(&self); | ||
} | ||
|
||
async fn my_task(obj: Arc<SomeTrait>) { | ||
unimplemented!() | ||
} | ||
|
||
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,14 @@ | ||
// compile-pass | ||
// edition:2018 | ||
|
||
#![feature(async_await, await_macro, futures_api)] | ||
|
||
use std::future::Future; | ||
|
||
#[allow(unused)] | ||
async fn foo<F: Future<Output = i32>>(x: &i32, future: F) -> i32 { | ||
let y = await!(future); | ||
*x + y | ||
} | ||
|
||
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,21 @@ | ||
// compile-pass | ||
// edition:2018 | ||
|
||
#![feature(async_await, await_macro, futures_api)] | ||
|
||
struct Xyz { | ||
a: u64, | ||
} | ||
|
||
trait Foo {} | ||
|
||
impl Xyz { | ||
async fn do_sth<'a>( | ||
&'a self, foo: &'a dyn Foo | ||
) -> bool | ||
{ | ||
true | ||
} | ||
} | ||
|
||
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,17 @@ | ||
// compile-pass | ||
// edition:2018 | ||
|
||
#![feature(async_await, await_macro, futures_api)] | ||
|
||
use std::future::Future; | ||
|
||
#[allow(unused)] | ||
async fn enter<'a, F, R>(mut callback: F) | ||
where | ||
F: FnMut(&'a mut i32) -> R, | ||
R: Future<Output = ()> + 'a, | ||
{ | ||
unimplemented!() | ||
} | ||
|
||
fn main() {} |