// ex-ice: #141761 //@ compile-flags: -Zlint-mir --crate-type lib //@ edition:2024 //@ check-pass #![feature(async_drop)] #![allow(incomplete_features)] type BoxFuture = std::pin::Pin>>; fn main() {} async fn f() { run("").await } struct InMemoryStorage; struct User<'dep> { dep: &'dep str, } impl<'a> StorageRequest for SaveUser<'a> { fn execute(&self) -> BoxFuture> { todo!() } } trait Storage { type Error; } impl Storage for InMemoryStorage { type Error = String; } trait StorageRequestReturnType { type Output; } trait StorageRequest: StorageRequestReturnType { fn execute(&self) -> BoxFuture::Output, S::Error>>; } struct SaveUser<'a> { name: &'a str, } impl<'a> StorageRequestReturnType for SaveUser<'a> { type Output = (); } impl<'dep> User<'dep> { async fn save(self) where S: Storage, for<'a> SaveUser<'a>: StorageRequest, { SaveUser { name: "" }.execute().await; } } async fn run(dep: &str) where S: Storage, for<'a> SaveUser<'a>: StorageRequest, { User { dep }.save().await }