Description
We currently incompletely prefer where-bounds over impls when proving trait goals and while normalizing. This causes multiple issues, so we discussed not applying this guidance immediately but returning them to the caller. At this point guidance would only be applied in the root, e.g. by the FnCtxt
.
issues solved/improved by avoiding eager guidance
- eagerly proving nested goals + incompleteness -> breakage #97
- higher-ranked goals in trait goal candidate selection #120
text
Returning guidance only works for inference variables from the input, as they have to be constrained by the caller. This means that guidance when normalizing is incredibly hard to solve.
Imagine we have <Vec<T> as Trait>::Assoc eq <Vec<U> as Trait>::Assoc
with where-bounds normalizing the associated types to u32
and an impl normalizing to T/U
.
Then normalizing <Vec<T> as Trait>::Assoc to ?infer
would result in ambiguity with guidance constraining ?infer
to u32
. The actual inference variables remain fully unconstrained however, allowing us to equate them. There's no way we can return this guidance from the alias-relate goal to allow the root to optionally apply it as the root cannot name the unconstrained inference variables created for normalization.