From 414be2e6ff398dd67aea1f6fffb1d335a23322bd Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 12 Feb 2026 10:35:23 +1100 Subject: [PATCH] Remove `Deps`. It's no longer needed. --- compiler/rustc_middle/src/dep_graph/graph.rs | 14 ++--- compiler/rustc_middle/src/dep_graph/mod.rs | 54 +++++-------------- .../rustc_middle/src/dep_graph/serialized.rs | 2 +- compiler/rustc_query_impl/src/plumbing.rs | 5 +- 4 files changed, 24 insertions(+), 51 deletions(-) diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs index 0ee1ee44fd1c..5d3d09ded212 100644 --- a/compiler/rustc_middle/src/dep_graph/graph.rs +++ b/compiler/rustc_middle/src/dep_graph/graph.rs @@ -25,7 +25,7 @@ use {super::debug::EdgeFilter, std::env}; use super::query::DepGraphQuery; use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; -use super::{DepContext, DepKind, DepNode, Deps, DepsType, HasDepContext, WorkProductId}; +use super::{DepContext, DepKind, DepNode, DepsType, HasDepContext, WorkProductId}; use crate::dep_graph::edges::EdgesVec; use crate::ty::TyCtxt; use crate::verify_ich::incremental_verify_ich; @@ -252,7 +252,7 @@ impl DepGraph { } #[inline(always)] - pub fn with_task, A: Debug, R>( + pub fn with_task( &self, key: DepNode, cx: Ctxt, @@ -266,7 +266,7 @@ impl DepGraph { } } - pub fn with_anon_task, OP, R>( + pub fn with_anon_task( &self, cx: Tcx, dep_kind: DepKind, @@ -315,7 +315,7 @@ impl DepGraphData { /// /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation.html #[inline(always)] - pub fn with_task, A: Debug, R>( + pub fn with_task( &self, key: DepNode, cx: Ctxt, @@ -369,7 +369,7 @@ impl DepGraphData { /// FIXME: This could perhaps return a `WithDepNode` to ensure that the /// user of this function actually performs the read; we'll have to see /// how to make that work with `anon` in `execute_job_incr`, though. - pub fn with_anon_task_inner, OP, R>( + pub fn with_anon_task_inner( &self, cx: Tcx, dep_kind: DepKind, @@ -438,7 +438,7 @@ impl DepGraphData { } /// Intern the new `DepNode` with the dependencies up-to-now. - fn hash_result_and_alloc_node, R>( + fn hash_result_and_alloc_node( &self, cx: &Ctxt, node: DepNode, @@ -553,7 +553,7 @@ impl DepGraph { /// FIXME: If the code is changed enough for this node to be marked before requiring the /// caller's node, we suppose that those changes will be enough to mark this node red and /// force a recomputation using the "normal" way. - pub fn with_feed_task, R>( + pub fn with_feed_task( &self, node: DepNode, cx: Ctxt, diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index 0c100b773392..3b04ba4ca276 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -1,7 +1,6 @@ use std::panic; use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_data_structures::sync::DynSync; use rustc_query_system::ich::StableHashingContext; use rustc_session::Session; use tracing::instrument; @@ -28,8 +27,6 @@ mod query; mod serialized; pub trait DepContext: Copy { - type Deps: Deps; - /// Create a hashing context for hashing new results. fn with_stable_hashing_context(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R; @@ -96,45 +93,13 @@ pub trait DepContext: Copy { fn with_reduced_queries(self, _: impl FnOnce() -> T) -> T; } -pub trait Deps: DynSync { - /// Execute the operation with provided dependencies. - fn with_deps(deps: TaskDepsRef<'_>, op: OP) -> R - where - OP: FnOnce() -> R; - - /// Access dependencies from current implicit context. - fn read_deps(op: OP) - where - OP: for<'a> FnOnce(TaskDepsRef<'a>); - - fn name(dep_kind: DepKind) -> &'static str; - - /// We use this for most things when incr. comp. is turned off. - const DEP_KIND_NULL: DepKind; - - /// We use this to create a forever-red node. - const DEP_KIND_RED: DepKind; - - /// We use this to create a side effect node. - const DEP_KIND_SIDE_EFFECT: DepKind; - - /// We use this to create the anon node with zero dependencies. - const DEP_KIND_ANON_ZERO_DEPS: DepKind; - - /// This is the highest value a `DepKind` can have. It's used during encoding to - /// pack information into the unused bits. - const DEP_KIND_MAX: u16; -} - pub trait HasDepContext: Copy { - type Deps: self::Deps; - type DepContext: self::DepContext; + type DepContext: self::DepContext; fn dep_context(&self) -> &Self::DepContext; } impl HasDepContext for T { - type Deps = T::Deps; type DepContext = Self; fn dep_context(&self) -> &Self::DepContext { @@ -143,7 +108,6 @@ impl HasDepContext for T { } impl HasDepContext for (T, Q) { - type Deps = T::Deps; type DepContext = T::DepContext; fn dep_context(&self) -> &Self::DepContext { @@ -183,7 +147,8 @@ pub type DepKindVTable<'tcx> = dep_node::DepKindVTable>; pub struct DepsType; -impl Deps for DepsType { +impl DepsType { + /// Execute the operation with provided dependencies. fn with_deps(task_deps: TaskDepsRef<'_>, op: OP) -> R where OP: FnOnce() -> R, @@ -195,6 +160,7 @@ impl Deps for DepsType { }) } + /// Access dependencies from current implicit context. fn read_deps(op: OP) where OP: for<'a> FnOnce(TaskDepsRef<'a>), @@ -209,16 +175,24 @@ impl Deps for DepsType { dep_node::DEP_KIND_NAMES[dep_kind.as_usize()] } + /// We use this for most things when incr. comp. is turned off. const DEP_KIND_NULL: DepKind = dep_kinds::Null; + + /// We use this to create a forever-red node. const DEP_KIND_RED: DepKind = dep_kinds::Red; + + /// We use this to create a side effect node. const DEP_KIND_SIDE_EFFECT: DepKind = dep_kinds::SideEffect; + + /// We use this to create the anon node with zero dependencies. const DEP_KIND_ANON_ZERO_DEPS: DepKind = dep_kinds::AnonZeroDeps; + + /// This is the highest value a `DepKind` can have. It's used during encoding to + /// pack information into the unused bits. const DEP_KIND_MAX: u16 = dep_node::DEP_KIND_VARIANTS - 1; } impl<'tcx> DepContext for TyCtxt<'tcx> { - type Deps = DepsType; - #[inline] fn with_stable_hashing_context(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R { TyCtxt::with_stable_hashing_context(self, f) diff --git a/compiler/rustc_middle/src/dep_graph/serialized.rs b/compiler/rustc_middle/src/dep_graph/serialized.rs index 87b85226c9c3..d2938373f544 100644 --- a/compiler/rustc_middle/src/dep_graph/serialized.rs +++ b/compiler/rustc_middle/src/dep_graph/serialized.rs @@ -60,7 +60,7 @@ use tracing::{debug, instrument}; use super::graph::{CurrentDepGraph, DepNodeColorMap}; use super::query::DepGraphQuery; -use super::{DepKind, DepNode, DepNodeIndex, Deps}; +use super::{DepKind, DepNode, DepNodeIndex}; use crate::dep_graph::DepsType; use crate::dep_graph::edges::EdgesVec; diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 911d38d0993e..50838daf0112 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -15,8 +15,8 @@ use rustc_middle::bug; #[expect(unused_imports, reason = "used by doc comments")] use rustc_middle::dep_graph::DepKindVTable; use rustc_middle::dep_graph::{ - self, DepContext, DepNode, DepNodeIndex, DepNodeKey, DepsType, HasDepContext, - SerializedDepNodeIndex, dep_kinds, + self, DepContext, DepNode, DepNodeIndex, DepNodeKey, HasDepContext, SerializedDepNodeIndex, + dep_kinds, }; use rustc_middle::query::on_disk_cache::{ AbsoluteBytePos, CacheDecoder, CacheEncoder, EncodedDepNodeIndex, @@ -142,7 +142,6 @@ impl<'tcx> QueryCtxt<'tcx> { } impl<'tcx> HasDepContext for QueryCtxt<'tcx> { - type Deps = DepsType; type DepContext = TyCtxt<'tcx>; #[inline]