Skip to content

candidate preference and guidance #129

Open
@lcnr

Description

@lcnr

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions