1 use crate::ich::StableHashingContext;
2 use crate::ty::{self, TyCtxt};
3 use rustc_data_structures::profiling::SelfProfilerRef;
4 use rustc_data_structures::sync::Lock;
5 use rustc_session::Session;
10 pub use rustc_query_system::dep_graph::{
11 debug::DepNodeFilter, hash_result, DepContext, DepNodeColor, DepNodeIndex,
12 SerializedDepNodeIndex, WorkProduct, WorkProductId,
15 pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};
16 crate use dep_node::{make_compile_codegen_unit, make_compile_mono_item};
18 pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
19 pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
20 pub type DepGraphQuery = rustc_query_system::dep_graph::DepGraphQuery<DepKind>;
21 pub type PreviousDepGraph = rustc_query_system::dep_graph::PreviousDepGraph<DepKind>;
22 pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<DepKind>;
23 pub type EdgeFilter = rustc_query_system::dep_graph::debug::EdgeFilter<DepKind>;
25 impl rustc_query_system::dep_graph::DepKind for DepKind {
26 const NULL: Self = DepKind::Null;
29 fn can_reconstruct_query_key(&self) -> bool {
30 DepKind::can_reconstruct_query_key(self)
34 fn is_eval_always(&self) -> bool {
39 fn has_params(&self) -> bool {
43 fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 write!(f, "{:?}", node.kind)?;
46 if !node.kind.has_params && !node.kind.is_anon {
52 ty::tls::with_opt(|opt_tcx| {
53 if let Some(tcx) = opt_tcx {
54 if let Some(def_id) = node.extract_def_id(tcx) {
55 write!(f, "{}", tcx.def_path_debug_str(def_id))?;
56 } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*node) {
59 write!(f, "{}", node.hash)?;
62 write!(f, "{}", node.hash)?;
70 fn with_deps<OP, R>(task_deps: Option<&Lock<TaskDeps>>, op: OP) -> R
74 ty::tls::with_context(|icx| {
75 let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
77 ty::tls::enter_context(&icx, |_| op())
81 fn read_deps<OP>(op: OP)
83 OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps>>),
85 ty::tls::with_context_opt(|icx| {
86 let icx = if let Some(icx) = icx { icx } else { return };
92 impl<'tcx> DepContext for TyCtxt<'tcx> {
93 type DepKind = DepKind;
94 type StableHashingContext = StableHashingContext<'tcx>;
96 fn register_reused_dep_node(&self, dep_node: &DepNode) {
97 if let Some(cache) = self.on_disk_cache.as_ref() {
98 cache.register_reused_dep_node(*self, dep_node)
102 fn create_stable_hashing_context(&self) -> Self::StableHashingContext {
103 TyCtxt::create_stable_hashing_context(*self)
107 fn dep_graph(&self) -> &DepGraph {
112 fn profiler(&self) -> &SelfProfilerRef {
117 fn sess(&self) -> &Session {