Auto merge of #129513 - cjgillot:fast-source-span, r=petrochenkov
Do not call source_span when not tracking dependencies. Split from https://github.com/rust-lang/rust/pull/127241
This commit is contained in:
commit
ab869e094a
@ -18,12 +18,20 @@
|
|||||||
use rustc_query_system::dep_graph::{DepContext, DepKind, DepNode};
|
use rustc_query_system::dep_graph::{DepContext, DepKind, DepNode};
|
||||||
|
|
||||||
fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
|
fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
|
||||||
tls::with_opt(|tcx| {
|
tls::with_context_opt(|icx| {
|
||||||
if let Some(tcx) = tcx {
|
if let Some(icx) = icx {
|
||||||
let _span = tcx.source_span(def_id);
|
// `track_span_parent` gets called a lot from HIR lowering code.
|
||||||
|
// Skip doing anything if we aren't tracking dependencies.
|
||||||
|
let tracks_deps = match icx.task_deps {
|
||||||
|
TaskDepsRef::Allow(..) => true,
|
||||||
|
TaskDepsRef::EvalAlways | TaskDepsRef::Ignore | TaskDepsRef::Forbid => false,
|
||||||
|
};
|
||||||
|
if tracks_deps {
|
||||||
|
let _span = icx.tcx.source_span(def_id);
|
||||||
// Sanity check: relative span's parent must be an absolute span.
|
// Sanity check: relative span's parent must be an absolute span.
|
||||||
debug_assert_eq!(_span.data_untracked().parent, None);
|
debug_assert_eq!(_span.data_untracked().parent, None);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user