//@ compile-flags: -Znext-solver //@ check-pass // A regression test for trait-system-refactor-initiative#161 trait Constrain { type Assoc; } impl Constrain for () { type Assoc = (); } struct Foo>::Assoc>(T, U); impl Foo { fn foo() {} } struct B; impl Foo { fn foo() {} } type Alias = Foo; fn via_guidance() where (): Constrain, { // Method selection on `Foo>::Assoc>` is ambiguous. // only by unnecessarily constraining `?t` to `T` when proving `(): Constrain` // are we able to select the first impl. // // This happens in the old solver when normalizing `Alias`. The new solver doesn't try // to eagerly normalize `<() as Constrain>::Assoc` so we instead always prove that the // self type is well-formed before method lookup. Alias::foo(); } fn main() { via_guidance::<()>(); }