// compile-flags: -Ztrait-solver=next // check-pass // A minimization of an ambiguity when using typenum. See // https://github.com/rust-lang/trait-system-refactor-initiative/issues/55 // for more details. trait Id { type Assoc: ?Sized; } impl Id for T { type Assoc = T; } trait WithAssoc { type Assoc: ?Sized; } struct Leaf; struct Wrapper(U); impl WithAssoc for Leaf { type Assoc = U; } impl WithAssoc> for Wrapper
    where Ul: WithAssoc, { type Assoc = <
      >::Assoc as Id>::Assoc; } fn bound() where T: WithAssoc, { } // normalize self type to `Wrapper` // This succeeds, HOWEVER, instantiating the query response previously // incremented the universe index counter. // equate impl headers: // as WithAssoc< as Id>::Assoc>> // as WithAssoc>> // ~> AliasRelate( as Id>::Assoc, Equate, Wrapper) // add where bounds: // ~> Leaf: WithAssoc // equate with assoc type: // ?0t // >::Assoc as Id>::Assoc // ~> AliasRelate( // <>::Assoc as Id>::Assoc, // Equate, // <>::Assoc as Id>::Assoc, // ) // // We do not reuse `?3t` during generalization because `?0t` cannot name `?4t` as we created // it after incrementing the universe index while normalizing the self type. // // evaluate_added_goals_and_make_query_response: // AliasRelate( as Id>::Assoc, Equate, Wrapper) // YES, constrains ?3t to Leaf // AliasRelate( // <>::Assoc as Id>::Assoc, // Equate, // <>::Assoc as Id>::Assoc, // ) // // Normalizing <>::Assoc as Id>::Assoc then *correctly* // results in ambiguity. fn main() { bound::< as Id>::Assoc, as Id>::Assoc, _>() }