about summary refs log tree commit diff
path: root/src/test/run-make-fulldeps/coverage/continue.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-20 03:08:24 +0000
committerbors <bors@rust-lang.org>2021-04-20 03:08:24 +0000
commitb2c20b51ed838368d3f2bdccb63f401bcddb7e1c (patch)
treeb0af4165f7549a3915410a8d8e52587a7e8bf948 /src/test/run-make-fulldeps/coverage/continue.rs
parente888a57da83fca78d6e64af0a347d06d9161affe (diff)
parentd1d7fb1ae53a02f5073a7cf0ab1497aaa9617ebe (diff)
downloadrust-b2c20b51ed838368d3f2bdccb63f401bcddb7e1c.tar.gz
rust-b2c20b51ed838368d3f2bdccb63f401bcddb7e1c.zip
Auto merge of #84295 - richkadel:continue-coverage, r=tmandry
Add coverage to continue statements

`continue` statements were missing coverage. This was particularly
noticeable in a match pattern that contained only a `continue`
statement, leaving the branch appear uncounted. This PR addresses the
problem and adds tests to prove it.

r? `@tmandry`
cc: `@wesleywiser`
Diffstat (limited to 'src/test/run-make-fulldeps/coverage/continue.rs')
-rw-r--r--src/test/run-make-fulldeps/coverage/continue.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/coverage/continue.rs b/src/test/run-make-fulldeps/coverage/continue.rs
new file mode 100644
index 00000000000..624aa98341b
--- /dev/null
+++ b/src/test/run-make-fulldeps/coverage/continue.rs
@@ -0,0 +1,69 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+    let is_true = std::env::args().len() == 1;
+
+    let mut x = 0;
+    for _ in 0..10 {
+        match is_true {
+            true => {
+                continue;
+            }
+            _ => {
+                x = 1;
+            }
+        }
+        x = 3;
+    }
+    for _ in 0..10 {
+        match is_true {
+            false => {
+                x = 1;
+            }
+            _ => {
+                continue;
+            }
+        }
+        x = 3;
+    }
+    for _ in 0..10 {
+        match is_true {
+            true => {
+                x = 1;
+            }
+            _ => {
+                continue;
+            }
+        }
+        x = 3;
+    }
+    for _ in 0..10 {
+        if is_true {
+            continue;
+        }
+        x = 3;
+    }
+    for _ in 0..10 {
+        match is_true {
+            false => {
+                x = 1;
+            }
+            _ => {
+                let _ = x;
+            }
+        }
+        x = 3;
+    }
+    for _ in 0..10 {
+        match is_true {
+            false => {
+                x = 1;
+            }
+            _ => {
+                break;
+            }
+        }
+        x = 3;
+    }
+    let _ = x;
+}