Track span dependency using a callback.
This commit is contained in:
parent
e85ddeb474
commit
b19ae20aad
6 changed files with 40 additions and 5 deletions
|
@ -25,6 +25,14 @@ fn span_debug(span: rustc_span::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result
|
|||
})
|
||||
}
|
||||
|
||||
fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
|
||||
tls::with_opt(|tcx| {
|
||||
if let Some(tcx) = tcx {
|
||||
let _ = tcx.source_span(def_id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// This is a callback from `rustc_ast` as it cannot access the implicit state
|
||||
/// in `rustc_middle` otherwise. It is used to when diagnostic messages are
|
||||
/// emitted and stores them in the current query, if there is one.
|
||||
|
@ -56,6 +64,7 @@ fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) ->
|
|||
/// TyCtxt in.
|
||||
pub fn setup_callbacks() {
|
||||
rustc_span::SPAN_DEBUG.swap(&(span_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
|
||||
rustc_span::SPAN_TRACK.swap(&(track_span_parent as fn(_)));
|
||||
rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
|
||||
TRACK_DIAGNOSTICS.swap(&(track_diagnostic as fn(&_)));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue