- Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
The struct SelectionContext has an intercrate field. This field is only enabled during coherence checking, when we want to see if two impls overlap.
Unfortunately, this flag ends up 'infecting' a large amount of the trait selection / projection logic. In particular, InferCtxt is not aware of this flag, so we can end up caching a particular result (candidate, evaluation, or projection) in intercrate mode, and then using the cached result in non-intercrate mode.
The need for this flag may go away once we fully transition to Chalk. However, it might be worthwhile to investigate if it's possible to move (some of) the necessary logic out of SelectionContext, and into coherence checking. If we could make intercrate mode just record additional information (instead of actually altering the results of trait selection), we could safely re-use the same InferCtxt caches across different SelectionContexts.