1
Fork 0

Add sanity check.

We force the relative span's parent to be absolute. This avoids having to
handle long dependency chains.
This commit is contained in:
Camille GILLOT 2021-04-27 19:58:46 +02:00
parent 940fa9251e
commit fb5ced0fbd
3 changed files with 9 additions and 3 deletions

View file

@ -28,7 +28,9 @@ 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);
let _span = tcx.source_span(def_id);
// Sanity check: relative span's parent must be an absolute span.
debug_assert_eq!(_span.data_untracked().parent, None);
}
})
}