Auto merge of #84323 - richkadel:uncovered-functions, r=tmandry
coverage of async function bodies should match non-async This fixes some missing coverage within async function bodies. Commit 1 demonstrates the problem in the fixed issue, and commit 2 corrects it. Fixes: #83985
This commit is contained in:
@@ -11,7 +11,7 @@ use rustc_middle::mir::{
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use rustc_span::source_map::original_sp;
|
||||
use rustc_span::{BytePos, Span, SyntaxContext};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
@@ -246,7 +246,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
|
||||
) -> Vec<CoverageSpan> {
|
||||
let mut coverage_spans = CoverageSpans {
|
||||
mir_body,
|
||||
fn_sig_span,
|
||||
fn_sig_span: fn_sig_source_span(fn_sig_span, body_span),
|
||||
body_span,
|
||||
basic_coverage_blocks,
|
||||
sorted_spans_iter: None,
|
||||
@@ -731,8 +731,13 @@ pub(super) fn filtered_terminator_span(
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn fn_sig_source_span(fn_sig_span: Span, body_span: Span) -> Span {
|
||||
original_sp(fn_sig_span, body_span).with_ctxt(body_span.ctxt())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn function_source_span(span: Span, body_span: Span) -> Span {
|
||||
let span = original_sp(span, body_span).with_ctxt(SyntaxContext::root());
|
||||
let span = original_sp(span, body_span).with_ctxt(body_span.ctxt());
|
||||
if body_span.contains(span) { span } else { body_span }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user