// Test for #120760, which causes an ice bug: no index for a field // //@ compile-flags: -Z threads=45 //@ edition: 2021 //@ compare-output-by-lines type BoxFuture = std::pin::Pin>>; fn main() { let _ = f(); } async fn f() { run("dependency").await; //~ ERROR cannot find function `run` in this scope } struct InMemoryStorage; pub struct User<'dep> { pub name: &'a str, //~ ERROR use of undeclared lifetime name `'a` } 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, ::Error>>; } pub struct SaveUser<'a> { pub 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, { let _ = run("dependency").await; //~ ERROR cannot find function `run` in this scope } } async fn execute(dep: &str) where S: Storage, for<'a> SaveUser<'a>: StorageRequest, { User { dep }.save().await; //~ ERROR struct `User<'_>` has no field named `dep` }