Skip to content

Resolve obligations more carefully #18391

Closed
@nikomatsakis

Description

@nikomatsakis

Resolving trait obligations can be an important part of type inference. However, right now we do it in a bit of an ad-hoc way:

  • Every once in a while, we eagerly resolve new obligations that haven't been attempted yet.
  • If we are looking at a type variable and need more type information, we do a full resolve of all obligations. This helps in some cases.

Probably we ought to avoid resolving obligations at all until we want more type information, and then we should do it only with obligations that will help with the variable in question. I am not sure if this is as simple as scanning for obligations that reference the variable somewhere -- I think not, we probably have to construct some kind of dependence graph. What can happen otherwise is something like:

$0 : Foo<$1>
$1 : Bar<$2>

To decide $2, we need to know $1, but to know $1, we have to resolve the first obligation.

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