//@ check-pass //@ compile-flags: -Znext-solver // A regression test for trait-system-refactor-initiative#184. // // When adding nested goals we replace aliases with infer vars // and add `AliasRelate` goals to constrain them. When doing this // for `NormalizesTo` goals, we then first tries to prove the // `NormalizesTo` goal and then normalized the nested aliases. trait Trait { type Assoc; } impl Trait for T { type Assoc = (); } trait Id { type This; } impl Id for T { type This = T; } trait Relate { type Alias; } impl Relate for T { type Alias = ::This>>::Assoc; } fn guide_me>() { // Normalizing `>::Alias` relates the associated type with an unconstrained // term. This resulted in a `NormalizesTo(::This>>::Assoc, ?x)` goal. // We replace `::This` with an infer var `?y`, resulting in the following goals: // - `NormalizesTo(::Assoc, ?x)` // - `AliasRelate(::This, ?y)` // // When proving the `NormalizesTo` goal first, we incompletely constrain `?y` to `u32`, // causing an unexpected type mismatch. let _: >::Alias; } fn main() {}