Skip to content

Commit 3dbe59e

Browse files
committed
coverage: Check that the fn sig span is before the body span
If the function signature span comes after the body span (due to macro expansion), expanding it towards the start of the body span would produce nonsense.
1 parent 623ef37 commit 3dbe59e

File tree

1 file changed

+1
-0
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+1
-0
lines changed

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ fn make_coverage_hir_info(tcx: TyCtxt<'_>, def_id: LocalDefId) -> mir::coverage:
330330

331331
let fn_sig_span = if let Some(fn_sig) = maybe_fn_sig
332332
&& spans_are_compatible(fn_sig.span, body_span)
333+
&& fn_sig.span.lo() <= body_span.lo()
333334
{
334335
fn_sig.span.with_hi(body_span.lo())
335336
} else {

0 commit comments

Comments
 (0)