Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nikomatsakis opened this issue Oct 11, 2017 · 2 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 11, 2017

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.
@nikomatsakis nikomatsakis added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation labels Oct 11, 2017
@cjkenn
Copy link
Contributor

cjkenn commented Oct 12, 2017

I think I'd like to take this on! Would be my first contribution to rust but you've laid the steps out pretty clearly and provided a lot of context so I think I would be able to work on it

@TimNN TimNN added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Oct 17, 2017
bors added a commit that referenced this issue Oct 24, 2017
Put used trait imports field into a distinct query

Implementation for #45214

r+ @nikomatsakis
@wesleywiser
Copy link
Member

I think this issue can be closed now.

@arielb1 arielb1 closed this as completed Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation
Projects
None yet
Development

No branches or pull requests

5 participants