Closed
Description
This code ICEs:
trait Foo<'a> {
type Assoc;
}
impl<T> Foo<'_> for T {
type Assoc = T;
}
fn foo<'b: 'b, T: for<'a> Foo<'a>, F: for<'a> Fn(<T as Foo<'a>>::Assoc)>(_: F) -> (T, F) {
todo!()
}
fn main() {
let (x, c): (i32, _) = foo::<'static, _, _>(|_| {});
}
We create a very sneaky closure type that has the signature of for<'a> fn(<i32 as Foo<'a>>::Assoc)
. Note that this type is not normalized, because of higher-ranked normalization problems w/ the old trait solver.
We then store this type into c
in the let
statement, and because it's a pattern, we end up storing a user type annotation that links it to the field ascription. Since it's a pattern with a single field place elem, we end up normalizing the closure type here:
note that this is a full normalization in the old solver.
We then try to relate the unnormalized and normalized closure signatures, which fails in the old solver.