//@ check-pass //@ edition: 2021 // Make sure that we infer the args of an async closure even if it's passed to // a function that requires the async closure implement `Fn*` but does *not* have // a `Future` bound on the return type. #![feature(async_closure)] use std::future::Future; trait TryStream { type Ok; type Err; } trait TryFuture { type Ok; type Err; } impl TryFuture for F where F: Future> { type Ok = T; type Err = E; } trait TryStreamExt: TryStream { fn try_for_each(&self, f: F) where F: FnMut(Self::Ok) -> Fut, Fut: TryFuture; } impl TryStreamExt for S where S: TryStream { fn try_for_each(&self, f: F) where F: FnMut(Self::Ok) -> Fut, Fut: TryFuture, { } } fn test(stream: impl TryStream) { stream.try_for_each(async |s| { s.trim(); // Make sure we know the type of `s` at this point. Ok(()) }); } fn main() {}