Remove DEP_NODE_DEBUG.

Like the previous commit, it's no longer needed.
This commit is contained in:
Nicholas Nethercote 2026-02-16 21:13:40 +11:00
parent 74dd36a934
commit 47ed4526d9
2 changed files with 21 additions and 37 deletions

View file

@ -11,8 +11,8 @@
use std::fmt; use std::fmt;
use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC}; use rustc_errors::DiagInner;
use rustc_middle::dep_graph::{DepNode, TaskDepsRef}; use rustc_middle::dep_graph::TaskDepsRef;
use rustc_middle::ty::tls; use rustc_middle::ty::tls;
fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) { fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
@ -64,35 +64,10 @@ fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) ->
write!(f, ")") write!(f, ")")
} }
/// This is a callback from `rustc_query_system` as it cannot access the implicit state
/// in `rustc_middle` otherwise.
pub fn dep_node_debug(node: DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}(", node.kind)?;
tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx {
if let Some(def_id) = node.extract_def_id(tcx) {
write!(f, "{}", tcx.def_path_debug_str(def_id))?;
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(node) {
write!(f, "{s}")?;
} else {
write!(f, "{}", node.hash)?;
}
} else {
write!(f, "{}", node.hash)?;
}
Ok(())
})?;
write!(f, ")")
}
/// Sets up the callbacks in prior crates which we want to refer to the /// Sets up the callbacks in prior crates which we want to refer to the
/// TyCtxt in. /// TyCtxt in.
pub fn setup_callbacks() { pub fn setup_callbacks() {
rustc_span::SPAN_TRACK.swap(&(track_span_parent as fn(_))); rustc_span::SPAN_TRACK.swap(&(track_span_parent as fn(_)));
rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
rustc_middle::dep_graph::dep_node::DEP_NODE_DEBUG rustc_errors::TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _));
.swap(&(dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _));
} }

View file

@ -58,7 +58,6 @@
use std::fmt; use std::fmt;
use std::hash::Hash; use std::hash::Hash;
use rustc_data_structures::AtomicRef;
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -174,16 +173,26 @@ impl DepNode {
} }
} }
pub fn default_dep_node_debug(node: DepNode, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DepNode").field("kind", &node.kind).field("hash", &node.hash).finish()
}
pub static DEP_NODE_DEBUG: AtomicRef<fn(DepNode, &mut fmt::Formatter<'_>) -> fmt::Result> =
AtomicRef::new(&(default_dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
impl fmt::Debug for DepNode { impl fmt::Debug for DepNode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(*DEP_NODE_DEBUG)(*self, f) write!(f, "{:?}(", self.kind)?;
tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx {
if let Some(def_id) = self.extract_def_id(tcx) {
write!(f, "{}", tcx.def_path_debug_str(def_id))?;
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) {
write!(f, "{s}")?;
} else {
write!(f, "{}", self.hash)?;
}
} else {
write!(f, "{}", self.hash)?;
}
Ok(())
})?;
write!(f, ")")
} }
} }