6 //~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
8 use std::future::Future;
10 async fn foo(f: dyn* Future<Output = i32>) {
11 println!("value: {}", f.await);
14 async fn async_main() {
15 foo(Box::pin(async { 1 })).await
18 // ------------------------------------------------------------------------- //
19 // Implementation Details Below...
24 pub fn noop_waker() -> Waker {
25 let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);
27 // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
28 unsafe { Waker::from_raw(raw) }
31 const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
33 unsafe fn noop_clone(_p: *const ()) -> RawWaker {
34 RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
37 unsafe fn noop(_p: *const ()) {}
40 let mut fut = async_main();
42 // Poll loop, just to test the future...
43 let waker = noop_waker();
44 let ctx = &mut Context::from_waker(&waker);
47 match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
49 Poll::Ready(()) => break,