Skip to content

Make traits_in_crate and impls_in_crate proper queries and use them #95092

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

Open
4 tasks
cjgillot opened this issue Mar 18, 2022 · 4 comments
Open
4 tasks

Make traits_in_crate and impls_in_crate proper queries and use them #95092

cjgillot opened this issue Mar 18, 2022 · 4 comments
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. 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.

Comments

@cjgillot
Copy link
Contributor

cjgillot commented Mar 18, 2022

We currently compute a list of all traits and all impls in a crate for metadata.
traits_in_crate is a query, and sorts all definitions by DefPathHash.
impls_in_crate is not a query, and sorts definitions by DefPathHash.

This PR suggests to:

  • shift the sorting of traits_in_crate from the query to metadata encoding;
  • use traits_in_crate for all analyses that iterate on traits;
  • make impls_in_crate a query, keeping the sorting outside of the query in metadata encoding;
  • use impls_in_crate for analyses that iterate on impls, like coherence.

The effect of the sorting on the definitions by DefPathHash is not obvious. The effect of sorting vs not sorting will need to investigated with respect to soundness of the crate_hash.

This issue may conflict with #94878, #95004 and #95082.

I am available on Zulip for further information.

@cjgillot cjgillot added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Mar 18, 2022
@petrochenkov
Copy link
Contributor

I'm not even sure traits_in_crate is necessary.

It's quite likely that we don't need the list of "all traits", but rather the list of "all traits with impls", in that case it can be extracted from impls_in_crate. This just needs some investigation and confirmation.

@spastorino spastorino self-assigned this Mar 21, 2022
@Robert-Cunningham
Copy link

@rustbot claim

@Robert-Cunningham
Copy link

After investigating, I suspect that traits_in_crate it is necessary; even if we have a trait without an impl, it seems to me that we need to know about it to generate docs for it.

Let me know if there's something here I'm missing.

@Enselic Enselic added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 3, 2023
@Enselic Enselic added the A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) label Nov 12, 2024
@mzacho
Copy link
Contributor

mzacho commented Jan 14, 2025

@cjgillot is this still an issue? traits_in_crate and impls_in_crate both seem to have vanished from the code, and the queries

https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/query/mod.rs#L2147
https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/query/mod.rs#L2152

seem to do the job of collecting traits and impls in a crate.

Otherwise, if you'd update the description I can take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. 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.
Projects
None yet
Development

No branches or pull requests

6 participants