1 // Regression test for #30225, which was an ICE that would trigger as
2 // a result of a poor interaction between trait result caching and
3 // type inference. Specifically, at that time, unification could cause
4 // unrelated type variables to become instantiated, if subtyping
5 // relationships existed. These relationships are now propagated
6 // through obligations and hence everything works out fine.
8 trait Foo<U,V> : Sized {
9 fn foo(self, u: Option<U>, v: Option<V>) {}
15 impl Foo<A, B> for () {} // impl A
16 impl Foo<u32, u32> for u32 {} // impl B, creating ambiguity
19 // cache the resolution <() as Foo<$0,$1>> = impl A
26 let mut u = None; // type is Option<$0>
27 let mut v = None; // type is Option<$1>
28 let mut x = None; // type is Option<$2>
30 Foo::foo(x.unwrap(),u,v); // register <$2 as Foo<$0, $1>>
31 u = v; // mark $0 and $1 in a subtype relationship
32 //~^ ERROR mismatched types
33 x = Some(()); // set $2 = (), allowing impl selection
34 // to proceed for <() as Foo<$0, $1>> = impl A.
35 // kaboom, this *used* to trigge an ICE