diff options
Diffstat (limited to 'src/test/ui/async-await/await-into-future.rs')
| -rw-r--r-- | src/test/ui/async-await/await-into-future.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/async-await/await-into-future.rs b/src/test/ui/async-await/await-into-future.rs new file mode 100644 index 00000000000..b74b1684440 --- /dev/null +++ b/src/test/ui/async-await/await-into-future.rs @@ -0,0 +1,30 @@ +// run-pass +// aux-build: issue-72470-lib.rs +// edition:2021 +#![feature(into_future)] + +extern crate issue_72470_lib; +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() { + issue_72470_lib::run(run()); +} |
