rustc_middle/dep_graph/
mod.rs1use std::panic;
2
3use tracing::instrument;
4
5pub use self::dep_node::{
6 DepKind, DepKindVTable, DepNode, WorkProductId, dep_kind_from_label, label_strs,
7};
8pub use self::dep_node_key::DepNodeKey;
9pub use self::graph::{
10 DepGraph, DepGraphData, DepNodeIndex, QuerySideEffect, TaskDepsRef, WorkProduct,
11 WorkProductMap, hash_result,
12};
13use self::graph::{MarkFrame, print_markframe_trace};
14pub use self::retained::RetainedDepGraph;
15pub use self::serialized::{SerializedDepGraph, SerializedDepNodeIndex};
16pub use crate::dep_graph::debug::{DepNodeFilter, EdgeFilter};
17use crate::ty::print::with_reduced_queries;
18use crate::ty::{self, TyCtxt};
19
20mod debug;
21pub(crate) mod dep_node;
22mod dep_node_key;
23mod edges;
24mod graph;
25mod retained;
26mod serialized;
27
28#[derive(#[automatically_derived]
impl ::core::fmt::Debug for KeyFingerprintStyle {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
KeyFingerprintStyle::DefPathHash => "DefPathHash",
KeyFingerprintStyle::HirId => "HirId",
KeyFingerprintStyle::Unit => "Unit",
KeyFingerprintStyle::Opaque => "Opaque",
})
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for KeyFingerprintStyle {
#[inline]
fn eq(&self, other: &KeyFingerprintStyle) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for KeyFingerprintStyle {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::marker::Copy for KeyFingerprintStyle { }Copy, #[automatically_derived]
impl ::core::clone::Clone for KeyFingerprintStyle {
#[inline]
fn clone(&self) -> KeyFingerprintStyle { *self }
}Clone)]
33pub enum KeyFingerprintStyle {
34 DefPathHash,
36 HirId,
38 Unit,
40 Opaque,
42}
43
44impl KeyFingerprintStyle {
45 #[inline]
50 pub const fn is_maybe_recoverable(self) -> bool {
51 match self {
52 KeyFingerprintStyle::DefPathHash
53 | KeyFingerprintStyle::Unit
54 | KeyFingerprintStyle::HirId => true,
55 KeyFingerprintStyle::Opaque => false,
56 }
57 }
58}
59
60fn with_deps<OP, R>(task_deps: TaskDepsRef<'_>, op: OP) -> R
62where
63 OP: FnOnce() -> R,
64{
65 ty::tls::with_context(|icx| {
66 let icx = ty::tls::ImplicitCtxt { task_deps, ..*icx };
67 ty::tls::enter_context(&icx, op)
68 })
69}
70
71fn read_deps<OP>(op: OP)
73where
74 OP: for<'a> FnOnce(TaskDepsRef<'a>),
75{
76 ty::tls::with_context_opt(|icx| {
77 let Some(icx) = icx else { return };
78 op(icx.task_deps)
79 })
80}
81
82impl<'tcx> TyCtxt<'tcx> {
83 #[inline]
84 pub fn dep_kind_vtable(self, dk: DepKind) -> &'tcx DepKindVTable<'tcx> {
85 &self.dep_kind_vtables[dk.as_usize()]
86 }
87
88 fn with_reduced_queries<T>(self, f: impl FnOnce() -> T) -> T {
89 { let _guard = ReducedQueriesGuard::new(); f() }with_reduced_queries!(f())
90 }
91
92 #[inline(always)]
93 pub fn key_fingerprint_style(self, kind: DepKind) -> KeyFingerprintStyle {
94 self.dep_kind_vtable(kind).key_fingerprint_style
95 }
96
97 #[inline]
103 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("try_force_from_dep_node",
"rustc_middle::dep_graph", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/dep_graph/mod.rs"),
::tracing_core::__macro_support::Option::Some(103u32),
::tracing_core::__macro_support::Option::Some("rustc_middle::dep_graph"),
::tracing_core::field::FieldSet::new(&["dep_node",
"prev_index"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&dep_node)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&prev_index)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: bool = loop {};
return __tracing_attr_fake_return;
}
{
if let Some(force_fn) =
self.dep_kind_vtable(dep_node.kind).force_from_dep_node_fn {
match panic::catch_unwind(panic::AssertUnwindSafe(||
{ force_fn(self, dep_node, prev_index) })) {
Err(value) => {
if !value.is::<rustc_errors::FatalErrorMarker>() {
print_markframe_trace(&self.dep_graph, frame);
}
panic::resume_unwind(value)
}
Ok(query_has_been_forced) => query_has_been_forced,
}
} else { false }
}
}
}#[instrument(skip(self, frame), level = "debug")]
104 fn try_force_from_dep_node(
105 self,
106 dep_node: DepNode,
107 prev_index: SerializedDepNodeIndex,
108 frame: &MarkFrame<'_>,
109 ) -> bool {
110 if let Some(force_fn) = self.dep_kind_vtable(dep_node.kind).force_from_dep_node_fn {
111 match panic::catch_unwind(panic::AssertUnwindSafe(|| {
112 force_fn(self, dep_node, prev_index)
113 })) {
114 Err(value) => {
115 if !value.is::<rustc_errors::FatalErrorMarker>() {
116 print_markframe_trace(&self.dep_graph, frame);
117 }
118 panic::resume_unwind(value)
119 }
120 Ok(query_has_been_forced) => query_has_been_forced,
121 }
122 } else {
123 false
124 }
125 }
126}