Skip to content

Conversation

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Jan 28, 2026

In #151203 I tried and failed to simplify QueryStackFrame. This is an alternative approach. There is no functional change, just tweaking of some names and types to make things clearer. Best reviewed one commit at a time.

r? @oli-obk

Instead of passing a closure that computes a hash and immediately
calling it, just compute the hash and pass the value.
It produces a `QueryStackFrameExtra`, so `stack_` should be in the name.
`QueryStackFrame<I>` is a generic type, and the `I` parameter leaks out
to many other related types. However, it only has two instantiations in
practice:
- `QueryStackFrame<QueryStackFrameExtra>`
- `QueryStackFrame<QueryStackDeferred<'tcx>>`

And most of the places that currently use `QueryStackFrame<I>` are
actually specific to one of the instantiations. This commit removes the
unneeded genericity.

The following types are only ever used with `QueryStackDeferred<'tcx>`:
- QueryMap
- QueryJobInfo
- QueryJob
- QueryWaiter
- QueryLatchInfo
- QueryLatch
- QueryState
- QueryResult
and their `<I>` parameter is changed to `<'tcx>`.

Also, the `QueryContext::QueryInfo` associated type is removed.

`CycleError<I>` and `QueryInfo<I>` are still generic over type, because
they are used with both instantiations.

This required also adding a `<'tcx>` parameter to the traits
`QueryConfig` and `QueryContext`, which is annoying but I can't see how
to avoid it.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 28, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 28, 2026

Yea this makes sense. Not much of an improvement, but lifetime generics are better than type generics for readability
@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 28, 2026

📌 Commit 2afcbf6 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2026
@Zalathar
Copy link
Member

Zalathar commented Jan 28, 2026

Be aware that this will textually conflict with some of the renames in #151666, though the changes should be compatible.

Also, after that PR I intend to change the generic type of QueryConfig (renamed to QueryDispatcher) to an associated type, so having the 'tcx will be a bit less annoying after that.

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 28, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 28, 2026

☔ The latest upstream changes (presumably #151778) made this pull request unmergeable. Please resolve the merge conflicts.

This pull request was unapproved.

@petrochenkov
Copy link
Contributor

petrochenkov commented Jan 28, 2026

The original implementation tried to avoid adding the 'tcx parameter everywhere, as I understand - #138672 (comment).
If it's added anyway, then perhaps my suggestion about using an enum or dyn trait from that comment can be implemented too.

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) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants