Description
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.