2020-03-18 10:32:58 +01:00
|
|
|
use crate::ich::StableHashingContext;
|
|
|
|
use crate::ty::{self, TyCtxt};
|
|
|
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
|
|
|
use rustc_data_structures::sync::Lock;
|
2020-11-12 20:48:37 +01:00
|
|
|
use rustc_session::Session;
|
2020-03-18 10:32:58 +01:00
|
|
|
|
2021-01-19 19:07:06 +01:00
|
|
|
#[macro_use]
|
2020-03-18 10:32:58 +01:00
|
|
|
mod dep_node;
|
|
|
|
|
|
|
|
pub use rustc_query_system::dep_graph::{
|
2021-03-02 22:38:49 +01:00
|
|
|
debug::DepNodeFilter, hash_result, DepContext, DepNodeColor, DepNodeIndex,
|
|
|
|
SerializedDepNodeIndex, WorkProduct, WorkProductId,
|
2020-03-18 10:32:58 +01:00
|
|
|
};
|
|
|
|
|
2021-01-08 18:00:25 -05:00
|
|
|
crate use dep_node::make_compile_codegen_unit;
|
|
|
|
pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};
|
2020-03-18 10:32:58 +01:00
|
|
|
|
|
|
|
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
|
|
|
|
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
|
|
|
|
pub type DepGraphQuery = rustc_query_system::dep_graph::DepGraphQuery<DepKind>;
|
|
|
|
pub type PreviousDepGraph = rustc_query_system::dep_graph::PreviousDepGraph<DepKind>;
|
|
|
|
pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<DepKind>;
|
2021-03-02 22:38:49 +01:00
|
|
|
pub type EdgeFilter = rustc_query_system::dep_graph::debug::EdgeFilter<DepKind>;
|
2020-03-18 10:32:58 +01:00
|
|
|
|
|
|
|
impl rustc_query_system::dep_graph::DepKind for DepKind {
|
2020-03-18 21:02:02 +01:00
|
|
|
const NULL: Self = DepKind::Null;
|
|
|
|
|
2020-10-27 19:49:10 +01:00
|
|
|
#[inline(always)]
|
|
|
|
fn can_reconstruct_query_key(&self) -> bool {
|
|
|
|
DepKind::can_reconstruct_query_key(self)
|
|
|
|
}
|
|
|
|
|
2020-10-27 18:43:49 +01:00
|
|
|
#[inline(always)]
|
2020-03-18 10:32:58 +01:00
|
|
|
fn is_eval_always(&self) -> bool {
|
2020-10-27 18:43:49 +01:00
|
|
|
self.is_eval_always
|
2020-03-18 10:32:58 +01:00
|
|
|
}
|
|
|
|
|
2020-10-27 18:46:43 +01:00
|
|
|
#[inline(always)]
|
2020-03-18 10:32:58 +01:00
|
|
|
fn has_params(&self) -> bool {
|
2020-10-27 18:46:43 +01:00
|
|
|
self.has_params
|
2020-03-18 10:32:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
write!(f, "{:?}", node.kind)?;
|
|
|
|
|
2020-10-27 18:46:43 +01:00
|
|
|
if !node.kind.has_params && !node.kind.is_anon {
|
2020-03-18 10:32:58 +01:00
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, "(")?;
|
|
|
|
|
|
|
|
ty::tls::with_opt(|opt_tcx| {
|
|
|
|
if let Some(tcx) = opt_tcx {
|
2020-03-21 09:28:37 +01:00
|
|
|
if let Some(def_id) = node.extract_def_id(tcx) {
|
2020-03-18 10:32:58 +01:00
|
|
|
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, ")")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with_deps<OP, R>(task_deps: Option<&Lock<TaskDeps>>, op: OP) -> R
|
|
|
|
where
|
|
|
|
OP: FnOnce() -> R,
|
|
|
|
{
|
|
|
|
ty::tls::with_context(|icx| {
|
|
|
|
let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
|
|
|
|
|
|
|
|
ty::tls::enter_context(&icx, |_| op())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
Fix clippy warnings
Fixes clippy::{cone_on_copy, filter_next, redundant_closure, single_char_pattern, len_zero,redundant_field_names, useless_format, identity_conversion, map_clone, into_iter_on_ref, needless_return, option_as_ref_deref, unused_unit, unnecessary_mut_passed}
2020-05-11 13:01:37 +02:00
|
|
|
fn read_deps<OP>(op: OP)
|
2020-03-18 10:32:58 +01:00
|
|
|
where
|
Fix clippy warnings
Fixes clippy::{cone_on_copy, filter_next, redundant_closure, single_char_pattern, len_zero,redundant_field_names, useless_format, identity_conversion, map_clone, into_iter_on_ref, needless_return, option_as_ref_deref, unused_unit, unnecessary_mut_passed}
2020-05-11 13:01:37 +02:00
|
|
|
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps>>),
|
2020-03-18 10:32:58 +01:00
|
|
|
{
|
|
|
|
ty::tls::with_context_opt(|icx| {
|
|
|
|
let icx = if let Some(icx) = icx { icx } else { return };
|
|
|
|
op(icx.task_deps)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> DepContext for TyCtxt<'tcx> {
|
|
|
|
type DepKind = DepKind;
|
|
|
|
type StableHashingContext = StableHashingContext<'tcx>;
|
|
|
|
|
2020-12-18 16:00:52 -08:00
|
|
|
fn register_reused_dep_node(&self, dep_node: &DepNode) {
|
2021-01-04 23:38:20 +01:00
|
|
|
if let Some(cache) = self.on_disk_cache.as_ref() {
|
2020-12-18 16:00:52 -08:00
|
|
|
cache.register_reused_dep_node(*self, dep_node)
|
2020-11-25 15:08:31 -05:00
|
|
|
}
|
2020-07-29 12:26:15 -04:00
|
|
|
}
|
|
|
|
|
2020-03-18 10:32:58 +01:00
|
|
|
fn create_stable_hashing_context(&self) -> Self::StableHashingContext {
|
|
|
|
TyCtxt::create_stable_hashing_context(*self)
|
|
|
|
}
|
|
|
|
|
2020-10-11 10:34:50 +02:00
|
|
|
#[inline]
|
|
|
|
fn dep_graph(&self) -> &DepGraph {
|
|
|
|
&self.dep_graph
|
|
|
|
}
|
|
|
|
|
2020-11-12 20:48:37 +01:00
|
|
|
#[inline(always)]
|
2020-03-18 10:32:58 +01:00
|
|
|
fn profiler(&self) -> &SelfProfilerRef {
|
|
|
|
&self.prof
|
|
|
|
}
|
2020-11-12 20:48:37 +01:00
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
fn sess(&self) -> &Session {
|
|
|
|
self.sess
|
|
|
|
}
|
2020-03-18 10:32:58 +01:00
|
|
|
}
|