//@check-pass use higher_kinded_types::*; mod higher_kinded_types { pub(crate) trait HKT { type Of<'lt>; } pub(crate) trait WithLifetime<'lt> { type T; } impl WithLifetime<'any>> HKT for T { type Of<'lt> = >::T; } } trait Trait { type Gat<'lt>; } impl Trait for () { type Gat<'lt> = (); } /// Same as `Trait`, but using HKTs rather than GATs trait HTrait { type Hat: ?Sized + HKT; } impl HTrait for T { type Hat = dyn for<'lt> WithLifetime<'lt, T = T::Gat<'lt>>; } impl Trait for Box> { type Gat<'lt> = Hat::Of<'lt>; } fn existential() -> impl for<'a> Trait = ()> {} fn dyn_hoops( _: T, ) -> Box WithLifetime<'a, T = T::Gat<'a>>>> { loop {} } fn main() { let _ = || -> _ { dyn_hoops(existential()) }; }