about summary refs log tree commit diff
path: root/src/test/run-make-fulldeps/coverage
diff options
context:
space:
mode:
authorRich Kadel <richkadel@google.com>2021-05-01 14:56:48 -0700
committerRich Kadel <richkadel@google.com>2021-05-01 15:04:48 -0700
commit0b0d293c7c46bdadf80e5304a667e34c53c0cf7e (patch)
tree7a2fac5f5697d60eef39f20242a51e4582ca00f6 /src/test/run-make-fulldeps/coverage
parent603a42ec5458c547b51173cfa48c23ad37b03c3f (diff)
downloadrust-0b0d293c7c46bdadf80e5304a667e34c53c0cf7e.tar.gz
rust-0b0d293c7c46bdadf80e5304a667e34c53c0cf7e.zip
Report coverage `0` of dead blocks
Fixes: #84018

With `-Z instrument-coverage`, coverage reporting of dead blocks
(for example, blocks dropped because a conditional branch is dropped,
based on const evaluation) is now supported.

If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()`
finds all dropped coverage `Statement`s and adds their `code_region`s as
`Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are
still included in the coverage map.

Check out the resulting changes in the test coverage reports in this PR.
Diffstat (limited to 'src/test/run-make-fulldeps/coverage')
-rw-r--r--src/test/run-make-fulldeps/coverage/conditions.rs4
-rw-r--r--src/test/run-make-fulldeps/coverage/generics.rs10
-rw-r--r--src/test/run-make-fulldeps/coverage/loops_branches.rs8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/test/run-make-fulldeps/coverage/conditions.rs b/src/test/run-make-fulldeps/coverage/conditions.rs
index 8a2a0b53e58..057599d1b47 100644
--- a/src/test/run-make-fulldeps/coverage/conditions.rs
+++ b/src/test/run-make-fulldeps/coverage/conditions.rs
@@ -53,8 +53,8 @@ fn main() {
         } else {
             return;
         }
-    } // Note: closing brace shows uncovered (vs. `0` for implicit else) because condition literal
-      // `true` was const-evaluated. The compiler knows the `if` block will be executed.
+    }
+
 
     let mut countdown = 0;
     if true {
diff --git a/src/test/run-make-fulldeps/coverage/generics.rs b/src/test/run-make-fulldeps/coverage/generics.rs
index cbeda35d3b8..18b38868496 100644
--- a/src/test/run-make-fulldeps/coverage/generics.rs
+++ b/src/test/run-make-fulldeps/coverage/generics.rs
@@ -30,11 +30,11 @@ fn main() -> Result<(),u8> {
     if true {
         println!("Exiting with error...");
         return Err(1);
-    } // The remaining lines below have no coverage because `if true` (with the constant literal
-      // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`.
-      // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown
-      // in other tests, the lines below would have coverage (which would show they had `0`
-      // executions, assuming the condition still evaluated to `true`).
+    }
+
+
+
+
 
     let _ = Firework { strength: 1000 };
 
diff --git a/src/test/run-make-fulldeps/coverage/loops_branches.rs b/src/test/run-make-fulldeps/coverage/loops_branches.rs
index 4d9bbad3367..7116ce47f4b 100644
--- a/src/test/run-make-fulldeps/coverage/loops_branches.rs
+++ b/src/test/run-make-fulldeps/coverage/loops_branches.rs
@@ -12,7 +12,7 @@ impl std::fmt::Debug for DebugTest {
                 while true {
                 }
             }
-            write!(f, "error")?;
+            write!(f, "cool")?;
         } else {
         }
 
@@ -21,7 +21,7 @@ impl std::fmt::Debug for DebugTest {
                 if false {
                     while true {}
                 }
-                write!(f, "error")?;
+                write!(f, "cool")?;
             } else {
             }
         }
@@ -38,7 +38,7 @@ impl std::fmt::Display for DisplayTest {
             if false {
                 while true {}
             }
-            write!(f, "error")?;
+            write!(f, "cool")?;
         }
         for i in 0..10 {
             if false {
@@ -46,7 +46,7 @@ impl std::fmt::Display for DisplayTest {
                 if false {
                     while true {}
                 }
-                write!(f, "error")?;
+                write!(f, "cool")?;
             }
         }
         Ok(())