Skip to content

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

Closed
@Noratrieb

Description

@Noratrieb

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-query-systemArea: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions