Skip to content

Commit 30de58e

Browse files
committed
source_span hook in case of non-incremental build
1 parent c0bb3b9 commit 30de58e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ rustc_queries! {
209209
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
210210
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
211211
/// of rustc_middle::hir::source_map.
212-
query source_span(key: LocalDefId) -> Span {
212+
query source_span_q(key: LocalDefId) -> Span {
213213
// Accesses untracked data
214214
eval_always
215215
desc { "getting the source span" }

compiler/rustc_middle/src/ty/context.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3482,6 +3482,15 @@ impl<'tcx> TyCtxt<'tcx> {
34823482
}
34833483
false
34843484
}
3485+
3486+
#[inline]
3487+
pub fn source_span(self, key: LocalDefId) -> Span {
3488+
if self.dep_graph.is_fully_enabled() {
3489+
self.source_span_q(key)
3490+
} else {
3491+
self.untracked.source_span.get(key).unwrap_or(DUMMY_SP)
3492+
}
3493+
}
34853494
}
34863495

34873496
/// Parameter attributes that can only be determined by examining the body of a function instead
@@ -3508,7 +3517,8 @@ pub fn provide(providers: &mut Providers) {
35083517
// We want to check if the panic handler was defined in this crate
35093518
tcx.lang_items().panic_impl().is_some_and(|did| did.is_local())
35103519
};
3511-
providers.source_span = |tcx, def_id| tcx.untracked.source_span.get(def_id).unwrap_or(DUMMY_SP);
3520+
providers.source_span_q =
3521+
|tcx, def_id| tcx.untracked.source_span.get(def_id).unwrap_or(DUMMY_SP);
35123522
}
35133523

35143524
pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {

0 commit comments

Comments
 (0)