Skip to content

Remove QueryCtxt and trait HasDepContext#152704

Open
Zalathar wants to merge 3 commits intorust-lang:mainfrom
Zalathar:query-ctxt
Open

Remove QueryCtxt and trait HasDepContext#152704
Zalathar wants to merge 3 commits intorust-lang:mainfrom
Zalathar:query-ctxt

Conversation

@Zalathar
Copy link
Member


With the QueryContext trait removed, wrapper struct QueryCtxt no longer serves a purpose and can be replaced with TyCtxt everywhere.

After that, the only obstacle to removing trait HasDepContext is DepGraph::with_task, which uses the trait to allow passing both a TyCtxt and a query vtable through the context argument. But we can achieve the same result by passing the vtable through the other argument instead, in a tuple alongside the query key.

r? nnethercote

@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 Feb 16, 2026
self.assert_dep_node_not_yet_allocated_in_current_session(tcx.sess, &dep_node, || {
format!(
"forcing query with already existing `DepNode`\n\
- query-key: {task_arg:?}\n\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't just print the query key now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will print a tuple of (query_name, key), which seems fine.

// Delegate to another function to actually execute the query job.
let (result, dep_node_index) = if INCR {
execute_job_incr(query, qcx, qcx.tcx.dep_graph.data().unwrap(), key, dep_node, id)
execute_job_incr(query, tcx, tcx.dep_graph.data().unwrap(), key, dep_node, id)
Copy link
Contributor

@nnethercote nnethercote Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could now just pass in tcx and get the dep graph data later (in try_load_from_disk_and_cache_in_memory).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That duplicates the unwrap(), so DepGraphData is passed around to indicate incremental is enabled.

for SemiDynamicQueryDispatcher<'tcx, C, FLAGS>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.name())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This omits most of the data in the type. Worth a brief comment explaining why?

@nnethercote
Copy link
Contributor

r=me with the nits addressed, and merging should wait for #152703.

@nnethercote nnethercote 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 16, 2026
This struct was only wrapping `TyCtxt` in order to implement traits that
were removed by RUST-152636.
The need for a `HasDepContext` impl on tuples can be avoided by passing the
query vtable as part of an argument tuple instead.
@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@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)
29 files already formatted
checking C++ file formatting
spellchecking files
building external tool typos from package typos-cli@1.38.1
error: download of ty/po/typos-cli failed

Caused by:
  failed to download from `https://index.crates.io/ty/po/typos-cli`

Caused by:
  [28] Timeout was reached (Operation too slow. Less than 10 bytes/sec transferred the last 30 seconds)
rerun tidy with `--extra-checks=spellcheck --bless` to fix typos
tidy [extra_checks]: cargo install failed
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
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.
Build completed unsuccessfully in 0:03:35
  local time: Tue Feb 17 01:32:29 UTC 2026
  network time: Tue, 17 Feb 2026 01:32:29 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

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