Skip to content

[incremental] Isolate the "used trait imports" part of typeck tables into a distinct query #45214

Closed
@nikomatsakis

Description

@nikomatsakis

As part of #45208, one place where typeck_tables_of is used that cannot easily be removed is this call from check_unused. What this code is doing is aggregating the set of trait imports that are used by all the function bodies in the crate. Due to glob imports and the like, it is hard to isolate which function body may make use of which trait import. Also, this information is only available from type-checking. So this will require serializing some amount of incremental data in between sessions. But since we don't want to save all of the typeck data, we can at least minimize the amount of data.

The idea is to introduce a new intermediate query used_trait_imports(D) for some def-id D. It will have the return type Rc<DefIdSet> and will return the used_trait_imports field from typeck_tables_of(D).

The steps are as follows:

  • Change the type of used_trait_imports to be Rc<DefIdSet> so it can be cheaply cloned. Make the code compiled.
  • Introduce the used_trait_imports query as defined above; it should return tcx.typeck_tables_of(key).used_trait_imports.clone().
  • Modify these lines to use your new query instead of typeck_tables_of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-incr-compWorking group: Incremental compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions