Open
Description
In #99780 (comment), I tried to add an assertion in the span formatting function to validate that the span for the mir::Body.span
span always contains all spans of MIR statements/terminators.
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs
index 28381157d50..ad44a0366b5 100644
--- a/compiler/rustc_span/src/source_map.rs
+++ b/compiler/rustc_span/src/source_map.rs
@@ -477,6 +477,8 @@ pub fn span_to_relative_line_string(&self, sp: Span, relative_to: Span) -> Strin
return self.span_to_embeddable_string(sp);
}
+ assert!(relative_to.contains(sp));
+
let lo_line = lo.line.saturating_sub(offset.line);
let hi_line = hi.line.saturating_sub(offset.line);
But this assertion failed for many tests. One such case was for associated constants.
We should investigate all the cases where the MIR body span is not fully correct, and add the assertion back in.