diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-04-27 19:24:33 +0200 | 
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-10 20:18:18 +0200 | 
| commit | b19ae20aada117a589ec238f97c97a98b483f97d (patch) | |
| tree | 47dde9a7f58604722b43c70c288edd2a70f8f561 /compiler/rustc_interface/src/callbacks.rs | |
| parent | e85ddeb474665f3af7c447445c273da6117e266d (diff) | |
| download | rust-b19ae20aada117a589ec238f97c97a98b483f97d.tar.gz rust-b19ae20aada117a589ec238f97c97a98b483f97d.zip | |
Track span dependency using a callback.
Diffstat (limited to 'compiler/rustc_interface/src/callbacks.rs')
| -rw-r--r-- | compiler/rustc_interface/src/callbacks.rs | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs index 3b852b8ccf9..03c75655d6a 100644 --- a/compiler/rustc_interface/src/callbacks.rs +++ b/compiler/rustc_interface/src/callbacks.rs @@ -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(&_))); } | 
