Skip to content

Clean up handling of SelectionContext 'intercrate' mode #89128

@Aaron1011

Description

@Aaron1011

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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