|
58 | 58 | use std::fmt; |
59 | 59 | use std::hash::Hash; |
60 | 60 |
|
61 | | -use rustc_data_structures::AtomicRef; |
62 | 61 | use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; |
63 | 62 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; |
64 | 63 | use rustc_hir::def_id::DefId; |
65 | 64 | use rustc_hir::definitions::DefPathHash; |
66 | 65 | use rustc_macros::{Decodable, Encodable}; |
67 | | -use rustc_query_system::ich::StableHashingContext; |
68 | 66 | use rustc_span::Symbol; |
69 | 67 |
|
70 | 68 | use super::{FingerprintStyle, SerializedDepNodeIndex}; |
| 69 | +use crate::ich::StableHashingContext; |
71 | 70 | use crate::mir::mono::MonoItem; |
72 | | -use crate::ty::TyCtxt; |
| 71 | +use crate::ty::{TyCtxt, tls}; |
73 | 72 |
|
74 | 73 | /// This serves as an index into arrays built by `make_dep_kind_array`. |
75 | 74 | #[derive(Clone, Copy, PartialEq, Eq, Hash)] |
@@ -114,16 +113,15 @@ impl DepKind { |
114 | 113 | pub(crate) const MAX: u16 = DEP_KIND_VARIANTS - 1; |
115 | 114 | } |
116 | 115 |
|
117 | | -pub fn default_dep_kind_debug(kind: DepKind, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
118 | | - f.debug_struct("DepKind").field("variant", &kind.variant).finish() |
119 | | -} |
120 | | - |
121 | | -pub static DEP_KIND_DEBUG: AtomicRef<fn(DepKind, &mut fmt::Formatter<'_>) -> fmt::Result> = |
122 | | - AtomicRef::new(&(default_dep_kind_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); |
123 | | - |
124 | 116 | impl fmt::Debug for DepKind { |
125 | 117 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
126 | | - (*DEP_KIND_DEBUG)(*self, f) |
| 118 | + tls::with_opt(|opt_tcx| { |
| 119 | + if let Some(tcx) = opt_tcx { |
| 120 | + write!(f, "{}", tcx.dep_kind_vtable(*self).name) |
| 121 | + } else { |
| 122 | + f.debug_struct("DepKind").field("variant", &self.variant).finish() |
| 123 | + } |
| 124 | + }) |
127 | 125 | } |
128 | 126 | } |
129 | 127 |
|
@@ -175,16 +173,26 @@ impl DepNode { |
175 | 173 | } |
176 | 174 | } |
177 | 175 |
|
178 | | -pub fn default_dep_node_debug(node: DepNode, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
179 | | - f.debug_struct("DepNode").field("kind", &node.kind).field("hash", &node.hash).finish() |
180 | | -} |
181 | | - |
182 | | -pub static DEP_NODE_DEBUG: AtomicRef<fn(DepNode, &mut fmt::Formatter<'_>) -> fmt::Result> = |
183 | | - AtomicRef::new(&(default_dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); |
184 | | - |
185 | 176 | impl fmt::Debug for DepNode { |
186 | 177 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
187 | | - (*DEP_NODE_DEBUG)(*self, f) |
| 178 | + write!(f, "{:?}(", self.kind)?; |
| 179 | + |
| 180 | + tls::with_opt(|opt_tcx| { |
| 181 | + if let Some(tcx) = opt_tcx { |
| 182 | + if let Some(def_id) = self.extract_def_id(tcx) { |
| 183 | + write!(f, "{}", tcx.def_path_debug_str(def_id))?; |
| 184 | + } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) { |
| 185 | + write!(f, "{s}")?; |
| 186 | + } else { |
| 187 | + write!(f, "{}", self.hash)?; |
| 188 | + } |
| 189 | + } else { |
| 190 | + write!(f, "{}", self.hash)?; |
| 191 | + } |
| 192 | + Ok(()) |
| 193 | + })?; |
| 194 | + |
| 195 | + write!(f, ")") |
188 | 196 | } |
189 | 197 | } |
190 | 198 |
|
|
0 commit comments