5 //~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
7 use std::future::Future;
9 async fn foo(f: dyn* Future<Output = i32>) {
10 println!("value: {}", f.await);
13 async fn async_main() {
14 foo(Box::pin(async { 1 })).await
17 // ------------------------------------------------------------------------- //
18 // Implementation Details Below...
23 pub fn noop_waker() -> Waker {
24 let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);
26 // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
27 unsafe { Waker::from_raw(raw) }
30 const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
32 unsafe fn noop_clone(_p: *const ()) -> RawWaker {
33 RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
36 unsafe fn noop(_p: *const ()) {}
39 let mut fut = async_main();
41 // Poll loop, just to test the future...
42 let waker = noop_waker();
43 let ctx = &mut Context::from_waker(&waker);
46 match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
48 Poll::Ready(()) => break,