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

Use DepKind instead of &'static str in QueryStackFrame #105168

Closed
Noratrieb opened this issue Dec 2, 2022 · 2 comments · Fixed by #105550
Closed

Use DepKind instead of &'static str in QueryStackFrame #105168

Noratrieb opened this issue Dec 2, 2022 · 2 comments · Fixed by #105550
Assignees
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Dec 2, 2022

In the Value impl for FnSig, we compare against the name of the query in the query stack frame. This is suboptimal because it will break if the query name is changed. To guard against this, we should instead do a comparison against the DepNode (an enum of all queries). This isn't possible yet because the DepKind isn't part of the query frame but it should be. We do have it available where we create the QueryStackFrame.

We can then replace the name: &'static str with a dep_kind: DepKind, but this does require us to add a generic parameter for the dep kind to QueryStackFrame and all of the places its used. We can also use type aliases in rustc_middle to make this not too bad. (Look at the existing types using DepKind to get an example of how to do it). With that we may need a fn as_str(&self) -> &str function (or Debug impl) on DepKind in places where the name is printed which should be easy to add with stringify!() where it's generated. This way we could get rid of the string comparison here and maybe also improve things in other places.

Originally posted by @Nilstrieb in #105162 (comment)

@Noratrieb
Copy link
Member Author

@rustbot label +A-query-system +E-easy +E-mentor

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Dec 2, 2022
@gimbling-away
Copy link
Contributor

@rustbot claim

@bors bors closed this as completed in c2ff8ad Dec 23, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
Use `DepKind` instead of `&'static str` in `QueryStackFrame`

`@rustbot` author

Fixes rust-lang#105168
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-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants