Skip to content

FIXME: ObligationForest assumptions incorrect #32286

Closed
@nikomatsakis

Description

@nikomatsakis

There are two assumptions I made in the Obligation Forest PR that I think may have been incorrect.

One. OF assumes that if selection results in ambiguity the inference context did not change. But, in working on #31867, @soltanmm reminded me that this is not always true, due to the "unify despite ambiguity" code.

Two. The stalled_on code assumes that the type of a variable will change if any progress can be made. I found this to be true even for closures -- because closures embed the types of their upvars. But this is not always true. That is, for closures with no upvars, when we select a closure kind (fn vs fnonce etc), the type doesn't change at all. This became an issue in the projection cache. I was not able however to make a test case that causes a problem with for the OF, but it seems likely to be a problem eventually.

Ultimately I expect the right fix for problem two is to expose the Closure Kind as part of the closure type, so that indeed the fully resolved type always changes. It seems very convenient to be able to use the fully resolved type as a cache key and not fear silent background changes.

The fix for problem one is just to refactor a bit I think to expose that information better. The only effect it has is when the OF will decide it has reached a fix point and stop trying to call select.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions