Using a returned `impl Trait` for a trait with an associated type and not specifying the associated type leads to the following error: ``` error[E0700]: hidden type for `impl Trait + 'static` captures lifetime that does not appear in bounds ``` ..even when `+ 'static` is specified, meaning no lifetimes should be captured. Adding `#![feature(associated_type_bounds)]` and instead using `impl Trait<AssocType: 'static>` as a return type solves the issue. I'm not sure if this is intended behavior - it seems pretty strange since `AssocType` is defined with a `'static` bound. See the code below for a reproducible example. ```rust #![feature(associated_type_bounds)] trait Anything {} impl<T: ?Sized> Anything for T {} trait Thing { type Output: 'static; fn calc(&mut self) -> Self::Output; } impl<'a> Thing for &'a u8 { type Output = u8; fn calc(&mut self) -> u8 { **self } } // uncomment the bound to make it work fn get_thing(x: &u8) -> impl Thing /* <Output: 'static> */ + '_ { x } fn f(n: &u8) -> impl Anything + 'static { let mut t = get_thing(n); t.calc() } ``` ### Meta `rustc --version --verbose`: ``` rustc 1.67.0-nightly (c090c6880 2022-12-01) ```