Skip to content

Remove QueryDispatcher#152215

Closed
nnethercote wants to merge 7 commits intorust-lang:mainfrom
nnethercote:start-cutting-down-rustc_query_system-AND-more
Closed

Remove QueryDispatcher#152215
nnethercote wants to merge 7 commits intorust-lang:mainfrom
nnethercote:start-cutting-down-rustc_query_system-AND-more

Conversation

@nnethercote
Copy link
Contributor

r? @ghost

That's the only place it's used, so it no longer needs to be `pub`.
Instead of writing it by hand.
…umbing`.

We are in the process of eliminating `rustc_query_system`. Chunks of it
are unused by `rustc_middle`, and so can be moved into
`rustc_query_info`. This commit does some of that.

Mostly it's just moving code from one file to another. There are a
couple of non-trivial changes.

- `QueryState` and `ActiveKeyStatus` must remain in `rustc_query_system`
  because they are used by `rustc_middle`. But their inherent methods
  are not used by `rustc_middle`. So these methods are moved and
  converted to free functions.

- The visibility of some things must increase. This includes `DepGraphData`
  and some of its methods, which are now used in `rustc_query_impl`.
  This is a bit annoying but seems hard to avoid.

What little is left behind in
`compiler/rustc_query_system/src/query/plumbing.rs` will be able to
moved into `rustc_query_impl` or `rustc_middle` in the future.
The previous commit moved some code from `rustc_query_system`, which
doesn't have access to `TyCtxt` and `QueryCtxt`, to `rustc_query_impl`,
which does. We can now remove quite a bit of indirection.

- Three methods in `trait QueryContext` are no longer needed
  (`next_job_id`, `current_query_job`, `start_query`). As a result,
  `QueryCtxt`'s trait impls of these methods are changed to inherent
  methods.

- `qcx: Q::Qcx` parameters are simplified to `qcx: QueryCtxt<'tcx>`.

- `*qcx.dep_context()` occurrences are simplified to `qcx.tcx`, and
  things like `qcx.dep_context().profiler()` become `qcx.tcx.prof`.

- `DepGraphData<<Q::Qcx as HasDepContext>::Deps>` becomes
  `DepGraphData<DepsType>`.

In short, various layers of indirection and abstraction are cut away.
The resulting code is simpler, more concrete, and easier to understand.
It's a good demonstration of the benefits of eliminating
`rustc_query_system`, and there will be more to come.
@rustbot rustbot added 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. labels Feb 6, 2026
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 6, 2026
…stem-AND-more, r=<try>

Remove `QueryDispatcher`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 6, 2026
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
checking C++ file formatting
spellchecking files
building external tool typos from package typos-cli@1.38.1
finished building tool typos
error: `necesssary` should be `necessary`
    ╭▸ compiler/rustc_query_impl/src/plumbing.rs:525:47
    │
525 │     C: QueryCache + 'tcx, // njn: +'tcx still necesssary?
    ╰╴                                              ━━━━━━━━━━
rerun tidy with `--extra-checks=spellcheck --bless` to fix typos
tidy [extra_checks]: checks with external tool 'typos' failed
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1365:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:02:29
  local time: Fri Feb  6 12:04:48 UTC 2026
  network time: Fri, 06 Feb 2026 12:04:48 GMT
##[error]Process completed with exit code 1.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 6, 2026

☀️ Try build successful (CI)
Build commit: 3e0cbd6 (3e0cbd6341ce1a73edd0ea2996ff280b15bfb2c0, parent: cf16cd9b751f6e13caec393cef4f6f67de2f3da8)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3e0cbd6): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.1%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-4.3%, -4.3%] 1
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Cycles

Results (primary 2.0%, secondary 5.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
5.2% [2.0%, 8.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

Results (primary 0.0%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 4
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 4

Bootstrap: 474.937s -> 475.111s (0.04%)
Artifact size: 397.89 MiB -> 397.95 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 6, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 8, 2026

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

@nnethercote nnethercote closed this Feb 9, 2026
@nnethercote nnethercote deleted the start-cutting-down-rustc_query_system-AND-more branch February 9, 2026 02:43
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 9, 2026
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) 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.

4 participants