Fix line numbers for MIR inlined code

`should_collapse_debuginfo` detects if the specified span is part of a
macro expansion however it does this by checking if the span is anything
other than a normal (non-expanded) kind, then the span sequence is
walked backwards to the root span.

This doesn't work when the MIR inliner inlines code as it creates spans
with expansion information set to `ExprKind::Inlined` and results in the
line number being attributed to the inline callsite rather than the
normal line number of the inlined code.
This commit is contained in:
Wesley Wiser
2022-10-14 18:44:30 -04:00
parent 9363a1401e
commit 34d90a46da
3 changed files with 11 additions and 3 deletions

View File

@@ -2522,7 +2522,9 @@ impl<'tcx> TyCtxt<'tcx> {
&& if self.features().collapse_debuginfo {
span.in_macro_expansion_with_collapse_debuginfo()
} else {
span.from_expansion()
// Inlined spans should not be collapsed as that leads to all of the
// inlined code being attributed to the inline callsite.
span.from_expansion() && !span.is_inlined()
}
}