// edition: 2021 use std::{ future::Future, pin::Pin, task::{Context, Poll, Waker}, }; pub struct StructAsync Pin>>> { pub callback: F, } impl Future for StructAsync where F: Fn() -> Pin>>, { type Output = (); fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { Poll::Pending } } async fn callback() {} struct Runtime; fn waker() -> &'static Waker { todo!() } impl Runtime { #[track_caller] pub fn block_on(&self, mut future: F) -> F::Output { loop { unsafe { Pin::new_unchecked(&mut future).poll(&mut Context::from_waker(waker())); } } } } fn main() { Runtime.block_on(async { StructAsync { callback }.await; //~^ ERROR expected `fn() -> impl Future {callback}` to be a fn item that returns `Pin>>`, but it returns `impl Future` //~| ERROR expected `fn() -> impl Future {callback}` to be a fn item that returns `Pin>>`, but it returns `impl Future` //~| ERROR expected `fn() -> impl Future {callback}` to be a fn item that returns `Pin>>`, but it returns `impl Future` }); }