From d08f97d739ab999d486d318f81efa4987ee82e4c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 3 Mar 2026 14:17:06 +1100 Subject: [PATCH] Remove `QueryVTable::construct_dep_node`. It's just a wrapper for `DepNode::construct` and it only has three uses. Better to just have one way of doing things. --- compiler/rustc_middle/src/query/plumbing.rs | 8 +------- compiler/rustc_query_impl/src/execution.rs | 8 +++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 65078a2a68b6..6193de8f77e4 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -11,7 +11,7 @@ use rustc_span::{ErrorGuaranteed, Span}; pub use sealed::IntoQueryParam; -use crate::dep_graph::{DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex}; +use crate::dep_graph::{DepKind, DepNodeIndex, SerializedDepNodeIndex}; use crate::ich::StableHashingContext; use crate::queries::{ExternProviders, Providers, QueryArenas, QueryVTables}; use crate::query::on_disk_cache::OnDiskCache; @@ -180,12 +180,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> { - pub fn construct_dep_node(&self, tcx: TyCtxt<'tcx>, key: &C::Key) -> DepNode { - DepNode::construct(tcx, self.dep_kind, key) - } -} - pub struct QuerySystem<'tcx> { pub arenas: WorkerLocal>, pub query_vtables: QueryVTables<'tcx>, diff --git a/compiler/rustc_query_impl/src/execution.rs b/compiler/rustc_query_impl/src/execution.rs index 5336b22514f2..3dfc3ca2ed3c 100644 --- a/compiler/rustc_query_impl/src/execution.rs +++ b/compiler/rustc_query_impl/src/execution.rs @@ -453,7 +453,8 @@ fn execute_job_incr<'tcx, C: QueryCache>( if !query.anon && !query.eval_always { // `to_dep_node` is expensive for some `DepKind`s. - let dep_node = dep_node_opt.get_or_insert_with(|| query.construct_dep_node(tcx, &key)); + let dep_node = + dep_node_opt.get_or_insert_with(|| DepNode::construct(tcx, query.dep_kind, &key)); // The diagnostics for this query will be promoted to the current session during // `try_mark_green()`, so we can ignore them here. @@ -485,7 +486,8 @@ fn execute_job_incr<'tcx, C: QueryCache>( } // `to_dep_node` is expensive for some `DepKind`s. - let dep_node = dep_node_opt.unwrap_or_else(|| query.construct_dep_node(tcx, &key)); + let dep_node = + dep_node_opt.unwrap_or_else(|| DepNode::construct(tcx, query.dep_kind, &key)); // Call the query provider. dep_graph_data.with_task( @@ -629,7 +631,7 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>( // Ensuring an anonymous query makes no sense assert!(!query.anon); - let dep_node = query.construct_dep_node(tcx, key); + let dep_node = DepNode::construct(tcx, query.dep_kind, key); let dep_graph = &tcx.dep_graph; let serialized_dep_node_index = match dep_graph.try_mark_green(tcx, &dep_node) {