Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ rustc_queries! {
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
/// of rustc_middle::hir::source_map.
query source_span(key: LocalDefId) -> Span {
query source_span_q(key: LocalDefId) -> Span {
// Accesses untracked data
eval_always
desc { "getting the source span" }
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,15 @@ impl<'tcx> TyCtxt<'tcx> {
}
false
}

#[inline]
pub fn source_span(self, key: LocalDefId) -> Span {
if self.dep_graph.is_fully_enabled() {
self.source_span_q(key)
} else {
self.untracked.source_span.get(key).unwrap_or(DUMMY_SP)
}
}
}

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

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