rust/tests/ui/dyn-star/dispatch-on-pin-mut.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
822 B
Rust
Raw Permalink Normal View History

2022-11-23 20:36:46 -06:00
//@ run-pass
//@ edition:2021
2022-11-23 20:36:46 -06:00
//@ check-run-results
#![feature(dyn_star)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
2023-12-14 12:34:29 -06:00
#![feature(noop_waker)]
use std::future::Future;
async fn foo(f: dyn* Future<Output = i32>) {
println!("value: {}", f.await);
}
async fn async_main() {
foo(Box::pin(async { 1 })).await
}
// ------------------------------------------------------------------------- //
// Implementation Details Below...
2023-12-14 12:34:29 -06:00
use std::pin::pin;
use std::task::*;
fn main() {
2023-12-14 12:34:29 -06:00
let mut fut = pin!(async_main());
// Poll loop, just to test the future...
let ctx = &mut Context::from_waker(Waker::noop());
loop {
2023-12-14 12:34:29 -06:00
match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(()) => break,
}
}
}