Reintroduce into_future in .await desugaring
This is a reintroduction of the remaining parts from https://github.com/rust-lang/rust/pull/65244 that have not been relanded yet. Issues GH-67644, GH-67982
This commit is contained in:
parent
936f2600b6
commit
dfa0db5961
9 changed files with 91 additions and 9 deletions
|
|
@ -112,7 +112,7 @@ async fn mixed_sizes() {
|
|||
fn main() {
|
||||
assert_eq!(1025, std::mem::size_of_val(&single()));
|
||||
assert_eq!(1026, std::mem::size_of_val(&single_with_noop()));
|
||||
assert_eq!(3078, std::mem::size_of_val(&joined()));
|
||||
assert_eq!(3079, std::mem::size_of_val(&joined_with_noop()));
|
||||
assert_eq!(7181, std::mem::size_of_val(&mixed_sizes()));
|
||||
assert_eq!(3076, std::mem::size_of_val(&joined()));
|
||||
assert_eq!(3076, std::mem::size_of_val(&joined_with_noop()));
|
||||
assert_eq!(6157, std::mem::size_of_val(&mixed_sizes()));
|
||||
}
|
||||
|
|
|
|||
28
src/test/ui/async-await/await-into-future.rs
Normal file
28
src/test/ui/async-await/await-into-future.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// check-pass
|
||||
|
||||
// edition:2021
|
||||
|
||||
#![feature(into_future)]
|
||||
|
||||
use std::{future::{Future, IntoFuture}, pin::Pin};
|
||||
|
||||
struct AwaitMe;
|
||||
|
||||
impl IntoFuture for AwaitMe {
|
||||
type Output = i32;
|
||||
type Future = Pin<Box<dyn Future<Output = i32>>>;
|
||||
|
||||
fn into_future(self) -> Self::Future {
|
||||
Box::pin(me())
|
||||
}
|
||||
}
|
||||
|
||||
async fn me() -> i32 {
|
||||
41
|
||||
}
|
||||
|
||||
async fn run() {
|
||||
assert_eq!(AwaitMe.await, 41);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -10,12 +10,20 @@ async fn foo() {
|
|||
//~^ ERROR type inside `async fn` body must be known in this context
|
||||
//~| ERROR type inside `async fn` body must be known in this context
|
||||
//~| ERROR type inside `async fn` body must be known in this context
|
||||
//~| ERROR type inside `async fn` body must be known in this context
|
||||
//~| ERROR type inside `async fn` body must be known in this context
|
||||
//~| NOTE cannot infer type for type parameter `T`
|
||||
//~| NOTE cannot infer type for type parameter `T`
|
||||
//~| NOTE cannot infer type for type parameter `T`
|
||||
//~| NOTE cannot infer type for type parameter `T`
|
||||
//~| NOTE cannot infer type for type parameter `T`
|
||||
//~| NOTE the type is part of the `async fn` body because of this `await`
|
||||
//~| NOTE the type is part of the `async fn` body because of this `await`
|
||||
//~| NOTE the type is part of the `async fn` body because of this `await`
|
||||
//~| NOTE the type is part of the `async fn` body because of this `await`
|
||||
//~| NOTE the type is part of the `async fn` body because of this `await`
|
||||
//~| NOTE in this expansion of desugaring of `await`
|
||||
//~| NOTE in this expansion of desugaring of `await`
|
||||
//~| NOTE in this expansion of desugaring of `await`
|
||||
//~| NOTE in this expansion of desugaring of `await`
|
||||
//~| NOTE in this expansion of desugaring of `await`
|
||||
|
|
|
|||
|
|
@ -34,6 +34,30 @@ note: the type is part of the `async fn` body because of this `await`
|
|||
LL | bar().await;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0698]: type inside `async fn` body must be known in this context
|
||||
--> $DIR/unresolved_type_param.rs:9:5
|
||||
|
|
||||
LL | bar().await;
|
||||
| ^^^ cannot infer type for type parameter `T` declared on the function `bar`
|
||||
|
|
||||
note: the type is part of the `async fn` body because of this `await`
|
||||
--> $DIR/unresolved_type_param.rs:9:5
|
||||
|
|
||||
LL | bar().await;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error[E0698]: type inside `async fn` body must be known in this context
|
||||
--> $DIR/unresolved_type_param.rs:9:5
|
||||
|
|
||||
LL | bar().await;
|
||||
| ^^^ cannot infer type for type parameter `T` declared on the function `bar`
|
||||
|
|
||||
note: the type is part of the `async fn` body because of this `await`
|
||||
--> $DIR/unresolved_type_param.rs:9:5
|
||||
|
|
||||
LL | bar().await;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0698`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue