rust/tests/ui/dyn-star/dispatch-on-pin-mut.rs
Kevin Reid c48cdfe8ee Remove unnecessary lets and borrowing from Waker::noop() usage.
`Waker::noop()` now returns a `&'static Waker` reference, so it can be
passed directly to `Context` creation with no temporary lifetime issue.
2024-01-17 12:00:27 -08:00

38 lines
819 B
Rust

// run-pass
// edition:2021
// 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
#![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...
use std::pin::pin;
use std::task::*;
fn main() {
let mut fut = pin!(async_main());
// Poll loop, just to test the future...
let ctx = &mut Context::from_waker(Waker::noop());
loop {
match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(()) => break,
}
}
}