2020-03-18 09:32:58 +00:00
|
|
|
use crate::ty::{self, TyCtxt};
|
|
|
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
2020-11-14 15:48:54 +00:00
|
|
|
use rustc_query_system::ich::StableHashingContext;
|
2020-11-12 19:48:37 +00:00
|
|
|
use rustc_session::Session;
|
2020-03-18 09:32:58 +00:00
|
|
|
|
2021-01-19 18:07:06 +00:00
|
|
|
#[macro_use]
|
2020-03-18 09:32:58 +00:00
|
|
|
mod dep_node;
|
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
pub use rustc_query_system::dep_graph::debug::EdgeFilter;
|
2020-03-18 09:32:58 +00:00
|
|
|
pub use rustc_query_system::dep_graph::{
|
2023-11-15 05:15:38 +00:00
|
|
|
debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps,
|
|
|
|
SerializedDepGraph, SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId,
|
2023-09-15 13:39:11 +00:00
|
|
|
WorkProductMap,
|
2020-03-18 09:32:58 +00:00
|
|
|
};
|
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
pub use dep_node::{dep_kinds, label_strs, DepKind, DepNode, DepNodeExt};
|
2022-05-20 23:51:09 +00:00
|
|
|
pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item};
|
2020-03-18 09:32:58 +00:00
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
|
2022-09-12 02:10:53 +00:00
|
|
|
|
|
|
|
pub type DepKindStruct<'tcx> = rustc_query_system::dep_graph::DepKindStruct<TyCtxt<'tcx>>;
|
2020-03-18 09:32:58 +00:00
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct DepsType;
|
2020-03-18 09:32:58 +00:00
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
impl Deps for DepsType {
|
2022-01-08 23:22:06 +00:00
|
|
|
fn with_deps<OP, R>(task_deps: TaskDepsRef<'_>, op: OP) -> R
|
2020-03-18 09:32:58 +00:00
|
|
|
where
|
|
|
|
OP: FnOnce() -> R,
|
|
|
|
{
|
|
|
|
ty::tls::with_context(|icx| {
|
|
|
|
let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
|
|
|
|
|
2023-02-07 05:11:40 +00:00
|
|
|
ty::tls::enter_context(&icx, op)
|
2020-03-18 09:32:58 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
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 11:01:37 +00:00
|
|
|
fn read_deps<OP>(op: OP)
|
2020-03-18 09:32:58 +00:00
|
|
|
where
|
2022-01-08 23:22:06 +00:00
|
|
|
OP: for<'a> FnOnce(TaskDepsRef<'a>),
|
2020-03-18 09:32:58 +00:00
|
|
|
{
|
|
|
|
ty::tls::with_context_opt(|icx| {
|
2022-02-15 04:58:25 +00:00
|
|
|
let Some(icx) = icx else { return };
|
2020-03-18 09:32:58 +00:00
|
|
|
op(icx.task_deps)
|
|
|
|
})
|
|
|
|
}
|
2023-04-30 01:51:32 +00:00
|
|
|
|
2023-09-15 13:39:11 +00:00
|
|
|
const DEP_KIND_NULL: DepKind = dep_kinds::Null;
|
|
|
|
const DEP_KIND_RED: DepKind = dep_kinds::Red;
|
|
|
|
const DEP_KIND_MAX: u16 = dep_node::DEP_KIND_VARIANTS - 1;
|
2020-03-18 09:32:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> DepContext for TyCtxt<'tcx> {
|
2023-09-15 13:39:11 +00:00
|
|
|
type Deps = DepsType;
|
2020-03-18 09:32:58 +00:00
|
|
|
|
2021-07-20 12:03:20 +00:00
|
|
|
#[inline]
|
2023-02-13 23:18:46 +00:00
|
|
|
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
|
|
|
|
TyCtxt::with_stable_hashing_context(self, f)
|
2020-03-18 09:32:58 +00:00
|
|
|
}
|
|
|
|
|
2020-10-11 08:34:50 +00:00
|
|
|
#[inline]
|
|
|
|
fn dep_graph(&self) -> &DepGraph {
|
|
|
|
&self.dep_graph
|
|
|
|
}
|
|
|
|
|
2020-11-12 19:48:37 +00:00
|
|
|
#[inline(always)]
|
2020-03-18 09:32:58 +00:00
|
|
|
fn profiler(&self) -> &SelfProfilerRef {
|
|
|
|
&self.prof
|
|
|
|
}
|
2020-11-12 19:48:37 +00:00
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
fn sess(&self) -> &Session {
|
|
|
|
self.sess
|
|
|
|
}
|
2021-10-16 18:10:23 +00:00
|
|
|
|
2022-09-12 04:18:08 +00:00
|
|
|
#[inline]
|
2023-02-27 18:12:16 +00:00
|
|
|
fn dep_kind_info(&self, dk: DepKind) -> &DepKindStruct<'tcx> {
|
2023-09-15 13:39:11 +00:00
|
|
|
&self.query_kinds[dk.as_usize()]
|
2021-10-16 18:24:08 +00:00
|
|
|
}
|
2020-03-18 09:32:58 +00:00
|
|
|
}
|