Remove Deps.

It's no longer needed.
This commit is contained in:
Nicholas Nethercote 2026-02-12 10:35:23 +11:00
parent 1d83208683
commit 414be2e6ff
4 changed files with 24 additions and 51 deletions

View file

@ -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<Ctxt: HasDepContext<Deps = DepsType>, A: Debug, R>(
pub fn with_task<Ctxt: HasDepContext, A: Debug, R>(
&self,
key: DepNode,
cx: Ctxt,
@ -266,7 +266,7 @@ impl DepGraph {
}
}
pub fn with_anon_task<Tcx: DepContext<Deps = DepsType>, OP, R>(
pub fn with_anon_task<Tcx: DepContext, OP, R>(
&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<Ctxt: HasDepContext<Deps = DepsType>, A: Debug, R>(
pub fn with_task<Ctxt: HasDepContext, A: Debug, R>(
&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<Tcx: DepContext<Deps = DepsType>, OP, R>(
pub fn with_anon_task_inner<Tcx: DepContext, OP, R>(
&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<Ctxt: DepContext<Deps = DepsType>, R>(
fn hash_result_and_alloc_node<Ctxt: DepContext, R>(
&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<Ctxt: DepContext<Deps = DepsType>, R>(
pub fn with_feed_task<Ctxt: DepContext, R>(
&self,
node: DepNode,
cx: Ctxt,

View file

@ -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<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
@ -96,45 +93,13 @@ pub trait DepContext: Copy {
fn with_reduced_queries<T>(self, _: impl FnOnce() -> T) -> T;
}
pub trait Deps: DynSync {
/// Execute the operation with provided dependencies.
fn with_deps<OP, R>(deps: TaskDepsRef<'_>, op: OP) -> R
where
OP: FnOnce() -> R;
/// Access dependencies from current implicit context.
fn read_deps<OP>(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<Deps = Self::Deps>;
type DepContext: self::DepContext;
fn dep_context(&self) -> &Self::DepContext;
}
impl<T: DepContext> HasDepContext for T {
type Deps = T::Deps;
type DepContext = Self;
fn dep_context(&self) -> &Self::DepContext {
@ -143,7 +108,6 @@ impl<T: DepContext> HasDepContext for T {
}
impl<T: HasDepContext, Q: Copy> 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<TyCtxt<'tcx>>;
pub struct DepsType;
impl Deps for DepsType {
impl DepsType {
/// Execute the operation with provided dependencies.
fn with_deps<OP, R>(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: 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<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
TyCtxt::with_stable_hashing_context(self, f)

View file

@ -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;

View file

@ -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]