Addressed feedback from 2020-12-01

Added one more test (two files) showing coverage of generics and unused
functions across crates.

Created and referenced new Issues, as requested.

Added comments.

Added a note about the possible effects of compiler options on LLVM
coverage maps.
This commit is contained in:
Rich Kadel 2020-12-01 23:01:26 -08:00
parent def932ca86
commit d96f351fa3
28 changed files with 1797 additions and 366 deletions

View file

@ -140,7 +140,9 @@ impl CoverageGraph {
// The following `TerminatorKind`s are either not expected outside an unwind branch,
// or they should not (under normal circumstances) branch. Coverage graphs are
// simplified by assuring coverage results are accurate for well-behaved programs.
// simplified by assuring coverage results are accurate for program executions that
// don't panic.
//
// Programs that panic and unwind may record slightly inaccurate coverage results
// for a coverage region containing the `Terminator` that began the panic. This
// is as intended. (See Issue #78544 for a possible future option to support

View file

@ -499,6 +499,8 @@ fn fn_sig_and_body<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
) -> (Option<&'tcx rustc_hir::FnSig<'tcx>>, &'tcx rustc_hir::Body<'tcx>) {
// FIXME(#79625): Consider improving MIR to provide the information needed, to avoid going back
// to HIR for it.
let hir_node = tcx.hir().get_if_local(def_id).expect("expected DefId is local");
let fn_body_id = hir::map::associated_body(hir_node).expect("HIR node is a function with body");
(hir::map::fn_sig(hir_node), tcx.hir().body(fn_body_id))

View file

@ -359,12 +359,12 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
}
// Async functions wrap a closure that implements the body to be executed. The enclosing
// function is initially called, posts the closure to the executor, and returns. To avoid
// showing the return from the enclosing function as a "covered" return from the closure,
// the enclosing function's `TerminatorKind::Return`s `CoverageSpan` is excluded. The
// closure's `Return` is the only one that will be counted. This provides adequate
// coverage, and more intuitive counts. (Avoids double-counting the closing brace of the
// function body.)
// function is called and returns an `impl Future` without initially executing any of the
// body. To avoid showing the return from the enclosing function as a "covered" return from
// the closure, the enclosing function's `TerminatorKind::Return`s `CoverageSpan` is
// excluded. The closure's `Return` is the only one that will be counted. This provides
// adequate coverage, and more intuitive counts. (Avoids double-counting the closing brace
// of the function body.)
let body_ends_with_closure = if let Some(last_covspan) = refined_spans.last() {
last_covspan.is_closure && last_covspan.span.hi() == self.body_span.hi()
} else {