# Async fn in trait: Static tests checklist Note: Some of these are now added to https://github.com/rust-lang/rust/pull/102642 * [x] These tests: https://hackmd.io/SwRcXCiWQV-WRJ4BYs53fA * [ ] Test that you can't "name" the associated type * [ ] e.g., `Foo::next` doesn't expose the return type of next * [ ] Recursion * [x] async function in trait that tries to call itself should not ICE or do something horrific * [x] What happens if your function is generic over your trait? (Error at call site if it's the same type) (bryangarza: I added a generic recursion case to my PR but not sure about in what case it should error) * [ ] Should work if it's a different type * [x] Calls to async functions in traits generic over types should work * [ ] Model the `AsyncIterator` case and successfully invoke `while let x = iter.next().await { ... }` * [x] In an impl, write a desugared version returning `-> impl Future` * [ ] Do we expect this to work? Should it require `#[refine]`? Can code rely on this? (bryangarza: it seemed to work okay without `#[refine]`) * [x] In an impl, write a desugared version returning `Box<dyn Future>` * [ ] In an impl, write a desugared version returning "some custom future" * [x] In the trait write `-> Box<dyn Future>` but in impl use `async fn` * [x] In the trait write `-> impl Future` but in impl use `async fn` * [ ] Write a test that wraps to make a dyn object, to show it's possible * [x] Call the async function from outside of an async context * [x] Call the async function from inside a async block inside a normal/async function * [ ] Call the async function inside a closure that creates an async block etc etc * [ ] Interactions with HRTB: async fn inside a trait that has `'a` and where caller has `for<'a>`? * [ ] Interactions with GATs: async fn that returns a GAT * [ ] Interactions with GATs: async fn that takes a GAT as argument * [ ] Async functions in generic traits * [ ] Async functions that take `impl Trait` arguments * [ ] Async functions that use `impl Trait` in where clauses (error) `async fn foo<T>() where T: PartialEq<impl Blah>` * [ ] Async functions that use `impl Trait` in assoc types (error) `async fn foo<T>() where T: Iterator<Item = impl Blah>` ?? * [ ] Check returned futures hold borrow on self (e.g., `async fn foo(ai: &mut impl AsyncIterator) { let x = ai.next(); let y = ai.next(); drop(x); drop(y); }` should not compile), and perhaps other arguments * [ ] Inheriting correct generics, capturing correct lifetimes * [ ] Allowed to hold non-'static argument across an await * [ ] Not allowed to hold returned future past the lifetime of an argument * [ ] Plus RPITIT * [ ] Returning (impl Trait, impl Trait) * [ ] (can caller observe its a tuple?) * [ ] Async functions returning impl Traits