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 SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<DepKind>;
22 pub type EdgeFilter = rustc_query_system::dep_graph::debug::EdgeFilter<DepKind>;
24 impl rustc_query_system::dep_graph::DepKind for DepKind {
25 const NULL: Self = DepKind::Null;
28 fn can_reconstruct_query_key(&self) -> bool {
29 DepKind::can_reconstruct_query_key(self)
33 fn is_eval_always(&self) -> bool {
38 fn has_params(&self) -> bool {
42 fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43 write!(f, "{:?}", node.kind)?;
45 if !node.kind.has_params && !node.kind.is_anon {
51 ty::tls::with_opt(|opt_tcx| {
52 if let Some(tcx) = opt_tcx {
53 if let Some(def_id) = node.extract_def_id(tcx) {
54 write!(f, "{}", tcx.def_path_debug_str(def_id))?;
55 } else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*node) {
58 write!(f, "{}", node.hash)?;
61 write!(f, "{}", node.hash)?;
69 fn with_deps<OP, R>(task_deps: Option<&Lock<TaskDeps>>, op: OP) -> R
73 ty::tls::with_context(|icx| {
74 let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
76 ty::tls::enter_context(&icx, |_| op())
80 fn read_deps<OP>(op: OP)
82 OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps>>),
84 ty::tls::with_context_opt(|icx| {
85 let icx = if let Some(icx) = icx { icx } else { return };
91 impl<'tcx> DepContext for TyCtxt<'tcx> {
92 type DepKind = DepKind;
93 type StableHashingContext = StableHashingContext<'tcx>;
96 fn create_stable_hashing_context(&self) -> Self::StableHashingContext {
97 TyCtxt::create_stable_hashing_context(*self)
101 fn dep_graph(&self) -> &DepGraph {
106 fn profiler(&self) -> &SelfProfilerRef {
111 fn sess(&self) -> &Session {