trait Trait<'a> {
type Assoc;
}
struct Wrapper<T>(T);
impl<'a, T: Trait<'a>> Trait<'a> for Wrapper<T> {
type Assoc = <T as Trait<'a>>::Assoc;
}
fn foo<T: for<'a> Trait<'a>>() -> for<'a> fn(<T as Trait<'a>>::Assoc) {
todo!()
}
fn bar<T: for<'a> Trait<'a>>() {
let _: for<'a> fn(<_ as Trait<'a>>::Assoc) = foo::<T>();
}
This compiles on stable by constraining for<'a> fn(<_ as Trait<'a>>::Assoc) to for<'a> fn(<T as Trait<'a>>::Assoc) because we simply relate the substs of projections which we cannot normalize (and which are inside of binders, as we otherwise replace them with inference vars).
This inference behavior will change with the new solver which may break stable code.
This compiles on stable by constraining
for<'a> fn(<_ as Trait<'a>>::Assoc)
tofor<'a> fn(<T as Trait<'a>>::Assoc)
because we simply relate the substs of projections which we cannot normalize (and which are inside of binders, as we otherwise replace them with inference vars).This inference behavior will change with the new solver which may break stable code.