about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
diff options
context:
space:
mode:
authorRich Kadel <richkadel@google.com>2020-12-01 23:01:26 -0800
committerRich Kadel <richkadel@google.com>2020-12-03 09:50:10 -0800
commitd96f351fa36d31f2b95b1cd2ad37ceaed3d395a8 (patch)
treeb51e88d4b3163850b652ea044962b812bb339b38 /compiler/rustc_mir/src
parentdef932ca865b86a5057517d8a0e27c0ca72a0815 (diff)
downloadrust-d96f351fa36d31f2b95b1cd2ad37ceaed3d395a8.tar.gz
rust-d96f351fa36d31f2b95b1cd2ad37ceaed3d395a8.zip
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.
Diffstat (limited to 'compiler/rustc_mir/src')
-rw-r--r--compiler/rustc_mir/src/transform/coverage/graph.rs4
-rw-r--r--compiler/rustc_mir/src/transform/coverage/mod.rs2
-rw-r--r--compiler/rustc_mir/src/transform/coverage/spans.rs12
3 files changed, 11 insertions, 7 deletions
diff --git a/compiler/rustc_mir/src/transform/coverage/graph.rs b/compiler/rustc_mir/src/transform/coverage/graph.rs
index 7db88a686a7..f79f0d32538 100644
--- a/compiler/rustc_mir/src/transform/coverage/graph.rs
+++ b/compiler/rustc_mir/src/transform/coverage/graph.rs
@@ -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
diff --git a/compiler/rustc_mir/src/transform/coverage/mod.rs b/compiler/rustc_mir/src/transform/coverage/mod.rs
index 18249530577..10f522d6746 100644
--- a/compiler/rustc_mir/src/transform/coverage/mod.rs
+++ b/compiler/rustc_mir/src/transform/coverage/mod.rs
@@ -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))
diff --git a/compiler/rustc_mir/src/transform/coverage/spans.rs b/compiler/rustc_mir/src/transform/coverage/spans.rs
index 38d66a442ad..6eb89754ee6 100644
--- a/compiler/rustc_mir/src/transform/coverage/spans.rs
+++ b/compiler/rustc_mir/src/transform/coverage/spans.rs
@@ -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 {