summaryrefslogtreecommitdiffstats
path: root/tests/coverage-map/status-quo
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/coverage-map/status-quo
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/coverage-map/status-quo/abort.cov-map57
-rw-r--r--tests/coverage-map/status-quo/abort.rs66
-rw-r--r--tests/coverage-map/status-quo/assert.cov-map40
-rw-r--r--tests/coverage-map/status-quo/assert.rs32
-rw-r--r--tests/coverage-map/status-quo/async.cov-map340
-rw-r--r--tests/coverage-map/status-quo/async.rs128
-rw-r--r--tests/coverage-map/status-quo/async2.cov-map136
-rw-r--r--tests/coverage-map/status-quo/async2.rs57
-rw-r--r--tests/coverage-map/status-quo/closure.cov-map324
-rw-r--r--tests/coverage-map/status-quo/closure.rs220
-rw-r--r--tests/coverage-map/status-quo/closure_bug.cov-map148
-rw-r--r--tests/coverage-map/status-quo/closure_bug.rs44
-rw-r--r--tests/coverage-map/status-quo/closure_macro.cov-map40
-rw-r--r--tests/coverage-map/status-quo/closure_macro.rs40
-rw-r--r--tests/coverage-map/status-quo/closure_macro_async.cov-map48
-rw-r--r--tests/coverage-map/status-quo/closure_macro_async.rs77
-rw-r--r--tests/coverage-map/status-quo/conditions.cov-map261
-rw-r--r--tests/coverage-map/status-quo/conditions.rs86
-rw-r--r--tests/coverage-map/status-quo/continue.cov-map85
-rw-r--r--tests/coverage-map/status-quo/continue.rs69
-rw-r--r--tests/coverage-map/status-quo/dead_code.cov-map37
-rw-r--r--tests/coverage-map/status-quo/dead_code.rs37
-rw-r--r--tests/coverage-map/status-quo/drop_trait.cov-map21
-rw-r--r--tests/coverage-map/status-quo/drop_trait.rs33
-rw-r--r--tests/coverage-map/status-quo/generator.cov-map58
-rw-r--r--tests/coverage-map/status-quo/generator.rs30
-rw-r--r--tests/coverage-map/status-quo/generics.cov-map45
-rw-r--r--tests/coverage-map/status-quo/generics.rs44
-rw-r--r--tests/coverage-map/status-quo/if.cov-map15
-rw-r--r--tests/coverage-map/status-quo/if.rs28
-rw-r--r--tests/coverage-map/status-quo/if_else.cov-map25
-rw-r--r--tests/coverage-map/status-quo/if_else.rs40
-rw-r--r--tests/coverage-map/status-quo/inline-dead.cov-map45
-rw-r--r--tests/coverage-map/status-quo/inline-dead.rs27
-rw-r--r--tests/coverage-map/status-quo/inline.cov-map82
-rw-r--r--tests/coverage-map/status-quo/inline.rs51
-rw-r--r--tests/coverage-map/status-quo/inner_items.cov-map49
-rw-r--r--tests/coverage-map/status-quo/inner_items.rs57
-rw-r--r--tests/coverage-map/status-quo/issue-83601.cov-map28
-rw-r--r--tests/coverage-map/status-quo/issue-83601.rs14
-rw-r--r--tests/coverage-map/status-quo/issue-84561.cov-map233
-rw-r--r--tests/coverage-map/status-quo/issue-84561.rs182
-rw-r--r--tests/coverage-map/status-quo/issue-93054.cov-map24
-rw-r--r--tests/coverage-map/status-quo/issue-93054.rs30
-rw-r--r--tests/coverage-map/status-quo/lazy_boolean.cov-map223
-rw-r--r--tests/coverage-map/status-quo/lazy_boolean.rs61
-rw-r--r--tests/coverage-map/status-quo/loop_break_value.cov-map8
-rw-r--r--tests/coverage-map/status-quo/loop_break_value.rs13
-rw-r--r--tests/coverage-map/status-quo/loops_branches.cov-map185
-rw-r--r--tests/coverage-map/status-quo/loops_branches.rs60
-rw-r--r--tests/coverage-map/status-quo/match_or_pattern.cov-map83
-rw-r--r--tests/coverage-map/status-quo/match_or_pattern.rs43
-rw-r--r--tests/coverage-map/status-quo/nested_loops.cov-map51
-rw-r--r--tests/coverage-map/status-quo/nested_loops.rs25
-rw-r--r--tests/coverage-map/status-quo/no_cov_crate.cov-map78
-rw-r--r--tests/coverage-map/status-quo/no_cov_crate.rs88
-rw-r--r--tests/coverage-map/status-quo/overflow.cov-map43
-rw-r--r--tests/coverage-map/status-quo/overflow.rs63
-rw-r--r--tests/coverage-map/status-quo/panic_unwind.cov-map40
-rw-r--r--tests/coverage-map/status-quo/panic_unwind.rs31
-rw-r--r--tests/coverage-map/status-quo/partial_eq.cov-map64
-rw-r--r--tests/coverage-map/status-quo/partial_eq.rs46
-rw-r--r--tests/coverage-map/status-quo/simple_loop.cov-map28
-rw-r--r--tests/coverage-map/status-quo/simple_loop.rs35
-rw-r--r--tests/coverage-map/status-quo/simple_match.cov-map36
-rw-r--r--tests/coverage-map/status-quo/simple_match.rs43
-rw-r--r--tests/coverage-map/status-quo/sort_groups.cov-map68
-rw-r--r--tests/coverage-map/status-quo/sort_groups.rs23
-rw-r--r--tests/coverage-map/status-quo/test_harness.cov-map24
-rw-r--r--tests/coverage-map/status-quo/test_harness.rs10
-rw-r--r--tests/coverage-map/status-quo/tight_inf_loop.cov-map12
-rw-r--r--tests/coverage-map/status-quo/tight_inf_loop.rs5
-rw-r--r--tests/coverage-map/status-quo/try_error_result.cov-map226
-rw-r--r--tests/coverage-map/status-quo/try_error_result.rs118
-rw-r--r--tests/coverage-map/status-quo/unused.cov-map94
-rw-r--r--tests/coverage-map/status-quo/unused.rs41
-rw-r--r--tests/coverage-map/status-quo/while.cov-map15
-rw-r--r--tests/coverage-map/status-quo/while.rs5
-rw-r--r--tests/coverage-map/status-quo/while_early_ret.cov-map26
-rw-r--r--tests/coverage-map/status-quo/while_early_ret.rs42
-rw-r--r--tests/coverage-map/status-quo/yield.cov-map72
-rw-r--r--tests/coverage-map/status-quo/yield.rs37
82 files changed, 5698 insertions, 0 deletions
diff --git a/tests/coverage-map/status-quo/abort.cov-map b/tests/coverage-map/status-quo/abort.cov-map
new file mode 100644
index 000000000..45d3795ef
--- /dev/null
+++ b/tests/coverage-map/status-quo/abort.cov-map
@@ -0,0 +1,57 @@
+Function name: abort::main
+Raw bytes (105): 0x[01, 01, 12, 01, 47, 05, 09, 03, 0d, 42, 11, 03, 0d, 11, 3e, 42, 11, 03, 0d, 3b, 15, 11, 3e, 42, 11, 03, 0d, 15, 36, 3b, 15, 11, 3e, 42, 11, 03, 0d, 05, 09, 0d, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 42, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 3e, 02, 0a, 00, 0b, 3b, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 36, 00, 31, 00, 32, 33, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 31, 00, 32, 47, 01, 09, 00, 17, 0d, 02, 05, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 18
+- expression 0 operands: lhs = Counter(0), rhs = Expression(17, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(16, Sub), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 5 operands: lhs = Counter(4), rhs = Expression(15, Sub)
+- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(4)
+- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 8 operands: lhs = Expression(14, Add), rhs = Counter(5)
+- expression 9 operands: lhs = Counter(4), rhs = Expression(15, Sub)
+- expression 10 operands: lhs = Expression(16, Sub), rhs = Counter(4)
+- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 12 operands: lhs = Counter(5), rhs = Expression(13, Sub)
+- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(5)
+- expression 14 operands: lhs = Counter(4), rhs = Expression(15, Sub)
+- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(4)
+- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 17 operands: lhs = Counter(1), rhs = Counter(2)
+Number of file 0 mappings: 13
+- Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24)
+ = (c0 + (c1 + c2))
+- Code(Expression(16, Sub)) at (prev + 1, 12) to (start + 0, 25)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(4)) at (prev + 0, 26) to (start + 2, 10)
+- Code(Expression(15, Sub)) at (prev + 2, 10) to (start + 0, 11)
+ = (((c0 + (c1 + c2)) - c3) - c4)
+- Code(Expression(14, Add)) at (prev + 2, 12) to (start + 0, 25)
+ = (c4 + (((c0 + (c1 + c2)) - c3) - c4))
+- Code(Counter(5)) at (prev + 0, 26) to (start + 0, 49)
+- Code(Expression(13, Sub)) at (prev + 0, 49) to (start + 0, 50)
+ = ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5)
+- Code(Expression(12, Add)) at (prev + 4, 12) to (start + 0, 25)
+ = (c5 + ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5))
+- Code(Counter(1)) at (prev + 0, 26) to (start + 0, 49)
+- Code(Counter(2)) at (prev + 0, 49) to (start + 0, 50)
+- Code(Expression(17, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (c1 + c2)
+- Code(Counter(3)) at (prev + 2, 5) to (start + 1, 2)
+
+Function name: abort::might_abort
+Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 01, 14, 05, 02, 09, 01, 24, 02, 02, 0c, 03, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20)
+- Code(Counter(1)) at (prev + 2, 9) to (start + 1, 36)
+- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 3, 2)
+ = (c0 - c1)
+
diff --git a/tests/coverage-map/status-quo/abort.rs b/tests/coverage-map/status-quo/abort.rs
new file mode 100644
index 000000000..98264bdc1
--- /dev/null
+++ b/tests/coverage-map/status-quo/abort.rs
@@ -0,0 +1,66 @@
+#![feature(c_unwind)]
+#![allow(unused_assignments)]
+
+extern "C" fn might_abort(should_abort: bool) {
+ if should_abort {
+ println!("aborting...");
+ panic!("panics and aborts");
+ } else {
+ println!("Don't Panic");
+ }
+}
+
+fn main() -> Result<(), u8> {
+ let mut countdown = 10;
+ while countdown > 0 {
+ if countdown < 5 {
+ might_abort(false);
+ }
+ // See discussion (below the `Notes` section) on coverage results for the closing brace.
+ if countdown < 5 { might_abort(false); } // Counts for different regions on one line.
+ // For the following example, the closing brace is the last character on the line.
+ // This shows the character after the closing brace is highlighted, even if that next
+ // character is a newline.
+ if countdown < 5 { might_abort(false); }
+ countdown -= 1;
+ }
+ Ok(())
+}
+
+// Notes:
+// 1. Compare this program and its coverage results to those of the similar tests
+// `panic_unwind.rs` and `try_error_result.rs`.
+// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`.
+// 3. The test does not invoke the abort. By executing to a successful completion, the coverage
+// results show where the program did and did not execute.
+// 4. If the program actually aborted, the coverage counters would not be saved (which "works as
+// intended"). Coverage results would show no executed coverage regions.
+// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status
+// (on Linux at least).
+
+/*
+
+Expect the following coverage results:
+
+```text
+ 16| 11| while countdown > 0 {
+ 17| 10| if countdown < 5 {
+ 18| 4| might_abort(false);
+ 19| 6| }
+```
+
+This is actually correct.
+
+The condition `countdown < 5` executed 10 times (10 loop iterations).
+
+It evaluated to `true` 4 times, and executed the `might_abort()` call.
+
+It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit
+`else`, the coverage implementation injects a counter, at the character immediately after the `if`s
+closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the
+non-true condition.
+
+As another example of why this is important, say the condition was `countdown < 50`, which is always
+`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called.
+The closing brace would have a count of `0`, highlighting the missed coverage.
+*/
diff --git a/tests/coverage-map/status-quo/assert.cov-map b/tests/coverage-map/status-quo/assert.cov-map
new file mode 100644
index 000000000..dd413123d
--- /dev/null
+++ b/tests/coverage-map/status-quo/assert.cov-map
@@ -0,0 +1,40 @@
+Function name: assert::main
+Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 09, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 8
+- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1)
+- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 7 operands: lhs = Counter(2), rhs = Counter(3)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 9, 1) to (start + 1, 27)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24)
+ = (c0 + (c1 + (c2 + c3)))
+- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26)
+ = ((c0 + (c1 + (c2 + c3))) - c4)
+- Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10)
+- Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32)
+ = (((c0 + (c1 + (c2 + c3))) - c4) - c1)
+- Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10)
+- Code(Counter(3)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (c1 + (c2 + c3))
+- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2)
+
+Function name: assert::might_fail_assert
+Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 02, 0f, 02, 02, 25, 00, 3d, 05, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 15)
+- Code(Expression(0, Sub)) at (prev + 2, 37) to (start + 0, 61)
+ = (c0 - c1)
+- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
+
diff --git a/tests/coverage-map/status-quo/assert.rs b/tests/coverage-map/status-quo/assert.rs
new file mode 100644
index 000000000..85e6662a6
--- /dev/null
+++ b/tests/coverage-map/status-quo/assert.rs
@@ -0,0 +1,32 @@
+#![allow(unused_assignments)]
+// failure-status: 101
+
+fn might_fail_assert(one_plus_one: u32) {
+ println!("does 1 + 1 = {}?", one_plus_one);
+ assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
+}
+
+fn main() -> Result<(), u8> {
+ let mut countdown = 10;
+ while countdown > 0 {
+ if countdown == 1 {
+ might_fail_assert(3);
+ } else if countdown < 5 {
+ might_fail_assert(2);
+ }
+ countdown -= 1;
+ }
+ Ok(())
+}
+
+// Notes:
+// 1. Compare this program and its coverage results to those of the very similar test
+// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`.
+// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or
+// related `assert_*!()` macro.
+// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce
+// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to
+// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails).
+// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test
+// (and in many other coverage tests). The `Assert` terminator is typically generated by the
+// Rust compiler to check for runtime failures, such as numeric overflows.
diff --git a/tests/coverage-map/status-quo/async.cov-map b/tests/coverage-map/status-quo/async.cov-map
new file mode 100644
index 000000000..5f28252ef
--- /dev/null
+++ b/tests/coverage-map/status-quo/async.cov-map
@@ -0,0 +1,340 @@
+Function name: async::c
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 00, 19]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 25)
+
+Function name: async::c::{closure#0}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 5, 25) to (start + 1, 14)
+- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 10)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: async::d
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 14]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 20)
+
+Function name: async::d::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 14, 00, 19]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 13, 20) to (start + 0, 25)
+
+Function name: async::e (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 01, 00, 14]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 15, 1) to (start + 0, 20)
+
+Function name: async::e::{closure#0} (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 14, 00, 19]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 15, 20) to (start + 0, 25)
+
+Function name: async::executor::block_on::<core::pin::Pin<&mut async::i::{closure#0}>>
+Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 6e, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 110, 5) to (start + 10, 54)
+- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
+ = ((c0 + c1) - c1)
+- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
+ = (c0 + c1)
+- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26)
+ = (((c0 + c1) - c1) + Zero)
+- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
+- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (((c0 + c1) - c1) + Zero)
+
+Function name: async::executor::block_on::VTABLE::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 51)
+
+Function name: async::executor::block_on::VTABLE::{closure#1}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 51)
+
+Function name: async::executor::block_on::VTABLE::{closure#2}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 51)
+
+Function name: async::executor::block_on::VTABLE::{closure#3}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 75, 11, 00, 13]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 117, 17) to (start + 0, 19)
+
+Function name: async::f
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 00, 14]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 17, 1) to (start + 0, 20)
+
+Function name: async::f::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 14, 00, 19]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 17, 20) to (start + 0, 25)
+
+Function name: async::foo (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 1e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 30)
+
+Function name: async::foo::{closure#0} (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 1e, 00, 2d]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 19, 30) to (start + 0, 45)
+
+Function name: async::g
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 17]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 23)
+
+Function name: async::g::{closure#0} (unused)
+Raw bytes (69): 0x[01, 01, 00, 0d, 00, 15, 17, 01, 0c, 00, 02, 09, 00, 0a, 01, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 13
+- Code(Zero) at (prev + 21, 23) to (start + 1, 12)
+- Code(Zero) at (prev + 2, 9) to (start + 0, 10)
+- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17)
+- Code(Zero) at (prev + 0, 18) to (start + 0, 23)
+- Code(Zero) at (prev + 0, 27) to (start + 0, 28)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 34)
+- Code(Zero) at (prev + 1, 9) to (start + 0, 10)
+- Code(Zero) at (prev + 0, 14) to (start + 0, 17)
+- Code(Zero) at (prev + 0, 18) to (start + 0, 23)
+- Code(Zero) at (prev + 0, 27) to (start + 0, 28)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 34)
+- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
+- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
+
+Function name: async::h
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 00, 16]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 29, 1) to (start + 0, 22)
+
+Function name: async::h::{closure#0} (unused)
+Raw bytes (44): 0x[01, 01, 00, 08, 00, 1d, 16, 03, 0c, 00, 04, 09, 00, 0a, 01, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 8
+- Code(Zero) at (prev + 29, 22) to (start + 3, 12)
+- Code(Zero) at (prev + 4, 9) to (start + 0, 10)
+- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 19)
+- Code(Zero) at (prev + 0, 20) to (start + 0, 25)
+- Code(Zero) at (prev + 0, 26) to (start + 0, 27)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 34)
+- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
+- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
+
+Function name: async::i
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 01, 00, 13]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 38, 1) to (start + 0, 19)
+
+Function name: async::i::{closure#0}
+Raw bytes (84): 0x[01, 01, 05, 01, 00, 0d, 00, 1d, 00, 19, 13, 1d, 21, 0e, 01, 26, 13, 04, 0c, 0d, 05, 09, 00, 0a, 03, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 07, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 0b, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 0f, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(3), rhs = Zero
+- expression 2 operands: lhs = Counter(7), rhs = Zero
+- expression 3 operands: lhs = Counter(6), rhs = Expression(4, Add)
+- expression 4 operands: lhs = Counter(7), rhs = Counter(8)
+Number of file 0 mappings: 14
+- Code(Counter(0)) at (prev + 38, 19) to (start + 4, 12)
+- Code(Counter(3)) at (prev + 5, 9) to (start + 0, 10)
+- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 18)
+ = (c0 + Zero)
+- Code(Counter(1)) at (prev + 0, 19) to (start + 0, 24)
+- Code(Counter(2)) at (prev + 0, 28) to (start + 0, 33)
+- Code(Expression(1, Add)) at (prev + 0, 39) to (start + 0, 42)
+ = (c3 + Zero)
+- Code(Counter(5)) at (prev + 0, 43) to (start + 0, 48)
+- Code(Counter(7)) at (prev + 1, 9) to (start + 0, 10)
+- Code(Counter(4)) at (prev + 0, 14) to (start + 0, 17)
+- Code(Counter(9)) at (prev + 0, 18) to (start + 0, 23)
+- Code(Counter(10)) at (prev + 0, 27) to (start + 0, 32)
+- Code(Expression(2, Add)) at (prev + 0, 36) to (start + 0, 38)
+ = (c7 + Zero)
+- Code(Counter(8)) at (prev + 1, 14) to (start + 0, 16)
+- Code(Expression(3, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c6 + (c7 + c8))
+
+Function name: async::j
+Raw bytes (59): 0x[01, 01, 05, 01, 00, 05, 00, 09, 00, 05, 13, 09, 0d, 09, 01, 31, 01, 13, 0c, 05, 14, 09, 00, 0a, 03, 00, 0e, 00, 1b, 07, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 0b, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 0f, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(1), rhs = Zero
+- expression 2 operands: lhs = Counter(2), rhs = Zero
+- expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add)
+- expression 4 operands: lhs = Counter(2), rhs = Counter(3)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 49, 1) to (start + 19, 12)
+- Code(Counter(1)) at (prev + 20, 9) to (start + 0, 10)
+- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 27)
+ = (c0 + Zero)
+- Code(Expression(1, Add)) at (prev + 0, 31) to (start + 0, 39)
+ = (c1 + Zero)
+- Code(Counter(2)) at (prev + 1, 9) to (start + 0, 10)
+- Code(Counter(4)) at (prev + 0, 14) to (start + 0, 26)
+- Code(Expression(2, Add)) at (prev + 0, 30) to (start + 0, 32)
+ = (c2 + Zero)
+- Code(Counter(3)) at (prev + 1, 14) to (start + 0, 16)
+- Code(Expression(3, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c1 + (c2 + c3))
+
+Function name: async::j::c
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 18)
+- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 14)
+- Code(Expression(0, Sub)) at (prev + 10, 13) to (start + 0, 14)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (c1 + (c0 - c1))
+
+Function name: async::j::d
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 42, 05, 00, 17]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 66, 5) to (start + 0, 23)
+
+Function name: async::j::f
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 43, 05, 00, 17]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 67, 5) to (start + 0, 23)
+
+Function name: async::k (unused)
+Raw bytes (29): 0x[01, 01, 00, 05, 01, 4b, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 5
+- Code(Counter(0)) at (prev + 75, 1) to (start + 1, 12)
+- Code(Zero) at (prev + 2, 14) to (start + 0, 16)
+- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
+- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
+- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
+
+Function name: async::l
+Raw bytes (37): 0x[01, 01, 04, 01, 07, 09, 05, 09, 0f, 05, 02, 05, 01, 53, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
+- expression 1 operands: lhs = Counter(2), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(2), rhs = Expression(3, Add)
+- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 5
+- Code(Counter(0)) at (prev + 83, 1) to (start + 1, 12)
+- Code(Expression(0, Sub)) at (prev + 2, 14) to (start + 0, 16)
+ = (c0 - (c2 + c1))
+- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16)
+- Code(Counter(2)) at (prev + 1, 14) to (start + 0, 16)
+- Code(Expression(2, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c2 + (c1 + (c0 - (c2 + c1))))
+
+Function name: async::m
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 01, 00, 19]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 91, 1) to (start + 0, 25)
+
+Function name: async::m::{closure#0} (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 19, 00, 22]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 91, 25) to (start + 0, 34)
+
+Function name: async::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 08, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 93, 1) to (start + 8, 2)
+
diff --git a/tests/coverage-map/status-quo/async.rs b/tests/coverage-map/status-quo/async.rs
new file mode 100644
index 000000000..efd9e62d6
--- /dev/null
+++ b/tests/coverage-map/status-quo/async.rs
@@ -0,0 +1,128 @@
+#![allow(unused_assignments, dead_code)]
+
+// compile-flags: --edition=2018 -C opt-level=1
+
+async fn c(x: u8) -> u8 {
+ if x == 8 {
+ 1
+ } else {
+ 0
+ }
+}
+
+async fn d() -> u8 { 1 }
+
+async fn e() -> u8 { 1 } // unused function; executor does not block on `g()`
+
+async fn f() -> u8 { 1 }
+
+async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()`
+
+pub async fn g(x: u8) {
+ match x {
+ y if e().await == y => (),
+ y if f().await == y => (),
+ _ => (),
+ }
+}
+
+async fn h(x: usize) { // The function signature is counted when called, but the body is not
+ // executed (not awaited) so the open brace has a `0` count (at least when
+ // displayed with `llvm-cov show` in color-mode).
+ match x {
+ y if foo().await[y] => (),
+ _ => (),
+ }
+}
+
+async fn i(x: u8) { // line coverage is 1, but there are 2 regions:
+ // (a) the function signature, counted when the function is called; and
+ // (b) the open brace for the function body, counted once when the body is
+ // executed asynchronously.
+ match x {
+ y if c(x).await == y + 1 => { d().await; }
+ y if f().await == y + 1 => (),
+ _ => (),
+ }
+}
+
+fn j(x: u8) {
+ // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`.
+ fn c(x: u8) -> u8 {
+ if x == 8 {
+ 1 // This line appears covered, but the 1-character expression span covering the `1`
+ // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because
+ // `fn j()` executes the open brace for the function body, followed by the function's
+ // first executable statement, `match x`. Inner function declarations are not
+ // "visible" to the MIR for `j()`, so the code region counts all lines between the
+ // open brace and the first statement as executed, which is, in a sense, true.
+ // `llvm-cov show` overcomes this kind of situation by showing the actual counts
+ // of the enclosed coverages, (that is, the `1` expression was not executed, and
+ // accurately displays a `0`).
+ } else {
+ 0
+ }
+ }
+ fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed
+ fn f() -> u8 { 1 }
+ match x {
+ y if c(x) == y + 1 => { d(); }
+ y if f() == y + 1 => (),
+ _ => (),
+ }
+}
+
+fn k(x: u8) { // unused function
+ match x {
+ 1 => (),
+ 2 => (),
+ _ => (),
+ }
+}
+
+fn l(x: u8) {
+ match x {
+ 1 => (),
+ 2 => (),
+ _ => (),
+ }
+}
+
+async fn m(x: u8) -> u8 { x - 1 }
+
+fn main() {
+ let _ = g(10);
+ let _ = h(9);
+ let mut future = Box::pin(i(8));
+ j(7);
+ l(6);
+ let _ = m(5);
+ executor::block_on(future.as_mut());
+}
+
+mod executor {
+ use core::{
+ future::Future,
+ pin::Pin,
+ task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
+ };
+
+ pub fn block_on<F: Future>(mut future: F) -> F::Output {
+ let mut future = unsafe { Pin::new_unchecked(&mut future) };
+ use std::hint::unreachable_unchecked;
+ static VTABLE: RawWakerVTable = RawWakerVTable::new(
+ |_| unsafe { unreachable_unchecked() }, // clone
+ |_| unsafe { unreachable_unchecked() }, // wake
+ |_| unsafe { unreachable_unchecked() }, // wake_by_ref
+ |_| (),
+ );
+ let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
+ let mut context = Context::from_waker(&waker);
+
+ loop {
+ if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
+ break val;
+ }
+ }
+ }
+}
diff --git a/tests/coverage-map/status-quo/async2.cov-map b/tests/coverage-map/status-quo/async2.cov-map
new file mode 100644
index 000000000..fe74dcd88
--- /dev/null
+++ b/tests/coverage-map/status-quo/async2.cov-map
@@ -0,0 +1,136 @@
+Function name: async2::async_func
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 01, 00, 17]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 23)
+
+Function name: async2::async_func::{closure#0}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 11, 23) to (start + 3, 9)
+- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: async2::async_func_just_println
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 24]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 36)
+
+Function name: async2::async_func_just_println::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 24, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 19, 36) to (start + 2, 2)
+
+Function name: async2::executor::block_on::<async2::async_func::{closure#0}>
+Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54)
+- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
+ = ((c0 + c1) - c1)
+- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
+ = (c0 + c1)
+- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26)
+ = (((c0 + c1) - c1) + Zero)
+- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
+- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (((c0 + c1) - c1) + Zero)
+
+Function name: async2::executor::block_on::<async2::async_func_just_println::{closure#0}>
+Raw bytes (44): 0x[01, 01, 05, 0b, 05, 01, 05, 01, 05, 02, 00, 02, 00, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 0f, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 13, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 4 operands: lhs = Expression(0, Sub), rhs = Zero
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54)
+- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
+ = ((c0 + c1) - c1)
+- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
+ = (c0 + c1)
+- Code(Expression(3, Add)) at (prev + 1, 23) to (start + 0, 26)
+ = (((c0 + c1) - c1) + Zero)
+- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
+- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (((c0 + c1) - c1) + Zero)
+
+Function name: async2::executor::block_on::VTABLE::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 51)
+
+Function name: async2::executor::block_on::VTABLE::{closure#1}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 51)
+
+Function name: async2::executor::block_on::VTABLE::{closure#2}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 33]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 51)
+
+Function name: async2::executor::block_on::VTABLE::{closure#3}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2e, 11, 00, 13]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 46, 17) to (start + 0, 19)
+
+Function name: async2::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 07, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 23, 1) to (start + 7, 2)
+
+Function name: async2::non_async_func
+Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 03, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(1), rhs = Zero
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 9)
+- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + Zero)
+
diff --git a/tests/coverage-map/status-quo/async2.rs b/tests/coverage-map/status-quo/async2.rs
new file mode 100644
index 000000000..2884ff297
--- /dev/null
+++ b/tests/coverage-map/status-quo/async2.rs
@@ -0,0 +1,57 @@
+// compile-flags: --edition=2018
+
+fn non_async_func() {
+ println!("non_async_func was covered");
+ let b = true;
+ if b {
+ println!("non_async_func println in block");
+ }
+}
+
+async fn async_func() {
+ println!("async_func was covered");
+ let b = true;
+ if b {
+ println!("async_func println in block");
+ }
+}
+
+async fn async_func_just_println() {
+ println!("async_func_just_println was covered");
+}
+
+fn main() {
+ println!("codecovsample::main");
+
+ non_async_func();
+
+ executor::block_on(async_func());
+ executor::block_on(async_func_just_println());
+}
+
+mod executor {
+ use core::{
+ future::Future,
+ pin::Pin,
+ task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
+ };
+
+ pub fn block_on<F: Future>(mut future: F) -> F::Output {
+ let mut future = unsafe { Pin::new_unchecked(&mut future) };
+ use std::hint::unreachable_unchecked;
+ static VTABLE: RawWakerVTable = RawWakerVTable::new(
+ |_| unsafe { unreachable_unchecked() }, // clone
+ |_| unsafe { unreachable_unchecked() }, // wake
+ |_| unsafe { unreachable_unchecked() }, // wake_by_ref
+ |_| (),
+ );
+ let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
+ let mut context = Context::from_waker(&waker);
+
+ loop {
+ if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
+ break val;
+ }
+ }
+ }
+}
diff --git a/tests/coverage-map/status-quo/closure.cov-map b/tests/coverage-map/status-quo/closure.cov-map
new file mode 100644
index 000000000..7dbf6ec83
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure.cov-map
@@ -0,0 +1,324 @@
+Function name: closure::main
+Raw bytes (170): 0x[01, 01, 17, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 00, 01, 05, 05, 5a, 01, 05, 18, 01, 08, 01, 0f, 0d, 03, 16, 0e, 06, 0a, 07, 10, 05, 13, 0d, 0b, 1a, 0e, 06, 0a, 0f, 10, 05, 0c, 16, 13, 16, 05, 0d, 18, 17, 19, 09, 01, 1e, 1b, 04, 09, 00, 29, 1f, 01, 09, 00, 2d, 23, 01, 09, 00, 24, 27, 05, 09, 00, 24, 2b, 02, 09, 00, 21, 2f, 04, 09, 00, 21, 33, 04, 09, 00, 28, 37, 09, 09, 00, 32, 3b, 04, 09, 00, 33, 3f, 07, 09, 00, 4b, 43, 08, 09, 00, 48, 47, 0a, 09, 00, 47, 4b, 08, 09, 00, 44, 4f, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 5a, 04, 06, 00, 07, 57, 01, 05, 03, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 23
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(0), rhs = Zero
+- expression 2 operands: lhs = Counter(0), rhs = Zero
+- expression 3 operands: lhs = Counter(0), rhs = Zero
+- expression 4 operands: lhs = Counter(0), rhs = Zero
+- expression 5 operands: lhs = Counter(0), rhs = Zero
+- expression 6 operands: lhs = Counter(0), rhs = Zero
+- expression 7 operands: lhs = Counter(0), rhs = Zero
+- expression 8 operands: lhs = Counter(0), rhs = Zero
+- expression 9 operands: lhs = Counter(0), rhs = Zero
+- expression 10 operands: lhs = Counter(0), rhs = Zero
+- expression 11 operands: lhs = Counter(0), rhs = Zero
+- expression 12 operands: lhs = Counter(0), rhs = Zero
+- expression 13 operands: lhs = Counter(0), rhs = Zero
+- expression 14 operands: lhs = Counter(0), rhs = Zero
+- expression 15 operands: lhs = Counter(0), rhs = Zero
+- expression 16 operands: lhs = Counter(0), rhs = Zero
+- expression 17 operands: lhs = Counter(0), rhs = Zero
+- expression 18 operands: lhs = Counter(0), rhs = Zero
+- expression 19 operands: lhs = Counter(0), rhs = Zero
+- expression 20 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 21 operands: lhs = Counter(1), rhs = Expression(22, Sub)
+- expression 22 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 24
+- Code(Counter(0)) at (prev + 8, 1) to (start + 15, 13)
+- Code(Expression(0, Add)) at (prev + 22, 14) to (start + 6, 10)
+ = (c0 + Zero)
+- Code(Expression(1, Add)) at (prev + 16, 5) to (start + 19, 13)
+ = (c0 + Zero)
+- Code(Expression(2, Add)) at (prev + 26, 14) to (start + 6, 10)
+ = (c0 + Zero)
+- Code(Expression(3, Add)) at (prev + 16, 5) to (start + 12, 22)
+ = (c0 + Zero)
+- Code(Expression(4, Add)) at (prev + 22, 5) to (start + 13, 24)
+ = (c0 + Zero)
+- Code(Expression(5, Add)) at (prev + 25, 9) to (start + 1, 30)
+ = (c0 + Zero)
+- Code(Expression(6, Add)) at (prev + 4, 9) to (start + 0, 41)
+ = (c0 + Zero)
+- Code(Expression(7, Add)) at (prev + 1, 9) to (start + 0, 45)
+ = (c0 + Zero)
+- Code(Expression(8, Add)) at (prev + 1, 9) to (start + 0, 36)
+ = (c0 + Zero)
+- Code(Expression(9, Add)) at (prev + 5, 9) to (start + 0, 36)
+ = (c0 + Zero)
+- Code(Expression(10, Add)) at (prev + 2, 9) to (start + 0, 33)
+ = (c0 + Zero)
+- Code(Expression(11, Add)) at (prev + 4, 9) to (start + 0, 33)
+ = (c0 + Zero)
+- Code(Expression(12, Add)) at (prev + 4, 9) to (start + 0, 40)
+ = (c0 + Zero)
+- Code(Expression(13, Add)) at (prev + 9, 9) to (start + 0, 50)
+ = (c0 + Zero)
+- Code(Expression(14, Add)) at (prev + 4, 9) to (start + 0, 51)
+ = (c0 + Zero)
+- Code(Expression(15, Add)) at (prev + 7, 9) to (start + 0, 75)
+ = (c0 + Zero)
+- Code(Expression(16, Add)) at (prev + 8, 9) to (start + 0, 72)
+ = (c0 + Zero)
+- Code(Expression(17, Add)) at (prev + 10, 9) to (start + 0, 71)
+ = (c0 + Zero)
+- Code(Expression(18, Add)) at (prev + 8, 9) to (start + 0, 68)
+ = (c0 + Zero)
+- Code(Expression(19, Add)) at (prev + 10, 8) to (start + 0, 16)
+ = (c0 + Zero)
+- Code(Counter(1)) at (prev + 0, 17) to (start + 4, 6)
+- Code(Expression(22, Sub)) at (prev + 4, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(21, Add)) at (prev + 1, 5) to (start + 3, 2)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#0}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 27, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 39, 5) to (start + 2, 20)
+- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10)
+- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#10} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 9a, 01, 07, 00, 21]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 154, 7) to (start + 0, 33)
+
+Function name: closure::main::{closure#11} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 9e, 01, 07, 00, 21]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 158, 7) to (start + 0, 33)
+
+Function name: closure::main::{closure#12} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, a6, 01, 01, 00, 17]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 166, 1) to (start + 0, 23)
+
+Function name: closure::main::{closure#13} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, ab, 01, 0d, 02, 0e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 171, 13) to (start + 2, 14)
+
+Function name: closure::main::{closure#14}
+Raw bytes (38): 0x[01, 01, 04, 05, 0a, 01, 05, 01, 05, 03, 00, 05, 03, b2, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 0f, 01, 0d, 00, 0e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Zero
+Number of file 0 mappings: 5
+- Code(Expression(0, Add)) at (prev + 178, 13) to (start + 0, 21)
+ = (c1 + (c0 - c1))
+- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27)
+- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37)
+- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51)
+ = (c0 - c1)
+- Code(Expression(3, Add)) at (prev + 1, 13) to (start + 0, 14)
+ = ((c1 + (c0 - c1)) + Zero)
+
+Function name: closure::main::{closure#15}
+Raw bytes (45): 0x[01, 01, 05, 05, 0e, 01, 05, 01, 00, 01, 05, 03, 00, 06, 01, ba, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 0b, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0e, 00, 2f, 00, 33, 13, 02, 09, 00, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(1), rhs = Expression(3, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Zero
+- expression 3 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 4 operands: lhs = Expression(0, Add), rhs = Zero
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 186, 9) to (start + 0, 10)
+- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21)
+ = (c1 + (c0 - c1))
+- Code(Expression(2, Add)) at (prev + 1, 17) to (start + 1, 27)
+ = (c0 + Zero)
+- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37)
+- Code(Expression(3, Sub)) at (prev + 0, 47) to (start + 0, 51)
+ = (c0 - c1)
+- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = ((c1 + (c0 - c1)) + Zero)
+
+Function name: closure::main::{closure#16}
+Raw bytes (38): 0x[01, 01, 04, 05, 0a, 01, 05, 01, 05, 03, 00, 05, 03, c4, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 0f, 01, 0d, 00, 0e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Zero
+Number of file 0 mappings: 5
+- Code(Expression(0, Add)) at (prev + 196, 13) to (start + 0, 21)
+ = (c1 + (c0 - c1))
+- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27)
+- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37)
+- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51)
+ = (c0 - c1)
+- Code(Expression(3, Add)) at (prev + 1, 13) to (start + 0, 14)
+ = ((c1 + (c0 - c1)) + Zero)
+
+Function name: closure::main::{closure#17}
+Raw bytes (45): 0x[01, 01, 05, 05, 0e, 01, 05, 01, 00, 01, 05, 03, 00, 06, 01, cc, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 0b, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0e, 00, 2f, 00, 33, 13, 02, 09, 00, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(1), rhs = Expression(3, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(0), rhs = Zero
+- expression 3 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 4 operands: lhs = Expression(0, Add), rhs = Zero
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 204, 9) to (start + 0, 10)
+- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21)
+ = (c1 + (c0 - c1))
+- Code(Expression(2, Add)) at (prev + 1, 17) to (start + 1, 27)
+ = (c0 + Zero)
+- Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37)
+- Code(Expression(3, Sub)) at (prev + 0, 47) to (start + 0, 51)
+ = (c0 - c1)
+- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = ((c1 + (c0 - c1)) + Zero)
+
+Function name: closure::main::{closure#18}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 18, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 24, 13) to (start + 2, 28)
+- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18)
+- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#19}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 42, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 66, 13) to (start + 2, 28)
+- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18)
+- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#1}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 51, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 81, 5) to (start + 2, 20)
+- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10)
+- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#2}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 67, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 103, 5) to (start + 2, 20)
+- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10)
+- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6)
+ = (c1 + (c0 - c1))
+
+Function name: closure::main::{closure#3} (unused)
+Raw bytes (25): 0x[01, 01, 00, 04, 01, 80, 01, 05, 01, 14, 00, 01, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 128, 5) to (start + 1, 20)
+- Code(Zero) at (prev + 1, 21) to (start + 2, 10)
+- Code(Zero) at (prev + 2, 10) to (start + 0, 11)
+- Code(Zero) at (prev + 1, 9) to (start + 1, 6)
+
+Function name: closure::main::{closure#4} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 88, 01, 35, 00, 43]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 136, 53) to (start + 0, 67)
+
+Function name: closure::main::{closure#5}
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 8b, 01, 3d, 00, 4f]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 139, 61) to (start + 0, 79)
+
+Function name: closure::main::{closure#6}
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 8c, 01, 41, 00, 57]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 140, 65) to (start + 0, 87)
+
+Function name: closure::main::{closure#7} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 8d, 01, 3b, 00, 51]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 141, 59) to (start + 0, 81)
+
+Function name: closure::main::{closure#8} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 92, 01, 3b, 00, 55]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 146, 59) to (start + 0, 85)
+
+Function name: closure::main::{closure#9} (unused)
+Raw bytes (10): 0x[01, 01, 00, 01, 01, 94, 01, 38, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 148, 56) to (start + 2, 6)
+
diff --git a/tests/coverage-map/status-quo/closure.rs b/tests/coverage-map/status-quo/closure.rs
new file mode 100644
index 000000000..16a2c4e33
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure.rs
@@ -0,0 +1,220 @@
+#![allow(unused_assignments, unused_variables)]
+// compile-flags: -C opt-level=2
+
+// This test used to be sensitive to certain coverage-specific hacks in
+// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by
+// <https://github.com/rust-lang/rust/pull/83666>.
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+ let is_false = !is_true;
+
+ let mut some_string = Some(String::from("the string content"));
+ println!(
+ "The string or alt: {}"
+ ,
+ some_string
+ .
+ unwrap_or_else
+ (
+ ||
+ {
+ let mut countdown = 0;
+ if is_false {
+ countdown = 10;
+ }
+ "alt string 1".to_owned()
+ }
+ )
+ );
+
+ some_string = Some(String::from("the string content"));
+ let
+ a
+ =
+ ||
+ {
+ let mut countdown = 0;
+ if is_false {
+ countdown = 10;
+ }
+ "alt string 2".to_owned()
+ };
+ println!(
+ "The string or alt: {}"
+ ,
+ some_string
+ .
+ unwrap_or_else
+ (
+ a
+ )
+ );
+
+ some_string = None;
+ println!(
+ "The string or alt: {}"
+ ,
+ some_string
+ .
+ unwrap_or_else
+ (
+ ||
+ {
+ let mut countdown = 0;
+ if is_false {
+ countdown = 10;
+ }
+ "alt string 3".to_owned()
+ }
+ )
+ );
+
+ some_string = None;
+ let
+ a
+ =
+ ||
+ {
+ let mut countdown = 0;
+ if is_false {
+ countdown = 10;
+ }
+ "alt string 4".to_owned()
+ };
+ println!(
+ "The string or alt: {}"
+ ,
+ some_string
+ .
+ unwrap_or_else
+ (
+ a
+ )
+ );
+
+ let
+ quote_closure
+ =
+ |val|
+ {
+ let mut countdown = 0;
+ if is_false {
+ countdown = 10;
+ }
+ format!("'{}'", val)
+ };
+ println!(
+ "Repeated, quoted string: {:?}"
+ ,
+ std::iter::repeat("repeat me")
+ .take(5)
+ .map
+ (
+ quote_closure
+ )
+ .collect::<Vec<_>>()
+ );
+
+ let
+ _unused_closure
+ =
+ |
+ mut countdown
+ |
+ {
+ if is_false {
+ countdown = 10;
+ }
+ "closure should be unused".to_owned()
+ };
+
+ let mut countdown = 10;
+ let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
+
+
+ let short_used_covered_closure_macro = | used_arg: u8 | println!("called");
+ let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called");
+ let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called");
+
+
+
+
+ let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
+
+ let _shortish_unused_closure = | _unused_arg: u8 | {
+ println!("not called")
+ };
+
+ let _as_short_unused_closure = |
+ _unused_arg: u8
+ | { println!("not called") };
+
+ let _almost_as_short_unused_closure = |
+ _unused_arg: u8
+ | { println!("not called") }
+ ;
+
+
+
+
+
+ let _short_unused_closure_line_break_no_block = | _unused_arg: u8 |
+println!("not called")
+ ;
+
+ let _short_unused_closure_line_break_no_block2 =
+ | _unused_arg: u8 |
+ println!(
+ "not called"
+ )
+ ;
+
+ let short_used_not_covered_closure_line_break_no_block_embedded_branch =
+ | _unused_arg: u8 |
+ println!(
+ "not called: {}",
+ if is_true { "check" } else { "me" }
+ )
+ ;
+
+ let short_used_not_covered_closure_line_break_block_embedded_branch =
+ | _unused_arg: u8 |
+ {
+ println!(
+ "not called: {}",
+ if is_true { "check" } else { "me" }
+ )
+ }
+ ;
+
+ let short_used_covered_closure_line_break_no_block_embedded_branch =
+ | _unused_arg: u8 |
+ println!(
+ "not called: {}",
+ if is_true { "check" } else { "me" }
+ )
+ ;
+
+ let short_used_covered_closure_line_break_block_embedded_branch =
+ | _unused_arg: u8 |
+ {
+ println!(
+ "not called: {}",
+ if is_true { "check" } else { "me" }
+ )
+ }
+ ;
+
+ if is_false {
+ short_used_not_covered_closure_macro(0);
+ short_used_not_covered_closure_line_break_no_block_embedded_branch(0);
+ short_used_not_covered_closure_line_break_block_embedded_branch(0);
+ }
+ short_used_covered_closure_macro(0);
+ short_used_covered_closure_line_break_no_block_embedded_branch(0);
+ short_used_covered_closure_line_break_block_embedded_branch(0);
+}
diff --git a/tests/coverage-map/status-quo/closure_bug.cov-map b/tests/coverage-map/status-quo/closure_bug.cov-map
new file mode 100644
index 000000000..4fe2e5ad2
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_bug.cov-map
@@ -0,0 +1,148 @@
+Function name: closure_bug::main
+Raw bytes (241): 0x[01, 01, 34, 01, 00, 01, 05, 05, ce, 01, 01, 05, cb, 01, 00, 05, ce, 01, 01, 05, cb, 01, 09, 05, ce, 01, 01, 05, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, c3, 01, 00, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, c3, 01, 0d, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, 0d, be, 01, c3, 01, 0d, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, bb, 01, 00, 0d, be, 01, c3, 01, 0d, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, bb, 01, 11, 0d, be, 01, c3, 01, 0d, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, 11, b6, 01, bb, 01, 11, 0d, be, 01, c3, 01, 0d, 09, c6, 01, cb, 01, 09, 05, ce, 01, 01, 05, 11, 01, 06, 01, 03, 0a, 03, 09, 05, 01, 0e, 05, 01, 0f, 00, 17, ce, 01, 00, 17, 00, 18, cb, 01, 02, 09, 00, 0a, 13, 06, 05, 01, 0e, 09, 01, 0f, 00, 17, c6, 01, 00, 17, 00, 18, c3, 01, 02, 09, 00, 0a, 3b, 06, 05, 01, 0e, 0d, 01, 0f, 00, 17, be, 01, 00, 17, 00, 18, bb, 01, 02, 09, 00, 0a, 7b, 06, 05, 01, 0e, 11, 01, 0f, 00, 17, b6, 01, 00, 17, 00, 18, b3, 01, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 52
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 3 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 4 operands: lhs = Expression(50, Add), rhs = Zero
+- expression 5 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 6 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 7 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 8 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 9 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 10 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 11 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 12 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 13 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 14 operands: lhs = Expression(48, Add), rhs = Zero
+- expression 15 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 16 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 17 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 18 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 19 operands: lhs = Expression(48, Add), rhs = Counter(3)
+- expression 20 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 21 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 22 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 23 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 24 operands: lhs = Counter(3), rhs = Expression(47, Sub)
+- expression 25 operands: lhs = Expression(48, Add), rhs = Counter(3)
+- expression 26 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 27 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 28 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 29 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 30 operands: lhs = Expression(46, Add), rhs = Zero
+- expression 31 operands: lhs = Counter(3), rhs = Expression(47, Sub)
+- expression 32 operands: lhs = Expression(48, Add), rhs = Counter(3)
+- expression 33 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 34 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 35 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 36 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 37 operands: lhs = Expression(46, Add), rhs = Counter(4)
+- expression 38 operands: lhs = Counter(3), rhs = Expression(47, Sub)
+- expression 39 operands: lhs = Expression(48, Add), rhs = Counter(3)
+- expression 40 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 41 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 42 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 43 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 44 operands: lhs = Counter(4), rhs = Expression(45, Sub)
+- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(4)
+- expression 46 operands: lhs = Counter(3), rhs = Expression(47, Sub)
+- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(3)
+- expression 48 operands: lhs = Counter(2), rhs = Expression(49, Sub)
+- expression 49 operands: lhs = Expression(50, Add), rhs = Counter(2)
+- expression 50 operands: lhs = Counter(1), rhs = Expression(51, Sub)
+- expression 51 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 17
+- Code(Counter(0)) at (prev + 6, 1) to (start + 3, 10)
+- Code(Expression(0, Add)) at (prev + 9, 5) to (start + 1, 14)
+ = (c0 + Zero)
+- Code(Counter(1)) at (prev + 1, 15) to (start + 0, 23)
+- Code(Expression(51, Sub)) at (prev + 0, 23) to (start + 0, 24)
+ = (c0 - c1)
+- Code(Expression(50, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = (c1 + (c0 - c1))
+- Code(Expression(4, Add)) at (prev + 6, 5) to (start + 1, 14)
+ = ((c1 + (c0 - c1)) + Zero)
+- Code(Counter(2)) at (prev + 1, 15) to (start + 0, 23)
+- Code(Expression(49, Sub)) at (prev + 0, 23) to (start + 0, 24)
+ = ((c1 + (c0 - c1)) - c2)
+- Code(Expression(48, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = (c2 + ((c1 + (c0 - c1)) - c2))
+- Code(Expression(14, Add)) at (prev + 6, 5) to (start + 1, 14)
+ = ((c2 + ((c1 + (c0 - c1)) - c2)) + Zero)
+- Code(Counter(3)) at (prev + 1, 15) to (start + 0, 23)
+- Code(Expression(47, Sub)) at (prev + 0, 23) to (start + 0, 24)
+ = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)
+- Code(Expression(46, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3))
+- Code(Expression(30, Add)) at (prev + 6, 5) to (start + 1, 14)
+ = ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) + Zero)
+- Code(Counter(4)) at (prev + 1, 15) to (start + 0, 23)
+- Code(Expression(45, Sub)) at (prev + 0, 23) to (start + 0, 24)
+ = ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)
+- Code(Expression(44, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4))
+
+Function name: closure_bug::main::{closure#0}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0d, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 13, 9) to (start + 0, 18)
+- Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25)
+- Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42)
+ = (c1 + (c0 - c1))
+
+Function name: closure_bug::main::{closure#1}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 16, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 22, 9) to (start + 0, 18)
+- Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25)
+- Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42)
+ = (c1 + (c0 - c1))
+
+Function name: closure_bug::main::{closure#2}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1f, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 31, 9) to (start + 0, 18)
+- Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25)
+- Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42)
+ = (c1 + (c0 - c1))
+
+Function name: closure_bug::main::{closure#3}
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 28, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 40, 9) to (start + 0, 18)
+- Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25)
+- Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42)
+ = (c1 + (c0 - c1))
+
diff --git a/tests/coverage-map/status-quo/closure_bug.rs b/tests/coverage-map/status-quo/closure_bug.rs
new file mode 100644
index 000000000..739bc5f0b
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_bug.rs
@@ -0,0 +1,44 @@
+// Regression test for #115930.
+// All of these closures are identical, and should produce identical output in
+// the coverage report. However, an unstable sort was causing them to be treated
+// inconsistently when preparing coverage spans.
+
+fn main() {
+ let truthy = std::env::args().len() == 1;
+
+ let a
+ =
+ |
+ |
+ if truthy { true } else { false };
+
+ a();
+ if truthy { a(); }
+
+ let b
+ =
+ |
+ |
+ if truthy { true } else { false };
+
+ b();
+ if truthy { b(); }
+
+ let c
+ =
+ |
+ |
+ if truthy { true } else { false };
+
+ c();
+ if truthy { c(); }
+
+ let d
+ =
+ |
+ |
+ if truthy { true } else { false };
+
+ d();
+ if truthy { d(); }
+}
diff --git a/tests/coverage-map/status-quo/closure_macro.cov-map b/tests/coverage-map/status-quo/closure_macro.cov-map
new file mode 100644
index 000000000..ac017eb44
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_macro.cov-map
@@ -0,0 +1,40 @@
+Function name: closure_macro::load_configuration_files
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2)
+
+Function name: closure_macro::main
+Raw bytes (49): 0x[01, 01, 05, 01, 05, 02, 00, 05, 00, 02, 00, 05, 02, 07, 01, 21, 01, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 07, 00, 12, 00, 13, 0b, 00, 54, 00, 55, 0f, 02, 09, 02, 0b, 13, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 2 operands: lhs = Counter(1), rhs = Zero
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 7
+- Code(Counter(0)) at (prev + 33, 1) to (start + 1, 33)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
+ = (c0 - c1)
+- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
+- Code(Expression(1, Add)) at (prev + 0, 18) to (start + 0, 19)
+ = ((c0 - c1) + Zero)
+- Code(Expression(2, Add)) at (prev + 0, 84) to (start + 0, 85)
+ = (c1 + Zero)
+- Code(Expression(3, Add)) at (prev + 2, 9) to (start + 2, 11)
+ = ((c0 - c1) + Zero)
+- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: closure_macro::main::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84)
+
diff --git a/tests/coverage-map/status-quo/closure_macro.rs b/tests/coverage-map/status-quo/closure_macro.rs
new file mode 100644
index 000000000..9b289141c
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_macro.rs
@@ -0,0 +1,40 @@
+// compile-flags: --edition=2018
+#![feature(coverage_attribute)]
+
+macro_rules! bail {
+ ($msg:literal $(,)?) => {
+ if $msg.len() > 0 {
+ println!("no msg");
+ } else {
+ println!($msg);
+ }
+ return Err(String::from($msg));
+ };
+}
+
+macro_rules! on_error {
+ ($value:expr, $error_message:expr) => {
+ $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
+ let message = format!($error_message, e);
+ if message.len() > 0 {
+ println!("{}", message);
+ Ok(String::from("ok"))
+ } else {
+ bail!("error");
+ }
+ })
+ };
+}
+
+fn load_configuration_files() -> Result<String, String> {
+ Ok(String::from("config"))
+}
+
+pub fn main() -> Result<(), String> {
+ println!("Starting service");
+ let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
+
+ let startup_delay_duration = String::from("arg");
+ let _ = (config, startup_delay_duration);
+ Ok(())
+}
diff --git a/tests/coverage-map/status-quo/closure_macro_async.cov-map b/tests/coverage-map/status-quo/closure_macro_async.cov-map
new file mode 100644
index 000000000..c9a142e5a
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_macro_async.cov-map
@@ -0,0 +1,48 @@
+Function name: closure_macro_async::load_configuration_files
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2)
+
+Function name: closure_macro_async::test
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 00, 2b]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 43)
+
+Function name: closure_macro_async::test::{closure#0}
+Raw bytes (49): 0x[01, 01, 05, 01, 05, 02, 00, 05, 00, 02, 00, 05, 02, 07, 01, 21, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 07, 00, 12, 00, 13, 0b, 00, 54, 00, 55, 0f, 02, 09, 02, 0b, 13, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 2 operands: lhs = Counter(1), rhs = Zero
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero
+- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 7
+- Code(Counter(0)) at (prev + 33, 43) to (start + 1, 33)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
+ = (c0 - c1)
+- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
+- Code(Expression(1, Add)) at (prev + 0, 18) to (start + 0, 19)
+ = ((c0 - c1) + Zero)
+- Code(Expression(2, Add)) at (prev + 0, 84) to (start + 0, 85)
+ = (c1 + Zero)
+- Code(Expression(3, Add)) at (prev + 2, 9) to (start + 2, 11)
+ = ((c0 - c1) + Zero)
+- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: closure_macro_async::test::{closure#0}::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84)
+
diff --git a/tests/coverage-map/status-quo/closure_macro_async.rs b/tests/coverage-map/status-quo/closure_macro_async.rs
new file mode 100644
index 000000000..b4275599e
--- /dev/null
+++ b/tests/coverage-map/status-quo/closure_macro_async.rs
@@ -0,0 +1,77 @@
+// compile-flags: --edition=2018
+#![feature(coverage_attribute)]
+
+macro_rules! bail {
+ ($msg:literal $(,)?) => {
+ if $msg.len() > 0 {
+ println!("no msg");
+ } else {
+ println!($msg);
+ }
+ return Err(String::from($msg));
+ };
+}
+
+macro_rules! on_error {
+ ($value:expr, $error_message:expr) => {
+ $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
+ let message = format!($error_message, e);
+ if message.len() > 0 {
+ println!("{}", message);
+ Ok(String::from("ok"))
+ } else {
+ bail!("error");
+ }
+ })
+ };
+}
+
+fn load_configuration_files() -> Result<String, String> {
+ Ok(String::from("config"))
+}
+
+pub async fn test() -> Result<(), String> {
+ println!("Starting service");
+ let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
+
+ let startup_delay_duration = String::from("arg");
+ let _ = (config, startup_delay_duration);
+ Ok(())
+}
+
+#[coverage(off)]
+fn main() {
+ executor::block_on(test()).unwrap();
+}
+
+mod executor {
+ use core::{
+ future::Future,
+ pin::Pin,
+ task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
+ };
+
+ #[coverage(off)]
+ pub fn block_on<F: Future>(mut future: F) -> F::Output {
+ let mut future = unsafe { Pin::new_unchecked(&mut future) };
+ use std::hint::unreachable_unchecked;
+ static VTABLE: RawWakerVTable = RawWakerVTable::new(
+ #[coverage(off)]
+ |_| unsafe { unreachable_unchecked() }, // clone
+ #[coverage(off)]
+ |_| unsafe { unreachable_unchecked() }, // wake
+ #[coverage(off)]
+ |_| unsafe { unreachable_unchecked() }, // wake_by_ref
+ #[coverage(off)]
+ |_| (),
+ );
+ let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
+ let mut context = Context::from_waker(&waker);
+
+ loop {
+ if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
+ break val;
+ }
+ }
+ }
+}
diff --git a/tests/coverage-map/status-quo/conditions.cov-map b/tests/coverage-map/status-quo/conditions.cov-map
new file mode 100644
index 000000000..d82b8389b
--- /dev/null
+++ b/tests/coverage-map/status-quo/conditions.cov-map
@@ -0,0 +1,261 @@
+Function name: conditions::main
+Raw bytes (793): 0x[01, 01, 90, 01, 09, 33, 37, 41, 3b, 3d, 35, 39, 05, 00, bf, 04, 09, 05, 00, 0d, 35, 26, 39, 0d, 35, 3b, 3d, 35, 39, 37, 41, 3b, 3d, 35, 39, ba, 04, 0d, bf, 04, 09, 05, 00, 03, 00, 45, 00, 87, 01, 49, 45, 00, 82, 01, 31, 87, 01, 49, 45, 00, 7e, 4d, 82, 01, 31, 87, 01, 49, 45, 00, 7a, 51, 7e, 4d, 82, 01, 31, 87, 01, 49, 45, 00, ab, 01, 55, 4d, 51, a7, 01, 59, ab, 01, 55, 4d, 51, 49, a3, 01, a7, 01, 59, ab, 01, 55, 4d, 51, 61, 00, e7, 01, 65, 61, 00, e2, 01, 2d, e7, 01, 65, 61, 00, de, 01, 69, e2, 01, 2d, e7, 01, 65, 61, 00, da, 01, 6d, de, 01, 69, e2, 01, 2d, e7, 01, 65, 61, 00, 8f, 02, 71, 69, 6d, 8b, 02, 75, 8f, 02, 71, 69, 6d, 83, 02, 00, 65, 87, 02, 8b, 02, 75, 8f, 02, 71, 69, 6d, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, 79, 00, db, 02, 7d, 79, 00, d6, 02, 29, db, 02, 7d, 79, 00, d2, 02, 81, 01, d6, 02, 29, db, 02, 7d, 79, 00, ce, 02, 85, 01, d2, 02, 81, 01, d6, 02, 29, db, 02, 7d, 79, 00, fb, 03, 89, 01, 81, 01, 85, 01, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, 11, 9b, 04, 9f, 04, 21, a3, 04, 1d, 15, 19, ef, 03, 00, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, e6, 03, 15, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, e2, 03, 19, e6, 03, 15, ea, 03, 25, ef, 03, 11, 7d, f3, 03, f7, 03, 8d, 01, fb, 03, 89, 01, 81, 01, 85, 01, a3, 04, 1d, 15, 19, 9f, 04, 21, a3, 04, 1d, 15, 19, 97, 04, a7, 04, 11, 9b, 04, 9f, 04, 21, a3, 04, 1d, 15, 19, ab, 04, b6, 04, af, 04, b3, 04, 25, 29, 2d, 31, ba, 04, 0d, bf, 04, 09, 05, 00, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 06, 00, 07, 03, 03, 09, 00, 0a, bf, 04, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, ba, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 26, 00, 1d, 00, 2a, 22, 00, 2e, 00, 3c, 37, 00, 3d, 02, 0a, 41, 02, 0a, 00, 0b, 33, 01, 09, 01, 12, b6, 04, 03, 09, 00, 0f, 4b, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 87, 01, 02, 08, 00, 15, 49, 00, 16, 02, 06, 82, 01, 02, 0f, 00, 1c, 7e, 01, 0c, 00, 19, 7a, 00, 1d, 00, 2a, 76, 00, 2e, 00, 3c, a7, 01, 00, 3d, 02, 0a, 59, 02, 0a, 00, 0b, a3, 01, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 9f, 01, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 0a, 00, 0b, e7, 01, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, e2, 01, 03, 11, 00, 1e, de, 01, 01, 10, 00, 1d, da, 01, 00, 21, 00, 2e, d6, 01, 00, 32, 00, 40, 8b, 02, 00, 41, 02, 0e, 75, 02, 0e, 00, 0f, 87, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, ff, 01, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, ef, 03, 02, 09, 00, 0a, db, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, d6, 02, 02, 0f, 00, 1c, d2, 02, 01, 0c, 00, 19, ce, 02, 00, 1d, 00, 2a, ca, 02, 00, 2e, 00, 3c, f7, 03, 00, 3d, 02, 0a, 8d, 01, 02, 0a, 00, 0b, f3, 03, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, 97, 04, 05, 09, 00, 0a, 83, 03, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, ea, 03, 02, 0f, 00, 1c, e6, 03, 01, 0c, 00, 19, e2, 03, 00, 1d, 00, 2a, de, 03, 00, 2e, 00, 3c, 9f, 04, 00, 3d, 02, 0a, 21, 02, 0a, 00, 0b, 9b, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, 93, 04, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 144
+- expression 0 operands: lhs = Counter(2), rhs = Expression(12, Add)
+- expression 1 operands: lhs = Expression(13, Add), rhs = Counter(16)
+- expression 2 operands: lhs = Expression(14, Add), rhs = Counter(15)
+- expression 3 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 4 operands: lhs = Counter(1), rhs = Zero
+- expression 5 operands: lhs = Expression(143, Add), rhs = Counter(2)
+- expression 6 operands: lhs = Counter(1), rhs = Zero
+- expression 7 operands: lhs = Counter(3), rhs = Counter(13)
+- expression 8 operands: lhs = Expression(9, Sub), rhs = Counter(14)
+- expression 9 operands: lhs = Counter(3), rhs = Counter(13)
+- expression 10 operands: lhs = Expression(14, Add), rhs = Counter(15)
+- expression 11 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(16)
+- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(15)
+- expression 14 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 15 operands: lhs = Expression(142, Sub), rhs = Counter(3)
+- expression 16 operands: lhs = Expression(143, Add), rhs = Counter(2)
+- expression 17 operands: lhs = Counter(1), rhs = Zero
+- expression 18 operands: lhs = Expression(0, Add), rhs = Zero
+- expression 19 operands: lhs = Counter(17), rhs = Zero
+- expression 20 operands: lhs = Expression(33, Add), rhs = Counter(18)
+- expression 21 operands: lhs = Counter(17), rhs = Zero
+- expression 22 operands: lhs = Expression(32, Sub), rhs = Counter(12)
+- expression 23 operands: lhs = Expression(33, Add), rhs = Counter(18)
+- expression 24 operands: lhs = Counter(17), rhs = Zero
+- expression 25 operands: lhs = Expression(31, Sub), rhs = Counter(19)
+- expression 26 operands: lhs = Expression(32, Sub), rhs = Counter(12)
+- expression 27 operands: lhs = Expression(33, Add), rhs = Counter(18)
+- expression 28 operands: lhs = Counter(17), rhs = Zero
+- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(20)
+- expression 30 operands: lhs = Expression(31, Sub), rhs = Counter(19)
+- expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(12)
+- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(18)
+- expression 33 operands: lhs = Counter(17), rhs = Zero
+- expression 34 operands: lhs = Expression(42, Add), rhs = Counter(21)
+- expression 35 operands: lhs = Counter(19), rhs = Counter(20)
+- expression 36 operands: lhs = Expression(41, Add), rhs = Counter(22)
+- expression 37 operands: lhs = Expression(42, Add), rhs = Counter(21)
+- expression 38 operands: lhs = Counter(19), rhs = Counter(20)
+- expression 39 operands: lhs = Counter(18), rhs = Expression(40, Add)
+- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(22)
+- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(21)
+- expression 42 operands: lhs = Counter(19), rhs = Counter(20)
+- expression 43 operands: lhs = Counter(24), rhs = Zero
+- expression 44 operands: lhs = Expression(57, Add), rhs = Counter(25)
+- expression 45 operands: lhs = Counter(24), rhs = Zero
+- expression 46 operands: lhs = Expression(56, Sub), rhs = Counter(11)
+- expression 47 operands: lhs = Expression(57, Add), rhs = Counter(25)
+- expression 48 operands: lhs = Counter(24), rhs = Zero
+- expression 49 operands: lhs = Expression(55, Sub), rhs = Counter(26)
+- expression 50 operands: lhs = Expression(56, Sub), rhs = Counter(11)
+- expression 51 operands: lhs = Expression(57, Add), rhs = Counter(25)
+- expression 52 operands: lhs = Counter(24), rhs = Zero
+- expression 53 operands: lhs = Expression(54, Sub), rhs = Counter(27)
+- expression 54 operands: lhs = Expression(55, Sub), rhs = Counter(26)
+- expression 55 operands: lhs = Expression(56, Sub), rhs = Counter(11)
+- expression 56 operands: lhs = Expression(57, Add), rhs = Counter(25)
+- expression 57 operands: lhs = Counter(24), rhs = Zero
+- expression 58 operands: lhs = Expression(67, Add), rhs = Counter(28)
+- expression 59 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 60 operands: lhs = Expression(66, Add), rhs = Counter(29)
+- expression 61 operands: lhs = Expression(67, Add), rhs = Counter(28)
+- expression 62 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 63 operands: lhs = Expression(64, Add), rhs = Zero
+- expression 64 operands: lhs = Counter(25), rhs = Expression(65, Add)
+- expression 65 operands: lhs = Expression(66, Add), rhs = Counter(29)
+- expression 66 operands: lhs = Expression(67, Add), rhs = Counter(28)
+- expression 67 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 68 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 69 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 70 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 71 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 72 operands: lhs = Counter(30), rhs = Zero
+- expression 73 operands: lhs = Expression(86, Add), rhs = Counter(31)
+- expression 74 operands: lhs = Counter(30), rhs = Zero
+- expression 75 operands: lhs = Expression(85, Sub), rhs = Counter(10)
+- expression 76 operands: lhs = Expression(86, Add), rhs = Counter(31)
+- expression 77 operands: lhs = Counter(30), rhs = Zero
+- expression 78 operands: lhs = Expression(84, Sub), rhs = Counter(32)
+- expression 79 operands: lhs = Expression(85, Sub), rhs = Counter(10)
+- expression 80 operands: lhs = Expression(86, Add), rhs = Counter(31)
+- expression 81 operands: lhs = Counter(30), rhs = Zero
+- expression 82 operands: lhs = Expression(83, Sub), rhs = Counter(33)
+- expression 83 operands: lhs = Expression(84, Sub), rhs = Counter(32)
+- expression 84 operands: lhs = Expression(85, Sub), rhs = Counter(10)
+- expression 85 operands: lhs = Expression(86, Add), rhs = Counter(31)
+- expression 86 operands: lhs = Counter(30), rhs = Zero
+- expression 87 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 88 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 89 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 90 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 91 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 92 operands: lhs = Counter(4), rhs = Expression(134, Add)
+- expression 93 operands: lhs = Expression(135, Add), rhs = Counter(8)
+- expression 94 operands: lhs = Expression(136, Add), rhs = Counter(7)
+- expression 95 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 96 operands: lhs = Expression(123, Add), rhs = Zero
+- expression 97 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 98 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 99 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 100 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 101 operands: lhs = Expression(123, Add), rhs = Counter(4)
+- expression 102 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 103 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 104 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 105 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 106 operands: lhs = Expression(122, Sub), rhs = Counter(9)
+- expression 107 operands: lhs = Expression(123, Add), rhs = Counter(4)
+- expression 108 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 109 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 110 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 111 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 112 operands: lhs = Expression(121, Sub), rhs = Counter(5)
+- expression 113 operands: lhs = Expression(122, Sub), rhs = Counter(9)
+- expression 114 operands: lhs = Expression(123, Add), rhs = Counter(4)
+- expression 115 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 116 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 117 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 118 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 119 operands: lhs = Expression(120, Sub), rhs = Counter(6)
+- expression 120 operands: lhs = Expression(121, Sub), rhs = Counter(5)
+- expression 121 operands: lhs = Expression(122, Sub), rhs = Counter(9)
+- expression 122 operands: lhs = Expression(123, Add), rhs = Counter(4)
+- expression 123 operands: lhs = Counter(31), rhs = Expression(124, Add)
+- expression 124 operands: lhs = Expression(125, Add), rhs = Counter(35)
+- expression 125 operands: lhs = Expression(126, Add), rhs = Counter(34)
+- expression 126 operands: lhs = Counter(32), rhs = Counter(33)
+- expression 127 operands: lhs = Expression(136, Add), rhs = Counter(7)
+- expression 128 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 129 operands: lhs = Expression(135, Add), rhs = Counter(8)
+- expression 130 operands: lhs = Expression(136, Add), rhs = Counter(7)
+- expression 131 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 132 operands: lhs = Expression(133, Add), rhs = Expression(137, Add)
+- expression 133 operands: lhs = Counter(4), rhs = Expression(134, Add)
+- expression 134 operands: lhs = Expression(135, Add), rhs = Counter(8)
+- expression 135 operands: lhs = Expression(136, Add), rhs = Counter(7)
+- expression 136 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 137 operands: lhs = Expression(138, Add), rhs = Expression(141, Sub)
+- expression 138 operands: lhs = Expression(139, Add), rhs = Expression(140, Add)
+- expression 139 operands: lhs = Counter(9), rhs = Counter(10)
+- expression 140 operands: lhs = Counter(11), rhs = Counter(12)
+- expression 141 operands: lhs = Expression(142, Sub), rhs = Counter(3)
+- expression 142 operands: lhs = Expression(143, Add), rhs = Counter(2)
+- expression 143 operands: lhs = Counter(1), rhs = Zero
+Number of file 0 mappings: 68
+- Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12)
+- Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(0, Add)) at (prev + 3, 9) to (start + 0, 10)
+ = (c2 + (((c13 + c14) + c15) + c16))
+- Code(Expression(143, Add)) at (prev + 0, 16) to (start + 0, 29)
+ = (c1 + Zero)
+- Code(Counter(2)) at (prev + 1, 9) to (start + 1, 10)
+- Code(Expression(142, Sub)) at (prev + 2, 15) to (start + 0, 28)
+ = ((c1 + Zero) - c2)
+- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 25)
+- Code(Expression(9, Sub)) at (prev + 0, 29) to (start + 0, 42)
+ = (c3 - c13)
+- Code(Expression(8, Sub)) at (prev + 0, 46) to (start + 0, 60)
+ = ((c3 - c13) - c14)
+- Code(Expression(13, Add)) at (prev + 0, 61) to (start + 2, 10)
+ = ((c13 + c14) + c15)
+- Code(Counter(16)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(12, Add)) at (prev + 1, 9) to (start + 1, 18)
+ = (((c13 + c14) + c15) + c16)
+- Code(Expression(141, Sub)) at (prev + 3, 9) to (start + 0, 15)
+ = (((c1 + Zero) - c2) - c3)
+- Code(Expression(18, Add)) at (prev + 3, 9) to (start + 1, 12)
+ = ((c2 + (((c13 + c14) + c15) + c16)) + Zero)
+- Code(Counter(17)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(33, Add)) at (prev + 2, 8) to (start + 0, 21)
+ = (c17 + Zero)
+- Code(Counter(18)) at (prev + 0, 22) to (start + 2, 6)
+- Code(Expression(32, Sub)) at (prev + 2, 15) to (start + 0, 28)
+ = ((c17 + Zero) - c18)
+- Code(Expression(31, Sub)) at (prev + 1, 12) to (start + 0, 25)
+ = (((c17 + Zero) - c18) - c12)
+- Code(Expression(30, Sub)) at (prev + 0, 29) to (start + 0, 42)
+ = ((((c17 + Zero) - c18) - c12) - c19)
+- Code(Expression(29, Sub)) at (prev + 0, 46) to (start + 0, 60)
+ = (((((c17 + Zero) - c18) - c12) - c19) - c20)
+- Code(Expression(41, Add)) at (prev + 0, 61) to (start + 2, 10)
+ = ((c19 + c20) + c21)
+- Code(Counter(22)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(40, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (((c19 + c20) + c21) + c22)
+- Code(Counter(12)) at (prev + 2, 9) to (start + 0, 15)
+- Code(Expression(39, Add)) at (prev + 3, 8) to (start + 0, 12)
+ = (c18 + (((c19 + c20) + c21) + c22))
+- Code(Counter(23)) at (prev + 1, 13) to (start + 1, 16)
+- Code(Counter(24)) at (prev + 1, 17) to (start + 2, 10)
+- Code(Zero) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(57, Add)) at (prev + 2, 12) to (start + 0, 25)
+ = (c24 + Zero)
+- Code(Counter(25)) at (prev + 0, 26) to (start + 2, 10)
+- Code(Expression(56, Sub)) at (prev + 3, 17) to (start + 0, 30)
+ = ((c24 + Zero) - c25)
+- Code(Expression(55, Sub)) at (prev + 1, 16) to (start + 0, 29)
+ = (((c24 + Zero) - c25) - c11)
+- Code(Expression(54, Sub)) at (prev + 0, 33) to (start + 0, 46)
+ = ((((c24 + Zero) - c25) - c11) - c26)
+- Code(Expression(53, Sub)) at (prev + 0, 50) to (start + 0, 64)
+ = (((((c24 + Zero) - c25) - c11) - c26) - c27)
+- Code(Expression(66, Add)) at (prev + 0, 65) to (start + 2, 14)
+ = ((c26 + c27) + c28)
+- Code(Counter(29)) at (prev + 2, 14) to (start + 0, 15)
+- Code(Expression(65, Add)) at (prev + 1, 13) to (start + 0, 27)
+ = (((c26 + c27) + c28) + c29)
+- Code(Counter(11)) at (prev + 2, 13) to (start + 0, 19)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(63, Add)) at (prev + 2, 9) to (start + 1, 12)
+ = ((c25 + (((c26 + c27) + c28) + c29)) + Zero)
+- Code(Counter(30)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(123, Add)) at (prev + 2, 9) to (start + 0, 10)
+ = (c31 + (((c32 + c33) + c34) + c35))
+- Code(Expression(86, Add)) at (prev + 0, 16) to (start + 0, 29)
+ = (c30 + Zero)
+- Code(Counter(31)) at (prev + 0, 30) to (start + 2, 6)
+- Code(Expression(85, Sub)) at (prev + 2, 15) to (start + 0, 28)
+ = ((c30 + Zero) - c31)
+- Code(Expression(84, Sub)) at (prev + 1, 12) to (start + 0, 25)
+ = (((c30 + Zero) - c31) - c10)
+- Code(Expression(83, Sub)) at (prev + 0, 29) to (start + 0, 42)
+ = ((((c30 + Zero) - c31) - c10) - c32)
+- Code(Expression(82, Sub)) at (prev + 0, 46) to (start + 0, 60)
+ = (((((c30 + Zero) - c31) - c10) - c32) - c33)
+- Code(Expression(125, Add)) at (prev + 0, 61) to (start + 2, 10)
+ = ((c32 + c33) + c34)
+- Code(Counter(35)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(124, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (((c32 + c33) + c34) + c35)
+- Code(Counter(10)) at (prev + 2, 13) to (start + 2, 15)
+- Code(Expression(133, Add)) at (prev + 5, 9) to (start + 0, 10)
+ = (c4 + (((c5 + c6) + c7) + c8))
+- Code(Expression(96, Add)) at (prev + 0, 16) to (start + 0, 29)
+ = ((c31 + (((c32 + c33) + c34) + c35)) + Zero)
+- Code(Counter(4)) at (prev + 0, 30) to (start + 2, 6)
+- Code(Expression(122, Sub)) at (prev + 2, 15) to (start + 0, 28)
+ = ((c31 + (((c32 + c33) + c34) + c35)) - c4)
+- Code(Expression(121, Sub)) at (prev + 1, 12) to (start + 0, 25)
+ = (((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9)
+- Code(Expression(120, Sub)) at (prev + 0, 29) to (start + 0, 42)
+ = ((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5)
+- Code(Expression(119, Sub)) at (prev + 0, 46) to (start + 0, 60)
+ = (((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) - c6)
+- Code(Expression(135, Add)) at (prev + 0, 61) to (start + 2, 10)
+ = ((c5 + c6) + c7)
+- Code(Counter(8)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(134, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (((c5 + c6) + c7) + c8)
+- Code(Counter(9)) at (prev + 2, 9) to (start + 0, 15)
+- Code(Expression(132, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = ((c4 + (((c5 + c6) + c7) + c8)) + (((c9 + c10) + (c11 + c12)) + (((c1 + Zero) - c2) - c3)))
+
diff --git a/tests/coverage-map/status-quo/conditions.rs b/tests/coverage-map/status-quo/conditions.rs
new file mode 100644
index 000000000..fa7f2a116
--- /dev/null
+++ b/tests/coverage-map/status-quo/conditions.rs
@@ -0,0 +1,86 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ let mut countdown = 0;
+ if true {
+ countdown = 10;
+ }
+
+ const B: u32 = 100;
+ let x = if countdown > 7 {
+ countdown -= 4;
+ B
+ } else if countdown > 2 {
+ if countdown < 1 || countdown > 5 || countdown != 9 {
+ countdown = 0;
+ }
+ countdown -= 5;
+ countdown
+ } else {
+ return;
+ };
+
+ let mut countdown = 0;
+ if true {
+ countdown = 10;
+ }
+
+ if countdown > 7 {
+ countdown -= 4;
+ } else if countdown > 2 {
+ if countdown < 1 || countdown > 5 || countdown != 9 {
+ countdown = 0;
+ }
+ countdown -= 5;
+ } else {
+ return;
+ }
+
+ if true {
+ let mut countdown = 0;
+ if true {
+ countdown = 10;
+ }
+
+ if countdown > 7 {
+ countdown -= 4;
+ }
+ else if countdown > 2 {
+ if countdown < 1 || countdown > 5 || countdown != 9 {
+ countdown = 0;
+ }
+ countdown -= 5;
+ } else {
+ return;
+ }
+ }
+
+ let mut countdown = 0;
+ if true {
+ countdown = 1;
+ }
+
+ let z = if countdown > 7 {
+ countdown -= 4;
+ } else if countdown > 2 {
+ if countdown < 1 || countdown > 5 || countdown != 9 {
+ countdown = 0;
+ }
+ countdown -= 5;
+ } else {
+ let should_be_reachable = countdown;
+ println!("reached");
+ return;
+ };
+
+ let w = if countdown > 7 {
+ countdown -= 4;
+ } else if countdown > 2 {
+ if countdown < 1 || countdown > 5 || countdown != 9 {
+ countdown = 0;
+ }
+ countdown -= 5;
+ } else {
+ return;
+ };
+}
diff --git a/tests/coverage-map/status-quo/continue.cov-map b/tests/coverage-map/status-quo/continue.cov-map
new file mode 100644
index 000000000..c78cf2930
--- /dev/null
+++ b/tests/coverage-map/status-quo/continue.cov-map
@@ -0,0 +1,85 @@
+Function name: continue::main
+Raw bytes (216): 0x[01, 01, 1f, 01, 07, 05, 09, 03, 0d, 0d, 1f, 11, 15, 1b, 19, 0d, 1f, 11, 15, 15, 00, 19, 37, 1d, 21, 33, 25, 19, 37, 1d, 21, 1d, 00, 25, 4f, 29, 2d, 4b, 31, 25, 4f, 29, 2d, 31, 67, 35, 39, 5f, 3d, 31, 67, 35, 39, 35, 39, 3d, 41, 73, 45, 3d, 41, 41, 00, 49, 45, 1e, 01, 03, 01, 03, 12, 03, 04, 0e, 00, 13, 0a, 01, 0f, 00, 16, 05, 02, 11, 00, 19, 09, 02, 12, 04, 0e, 1b, 06, 0e, 00, 13, 16, 01, 0f, 00, 16, 15, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 23, 03, 09, 00, 0e, 33, 02, 0e, 00, 13, 2e, 01, 0f, 00, 16, 1d, 01, 15, 02, 0e, 21, 04, 11, 00, 19, 3b, 03, 09, 00, 0e, 4b, 02, 0e, 00, 13, 46, 01, 0c, 00, 13, 29, 01, 0d, 00, 15, 2d, 01, 0a, 01, 0e, 5f, 03, 0e, 00, 13, 5a, 01, 0f, 00, 16, 39, 01, 16, 02, 0e, 35, 03, 12, 02, 0e, 67, 04, 09, 00, 0e, 73, 02, 0e, 00, 13, 6e, 01, 0f, 00, 16, 41, 01, 16, 02, 0e, 49, 04, 11, 00, 16, 77, 03, 09, 00, 0e, 7b, 02, 0d, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 31
+- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(3), rhs = Expression(7, Add)
+- expression 4 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(6)
+- expression 6 operands: lhs = Counter(3), rhs = Expression(7, Add)
+- expression 7 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 8 operands: lhs = Counter(5), rhs = Zero
+- expression 9 operands: lhs = Counter(6), rhs = Expression(13, Add)
+- expression 10 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(9)
+- expression 12 operands: lhs = Counter(6), rhs = Expression(13, Add)
+- expression 13 operands: lhs = Counter(7), rhs = Counter(8)
+- expression 14 operands: lhs = Counter(7), rhs = Zero
+- expression 15 operands: lhs = Counter(9), rhs = Expression(19, Add)
+- expression 16 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(12)
+- expression 18 operands: lhs = Counter(9), rhs = Expression(19, Add)
+- expression 19 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 20 operands: lhs = Counter(12), rhs = Expression(25, Add)
+- expression 21 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 22 operands: lhs = Expression(23, Add), rhs = Counter(15)
+- expression 23 operands: lhs = Counter(12), rhs = Expression(25, Add)
+- expression 24 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 25 operands: lhs = Counter(13), rhs = Counter(14)
+- expression 26 operands: lhs = Counter(15), rhs = Counter(16)
+- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(17)
+- expression 28 operands: lhs = Counter(15), rhs = Counter(16)
+- expression 29 operands: lhs = Counter(16), rhs = Zero
+- expression 30 operands: lhs = Counter(18), rhs = Counter(17)
+Number of file 0 mappings: 30
+- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 18)
+- Code(Expression(0, Add)) at (prev + 4, 14) to (start + 0, 19)
+ = (c0 + (c1 + c2))
+- Code(Expression(2, Sub)) at (prev + 1, 15) to (start + 0, 22)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(1)) at (prev + 2, 17) to (start + 0, 25)
+- Code(Counter(2)) at (prev + 2, 18) to (start + 4, 14)
+- Code(Expression(6, Add)) at (prev + 6, 14) to (start + 0, 19)
+ = (c3 + (c4 + c5))
+- Code(Expression(5, Sub)) at (prev + 1, 15) to (start + 0, 22)
+ = ((c3 + (c4 + c5)) - c6)
+- Code(Counter(5)) at (prev + 1, 22) to (start + 2, 14)
+- Code(Counter(4)) at (prev + 4, 17) to (start + 0, 25)
+- Code(Expression(8, Add)) at (prev + 3, 9) to (start + 0, 14)
+ = (c5 + Zero)
+- Code(Expression(12, Add)) at (prev + 2, 14) to (start + 0, 19)
+ = (c6 + (c7 + c8))
+- Code(Expression(11, Sub)) at (prev + 1, 15) to (start + 0, 22)
+ = ((c6 + (c7 + c8)) - c9)
+- Code(Counter(7)) at (prev + 1, 21) to (start + 2, 14)
+- Code(Counter(8)) at (prev + 4, 17) to (start + 0, 25)
+- Code(Expression(14, Add)) at (prev + 3, 9) to (start + 0, 14)
+ = (c7 + Zero)
+- Code(Expression(18, Add)) at (prev + 2, 14) to (start + 0, 19)
+ = (c9 + (c10 + c11))
+- Code(Expression(17, Sub)) at (prev + 1, 12) to (start + 0, 19)
+ = ((c9 + (c10 + c11)) - c12)
+- Code(Counter(10)) at (prev + 1, 13) to (start + 0, 21)
+- Code(Counter(11)) at (prev + 1, 10) to (start + 1, 14)
+- Code(Expression(23, Add)) at (prev + 3, 14) to (start + 0, 19)
+ = (c12 + (c13 + c14))
+- Code(Expression(22, Sub)) at (prev + 1, 15) to (start + 0, 22)
+ = ((c12 + (c13 + c14)) - c15)
+- Code(Counter(14)) at (prev + 1, 22) to (start + 2, 14)
+- Code(Counter(13)) at (prev + 3, 18) to (start + 2, 14)
+- Code(Expression(25, Add)) at (prev + 4, 9) to (start + 0, 14)
+ = (c13 + c14)
+- Code(Expression(28, Add)) at (prev + 2, 14) to (start + 0, 19)
+ = (c15 + c16)
+- Code(Expression(27, Sub)) at (prev + 1, 15) to (start + 0, 22)
+ = ((c15 + c16) - c17)
+- Code(Counter(16)) at (prev + 1, 22) to (start + 2, 14)
+- Code(Counter(18)) at (prev + 4, 17) to (start + 0, 22)
+- Code(Expression(29, Add)) at (prev + 3, 9) to (start + 0, 14)
+ = (c16 + Zero)
+- Code(Expression(30, Add)) at (prev + 2, 13) to (start + 1, 2)
+ = (c18 + c17)
+
diff --git a/tests/coverage-map/status-quo/continue.rs b/tests/coverage-map/status-quo/continue.rs
new file mode 100644
index 000000000..624aa9834
--- /dev/null
+++ b/tests/coverage-map/status-quo/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;
+}
diff --git a/tests/coverage-map/status-quo/dead_code.cov-map b/tests/coverage-map/status-quo/dead_code.cov-map
new file mode 100644
index 000000000..8d5f88e63
--- /dev/null
+++ b/tests/coverage-map/status-quo/dead_code.cov-map
@@ -0,0 +1,37 @@
+Function name: dead_code::main
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1b, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 27, 1) to (start + 7, 15)
+- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: dead_code::unused_fn (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 0f, 01, 07, 0f, 00, 07, 10, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 15, 1) to (start + 7, 15)
+- Code(Zero) at (prev + 7, 16) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: dead_code::unused_pub_fn_not_in_library (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 03, 01, 07, 0f, 00, 07, 10, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15)
+- Code(Zero) at (prev + 7, 16) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
diff --git a/tests/coverage-map/status-quo/dead_code.rs b/tests/coverage-map/status-quo/dead_code.rs
new file mode 100644
index 000000000..3492712a6
--- /dev/null
+++ b/tests/coverage-map/status-quo/dead_code.rs
@@ -0,0 +1,37 @@
+#![allow(dead_code, unused_assignments, unused_variables)]
+
+pub fn unused_pub_fn_not_in_library() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+ if is_true {
+ countdown = 10;
+ }
+}
+
+fn unused_fn() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+ if is_true {
+ countdown = 10;
+ }
+}
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+ if is_true {
+ countdown = 10;
+ }
+}
diff --git a/tests/coverage-map/status-quo/drop_trait.cov-map b/tests/coverage-map/status-quo/drop_trait.cov-map
new file mode 100644
index 000000000..203d1048b
--- /dev/null
+++ b/tests/coverage-map/status-quo/drop_trait.cov-map
@@ -0,0 +1,21 @@
+Function name: <drop_trait::Firework as core::ops::drop::Drop>::drop
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 09, 05, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 9, 5) to (start + 2, 6)
+
+Function name: drop_trait::main
+Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 0e, 01, 05, 0c, 05, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(1), rhs = Zero
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 14, 1) to (start + 5, 12)
+- Code(Counter(1)) at (prev + 6, 9) to (start + 1, 22)
+- Code(Zero) at (prev + 2, 6) to (start + 4, 11)
+- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2)
+ = (c1 + Zero)
+
diff --git a/tests/coverage-map/status-quo/drop_trait.rs b/tests/coverage-map/status-quo/drop_trait.rs
new file mode 100644
index 000000000..7b062719c
--- /dev/null
+++ b/tests/coverage-map/status-quo/drop_trait.rs
@@ -0,0 +1,33 @@
+#![allow(unused_assignments)]
+// failure-status: 1
+
+struct Firework {
+ strength: i32,
+}
+
+impl Drop for Firework {
+ fn drop(&mut self) {
+ println!("BOOM times {}!!!", self.strength);
+ }
+}
+
+fn main() -> Result<(), u8> {
+ let _firecracker = Firework { strength: 1 };
+
+ let _tnt = Firework { strength: 100 };
+
+ if true {
+ println!("Exiting with error...");
+ return Err(1);
+ }
+
+ let _ = Firework { strength: 1000 };
+
+ Ok(())
+}
+
+// Expected program output:
+// Exiting with error...
+// BOOM times 100!!!
+// BOOM times 1!!!
+// Error: 1
diff --git a/tests/coverage-map/status-quo/generator.cov-map b/tests/coverage-map/status-quo/generator.cov-map
new file mode 100644
index 000000000..a66c1af30
--- /dev/null
+++ b/tests/coverage-map/status-quo/generator.cov-map
@@ -0,0 +1,58 @@
+Function name: generator::get_u32
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 01, 01, 0b, 05, 01, 0e, 00, 13, 02, 00, 1d, 00, 3c, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 11, 1) to (start + 1, 11)
+- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 19)
+- Code(Expression(0, Sub)) at (prev + 0, 29) to (start + 0, 60)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: generator::main
+Raw bytes (71): 0x[01, 01, 0b, 01, 00, 05, 0b, 09, 0d, 11, 00, 11, 15, 2a, 19, 11, 15, 15, 19, 26, 00, 2a, 19, 11, 15, 09, 01, 0f, 01, 02, 16, 03, 07, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 07, 01, 0e, 00, 35, 0f, 02, 0b, 00, 2e, 2a, 01, 22, 00, 27, 26, 00, 2c, 00, 2e, 1f, 01, 0e, 00, 35, 23, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 11
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(4), rhs = Zero
+- expression 4 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 5 operands: lhs = Expression(10, Sub), rhs = Counter(6)
+- expression 6 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 7 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 8 operands: lhs = Expression(9, Sub), rhs = Zero
+- expression 9 operands: lhs = Expression(10, Sub), rhs = Counter(6)
+- expression 10 operands: lhs = Counter(4), rhs = Counter(5)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 22)
+- Code(Expression(0, Add)) at (prev + 7, 11) to (start + 0, 46)
+ = (c0 + Zero)
+- Code(Counter(4)) at (prev + 1, 43) to (start + 0, 45)
+- Code(Expression(1, Add)) at (prev + 1, 14) to (start + 0, 53)
+ = (c1 + (c2 + c3))
+- Code(Expression(3, Add)) at (prev + 2, 11) to (start + 0, 46)
+ = (c4 + Zero)
+- Code(Expression(10, Sub)) at (prev + 1, 34) to (start + 0, 39)
+ = (c4 - c5)
+- Code(Expression(9, Sub)) at (prev + 0, 44) to (start + 0, 46)
+ = ((c4 - c5) - c6)
+- Code(Expression(7, Add)) at (prev + 1, 14) to (start + 0, 53)
+ = (c5 + c6)
+- Code(Expression(8, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (((c4 - c5) - c6) + Zero)
+
+Function name: generator::main::{closure#0}
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 11, 1c, 01, 1f, 05, 02, 10, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 17, 28) to (start + 1, 31)
+- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6)
+
diff --git a/tests/coverage-map/status-quo/generator.rs b/tests/coverage-map/status-quo/generator.rs
new file mode 100644
index 000000000..431999102
--- /dev/null
+++ b/tests/coverage-map/status-quo/generator.rs
@@ -0,0 +1,30 @@
+#![feature(generators, generator_trait)]
+
+use std::ops::{Generator, GeneratorState};
+use std::pin::Pin;
+
+// The following implementation of a function called from a `yield` statement
+// (apparently requiring the Result and the `String` type or constructor)
+// creates conditions where the `generator::StateTransform` MIR transform will
+// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic
+// to handle this condition, and still report dead block coverage.
+fn get_u32(val: bool) -> Result<u32, String> {
+ if val { Ok(1) } else { Err(String::from("some error")) }
+}
+
+fn main() {
+ let is_true = std::env::args().len() == 1;
+ let mut generator = || {
+ yield get_u32(is_true);
+ return "foo";
+ };
+
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Yielded(Ok(1)) => {}
+ _ => panic!("unexpected return from resume"),
+ }
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Complete("foo") => {}
+ _ => panic!("unexpected return from resume"),
+ }
+}
diff --git a/tests/coverage-map/status-quo/generics.cov-map b/tests/coverage-map/status-quo/generics.cov-map
new file mode 100644
index 000000000..6079a433c
--- /dev/null
+++ b/tests/coverage-map/status-quo/generics.cov-map
@@ -0,0 +1,45 @@
+Function name: <generics::Firework<f64> as core::ops::drop::Drop>::drop
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 05, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 17, 5) to (start + 2, 6)
+
+Function name: <generics::Firework<f64>>::set_strength
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 05, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 10, 5) to (start + 2, 6)
+
+Function name: <generics::Firework<i32> as core::ops::drop::Drop>::drop
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 05, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 17, 5) to (start + 2, 6)
+
+Function name: <generics::Firework<i32>>::set_strength
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 05, 02, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 10, 5) to (start + 2, 6)
+
+Function name: generics::main
+Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 16, 01, 08, 0c, 05, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(1), rhs = Zero
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 22, 1) to (start + 8, 12)
+- Code(Counter(1)) at (prev + 9, 9) to (start + 1, 22)
+- Code(Zero) at (prev + 2, 6) to (start + 4, 11)
+- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2)
+ = (c1 + Zero)
+
diff --git a/tests/coverage-map/status-quo/generics.rs b/tests/coverage-map/status-quo/generics.rs
new file mode 100644
index 000000000..bf4c2d8d6
--- /dev/null
+++ b/tests/coverage-map/status-quo/generics.rs
@@ -0,0 +1,44 @@
+#![allow(unused_assignments)]
+// failure-status: 1
+
+struct Firework<T> where T: Copy + std::fmt::Display {
+ strength: T,
+}
+
+impl<T> Firework<T> where T: Copy + std::fmt::Display {
+ #[inline(always)]
+ fn set_strength(&mut self, new_strength: T) {
+ self.strength = new_strength;
+ }
+}
+
+impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
+ #[inline(always)]
+ fn drop(&mut self) {
+ println!("BOOM times {}!!!", self.strength);
+ }
+}
+
+fn main() -> Result<(), u8> {
+ let mut firecracker = Firework { strength: 1 };
+ firecracker.set_strength(2);
+
+ let mut tnt = Firework { strength: 100.1 };
+ tnt.set_strength(200.1);
+ tnt.set_strength(300.3);
+
+ if true {
+ println!("Exiting with error...");
+ return Err(1);
+ }
+
+ let _ = Firework { strength: 1000 };
+
+ Ok(())
+}
+
+// Expected program output:
+// Exiting with error...
+// BOOM times 100!!!
+// BOOM times 1!!!
+// Error: 1
diff --git a/tests/coverage-map/status-quo/if.cov-map b/tests/coverage-map/status-quo/if.cov-map
new file mode 100644
index 000000000..391a69e0e
--- /dev/null
+++ b/tests/coverage-map/status-quo/if.cov-map
@@ -0,0 +1,15 @@
+Function name: if::main
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 03, 01, 12, 10, 05, 13, 05, 05, 06, 02, 05, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 3, 1) to (start + 18, 16)
+- Code(Counter(1)) at (prev + 19, 5) to (start + 5, 6)
+- Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
diff --git a/tests/coverage-map/status-quo/if.rs b/tests/coverage-map/status-quo/if.rs
new file mode 100644
index 000000000..8ad5042ff
--- /dev/null
+++ b/tests/coverage-map/status-quo/if.rs
@@ -0,0 +1,28 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let
+ is_true
+ =
+ std::env::args().len()
+ ==
+ 1
+ ;
+ let
+ mut
+ countdown
+ =
+ 0
+ ;
+ if
+ is_true
+ {
+ countdown
+ =
+ 10
+ ;
+ }
+}
diff --git a/tests/coverage-map/status-quo/if_else.cov-map b/tests/coverage-map/status-quo/if_else.cov-map
new file mode 100644
index 000000000..da692ca3a
--- /dev/null
+++ b/tests/coverage-map/status-quo/if_else.cov-map
@@ -0,0 +1,25 @@
+Function name: if_else::main
+Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 03, 01, 08, 10, 05, 09, 05, 05, 06, 02, 08, 09, 02, 10, 1b, 06, 09, 00, 10, 09, 01, 05, 05, 06, 16, 07, 05, 05, 06, 13, 06, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 7
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2)
+- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub)
+- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 7
+- Code(Counter(0)) at (prev + 3, 1) to (start + 8, 16)
+- Code(Counter(1)) at (prev + 9, 5) to (start + 5, 6)
+- Code(Expression(0, Sub)) at (prev + 8, 9) to (start + 2, 16)
+ = (c0 - c1)
+- Code(Expression(6, Add)) at (prev + 6, 9) to (start + 0, 16)
+ = (c1 + (c0 - c1))
+- Code(Counter(2)) at (prev + 1, 5) to (start + 5, 6)
+- Code(Expression(5, Sub)) at (prev + 7, 5) to (start + 5, 6)
+ = ((c1 + (c0 - c1)) - c2)
+- Code(Expression(4, Add)) at (prev + 6, 1) to (start + 0, 2)
+ = (c2 + ((c1 + (c0 - c1)) - c2))
+
diff --git a/tests/coverage-map/status-quo/if_else.rs b/tests/coverage-map/status-quo/if_else.rs
new file mode 100644
index 000000000..3244e1e3a
--- /dev/null
+++ b/tests/coverage-map/status-quo/if_else.rs
@@ -0,0 +1,40 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+ if
+ is_true
+ {
+ countdown
+ =
+ 10
+ ;
+ }
+ else // Note coverage region difference without semicolon
+ {
+ countdown
+ =
+ 100
+ }
+
+ if
+ is_true
+ {
+ countdown
+ =
+ 10
+ ;
+ }
+ else
+ {
+ countdown
+ =
+ 100
+ ;
+ }
+}
diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/status-quo/inline-dead.cov-map
new file mode 100644
index 000000000..dec43d3e8
--- /dev/null
+++ b/tests/coverage-map/status-quo/inline-dead.cov-map
@@ -0,0 +1,45 @@
+Function name: inline_dead::dead (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 19, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 2)
+
+Function name: inline_dead::live::<false>
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9)
+- Code(Zero) at (prev + 2, 9) to (start + 0, 15)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: inline_dead::main
+Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 04, 01, 03, 0d, 03, 07, 06, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 4, 1) to (start + 3, 13)
+- Code(Expression(0, Add)) at (prev + 7, 6) to (start + 2, 2)
+ = (c0 + Zero)
+
+Function name: inline_dead::main::{closure#0}
+Raw bytes (16): 0x[01, 01, 01, 01, 05, 02, 00, 09, 0d, 00, 0e, 03, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 2
+- Code(Zero) at (prev + 9, 13) to (start + 0, 14)
+- Code(Expression(0, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (c0 + c1)
+
diff --git a/tests/coverage-map/status-quo/inline-dead.rs b/tests/coverage-map/status-quo/inline-dead.rs
new file mode 100644
index 000000000..854fa0629
--- /dev/null
+++ b/tests/coverage-map/status-quo/inline-dead.rs
@@ -0,0 +1,27 @@
+// Regression test for issue #98833.
+// compile-flags: -Zinline-mir -Cdebug-assertions=off
+
+fn main() {
+ println!("{}", live::<false>());
+
+ let f = |x: bool| {
+ debug_assert!(
+ x
+ );
+ };
+ f(false);
+}
+
+#[inline]
+fn live<const B: bool>() -> u32 {
+ if B {
+ dead()
+ } else {
+ 0
+ }
+}
+
+#[inline]
+fn dead() -> u32 {
+ 42
+}
diff --git a/tests/coverage-map/status-quo/inline.cov-map b/tests/coverage-map/status-quo/inline.cov-map
new file mode 100644
index 000000000..57ae85623
--- /dev/null
+++ b/tests/coverage-map/status-quo/inline.cov-map
@@ -0,0 +1,82 @@
+Function name: inline::display::<char>
+Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 00, 03, 05, 05, 01, 29, 01, 00, 22, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 10, 07, 00, 11, 02, 06, 0a, 03, 05, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 3
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Zero
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(1)
+Number of file 0 mappings: 5
+- Code(Counter(0)) at (prev + 41, 1) to (start + 0, 34)
+- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 10)
+- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 16)
+ = (c0 + c1)
+- Code(Expression(1, Add)) at (prev + 0, 17) to (start + 2, 6)
+ = (c1 + Zero)
+- Code(Expression(2, Sub)) at (prev + 3, 5) to (start + 1, 2)
+ = ((c0 + c1) - c1)
+
+Function name: inline::error
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 49, 1) to (start + 2, 2)
+
+Function name: inline::length::<char>
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 2)
+
+Function name: inline::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 5, 1) to (start + 2, 2)
+
+Function name: inline::permutate::<char>
+Raw bytes (54): 0x[01, 01, 05, 01, 05, 02, 0d, 11, 00, 05, 13, 09, 0d, 08, 01, 0f, 01, 02, 0e, 05, 02, 0f, 02, 06, 02, 02, 0f, 00, 14, 11, 01, 0d, 00, 0e, 06, 00, 12, 00, 16, 0b, 00, 17, 04, 0a, 0d, 05, 0c, 02, 06, 0f, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 5
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(3)
+- expression 2 operands: lhs = Counter(4), rhs = Zero
+- expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add)
+- expression 4 operands: lhs = Counter(2), rhs = Counter(3)
+Number of file 0 mappings: 8
+- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 14)
+- Code(Counter(1)) at (prev + 2, 15) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 15) to (start + 0, 20)
+ = (c0 - c1)
+- Code(Counter(4)) at (prev + 1, 13) to (start + 0, 14)
+- Code(Expression(1, Sub)) at (prev + 0, 18) to (start + 0, 22)
+ = ((c0 - c1) - c3)
+- Code(Expression(2, Add)) at (prev + 0, 23) to (start + 4, 10)
+ = (c4 + Zero)
+- Code(Counter(3)) at (prev + 5, 12) to (start + 2, 6)
+- Code(Expression(3, Add)) at (prev + 3, 1) to (start + 0, 2)
+ = (c1 + (c2 + c3))
+
+Function name: inline::permutations::<char>
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 03, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 10, 1) to (start + 3, 2)
+
+Function name: inline::swap::<char>
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 01, 04, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 35, 1) to (start + 4, 2)
+
diff --git a/tests/coverage-map/status-quo/inline.rs b/tests/coverage-map/status-quo/inline.rs
new file mode 100644
index 000000000..9cfab9ddb
--- /dev/null
+++ b/tests/coverage-map/status-quo/inline.rs
@@ -0,0 +1,51 @@
+// compile-flags: -Zinline-mir
+
+use std::fmt::Display;
+
+fn main() {
+ permutations(&['a', 'b', 'c']);
+}
+
+#[inline(always)]
+fn permutations<T: Copy + Display>(xs: &[T]) {
+ let mut ys = xs.to_owned();
+ permutate(&mut ys, 0);
+}
+
+fn permutate<T: Copy + Display>(xs: &mut [T], k: usize) {
+ let n = length(xs);
+ if k == n {
+ display(xs);
+ } else if k < n {
+ for i in k..n {
+ swap(xs, i, k);
+ permutate(xs, k + 1);
+ swap(xs, i, k);
+ }
+ } else {
+ error();
+ }
+}
+
+fn length<T>(xs: &[T]) -> usize {
+ xs.len()
+}
+
+#[inline]
+fn swap<T: Copy>(xs: &mut [T], i: usize, j: usize) {
+ let t = xs[i];
+ xs[i] = xs[j];
+ xs[j] = t;
+}
+
+fn display<T: Display>(xs: &[T]) {
+ for x in xs {
+ print!("{}", x);
+ }
+ println!();
+}
+
+#[inline(always)]
+fn error() {
+ panic!("error");
+}
diff --git a/tests/coverage-map/status-quo/inner_items.cov-map b/tests/coverage-map/status-quo/inner_items.cov-map
new file mode 100644
index 000000000..3f39d74ef
--- /dev/null
+++ b/tests/coverage-map/status-quo/inner_items.cov-map
@@ -0,0 +1,49 @@
+Function name: <inner_items::main::InStruct as inner_items::main::InTrait>::default_trait_func
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 09, 03, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 33, 9) to (start + 3, 10)
+
+Function name: <inner_items::main::InStruct as inner_items::main::InTrait>::trait_func
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 28, 09, 03, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 40, 9) to (start + 3, 10)
+
+Function name: inner_items::main
+Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 1b, 24, 08, 00, 0f, 09, 00, 10, 02, 06, 16, 02, 06, 00, 07, 13, 02, 09, 05, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 7
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2)
+- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub)
+- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 7
+- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15)
+- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(6, Add)) at (prev + 36, 8) to (start + 0, 15)
+ = (c1 + (c0 - c1))
+- Code(Counter(2)) at (prev + 0, 16) to (start + 2, 6)
+- Code(Expression(5, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = ((c1 + (c0 - c1)) - c2)
+- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 5, 2)
+ = (c2 + ((c1 + (c0 - c1)) - c2))
+
+Function name: inner_items::main::in_func
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 12, 05, 04, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 18, 5) to (start + 4, 6)
+
diff --git a/tests/coverage-map/status-quo/inner_items.rs b/tests/coverage-map/status-quo/inner_items.rs
new file mode 100644
index 000000000..bcb62b303
--- /dev/null
+++ b/tests/coverage-map/status-quo/inner_items.rs
@@ -0,0 +1,57 @@
+#![allow(unused_assignments, unused_variables, dead_code)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+ if is_true {
+ countdown = 10;
+ }
+
+ mod in_mod {
+ const IN_MOD_CONST: u32 = 1000;
+ }
+
+ fn in_func(a: u32) {
+ let b = 1;
+ let c = a + b;
+ println!("c = {}", c)
+ }
+
+ struct InStruct {
+ in_struct_field: u32,
+ }
+
+ const IN_CONST: u32 = 1234;
+
+ trait InTrait {
+ fn trait_func(&mut self, incr: u32);
+
+ fn default_trait_func(&mut self) {
+ in_func(IN_CONST);
+ self.trait_func(IN_CONST);
+ }
+ }
+
+ impl InTrait for InStruct {
+ fn trait_func(&mut self, incr: u32) {
+ self.in_struct_field += incr;
+ in_func(self.in_struct_field);
+ }
+ }
+
+ type InType = String;
+
+ if is_true {
+ in_func(countdown);
+ }
+
+ let mut val = InStruct {
+ in_struct_field: 101,
+ };
+
+ val.default_trait_func();
+}
diff --git a/tests/coverage-map/status-quo/issue-83601.cov-map b/tests/coverage-map/status-quo/issue-83601.cov-map
new file mode 100644
index 000000000..f5db3a897
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-83601.cov-map
@@ -0,0 +1,28 @@
+Function name: <issue_83601::Foo as core::cmp::PartialEq>::eq
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 11, 00, 1a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 3, 17) to (start + 0, 26)
+
+Function name: <issue_83601::Foo as core::fmt::Debug>::fmt
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 0a, 00, 0f]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 3, 10) to (start + 0, 15)
+
+Function name: issue_83601::main
+Raw bytes (21): 0x[01, 01, 01, 05, 09, 03, 01, 06, 01, 02, 1c, 05, 03, 09, 01, 1c, 02, 02, 05, 03, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 6, 1) to (start + 2, 28)
+- Code(Counter(1)) at (prev + 3, 9) to (start + 1, 28)
+- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 3, 2)
+ = (c1 - c2)
+
diff --git a/tests/coverage-map/status-quo/issue-83601.rs b/tests/coverage-map/status-quo/issue-83601.rs
new file mode 100644
index 000000000..0b72a8194
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-83601.rs
@@ -0,0 +1,14 @@
+// Shows that rust-lang/rust/83601 is resolved
+
+#[derive(Debug, PartialEq, Eq)]
+struct Foo(u32);
+
+fn main() {
+ let bar = Foo(1);
+ assert_eq!(bar, Foo(1));
+ let baz = Foo(0);
+ assert_ne!(baz, Foo(1));
+ println!("{:?}", Foo(1));
+ println!("{:?}", bar);
+ println!("{:?}", baz);
+}
diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map
new file mode 100644
index 000000000..fe098fd39
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-84561.cov-map
@@ -0,0 +1,233 @@
+Function name: <issue_84561::Foo as core::cmp::PartialEq>::eq
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 0a, 00, 13, 00, 00, 0a, 00, 13]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 19)
+- Code(Zero) at (prev + 0, 10) to (start + 0, 19)
+
+Function name: <issue_84561::Foo as core::fmt::Debug>::fmt
+Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 89, 01, 09, 00, 25, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 137, 9) to (start + 0, 37)
+- Code(Counter(1)) at (prev + 0, 37) to (start + 0, 38)
+- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 0, 6)
+ = (c1 + (c0 - c1))
+
+Function name: issue_84561::main
+Raw bytes (10): 0x[01, 01, 00, 01, 01, b2, 01, 01, 04, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 178, 1) to (start + 4, 2)
+
+Function name: issue_84561::test1
+Raw bytes (78): 0x[01, 01, 0e, 05, 06, 01, 05, 09, 36, 03, 09, 0d, 2e, 33, 0d, 09, 36, 03, 09, 11, 26, 2b, 11, 0d, 2e, 33, 0d, 09, 36, 03, 09, 09, 01, 98, 01, 01, 01, 0b, 05, 01, 0c, 00, 1e, 03, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 33, 01, 0d, 01, 0b, 0d, 01, 0c, 00, 1e, 2b, 01, 05, 03, 0b, 11, 03, 0c, 00, 1e, 23, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 14
+- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 2 operands: lhs = Counter(2), rhs = Expression(13, Sub)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2)
+- expression 4 operands: lhs = Counter(3), rhs = Expression(11, Sub)
+- expression 5 operands: lhs = Expression(12, Add), rhs = Counter(3)
+- expression 6 operands: lhs = Counter(2), rhs = Expression(13, Sub)
+- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(2)
+- expression 8 operands: lhs = Counter(4), rhs = Expression(9, Sub)
+- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(4)
+- expression 10 operands: lhs = Counter(3), rhs = Expression(11, Sub)
+- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(3)
+- expression 12 operands: lhs = Counter(2), rhs = Expression(13, Sub)
+- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(2)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 152, 1) to (start + 1, 11)
+- Code(Counter(1)) at (prev + 1, 12) to (start + 0, 30)
+- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 11)
+ = (c1 + (c0 - c1))
+- Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30)
+- Code(Expression(12, Add)) at (prev + 1, 13) to (start + 1, 11)
+ = (c2 + ((c1 + (c0 - c1)) - c2))
+- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 30)
+- Code(Expression(10, Add)) at (prev + 1, 5) to (start + 3, 11)
+ = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3))
+- Code(Counter(4)) at (prev + 3, 12) to (start + 0, 30)
+- Code(Expression(8, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4))
+
+Function name: issue_84561::test2
+Raw bytes (24): 0x[01, 01, 02, 05, 06, 01, 05, 03, 01, ae, 01, 01, 01, 10, 05, 01, 11, 00, 23, 03, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub)
+- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 174, 1) to (start + 1, 16)
+- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 35)
+- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: issue_84561::test2::call_print
+Raw bytes (10): 0x[01, 01, 00, 01, 01, a5, 01, 09, 02, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 165, 9) to (start + 2, 10)
+
+Function name: issue_84561::test3
+Raw bytes (437): 0x[01, 01, 41, 05, 09, 0d, 11, 15, 19, 12, 1d, 15, 19, 21, 25, 1e, 29, 21, 25, 31, 39, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 4d, 3f, 51, 42, 49, 45, 4d, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 92, 01, 55, 51, 59, 8f, 01, 5d, 92, 01, 55, 51, 59, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 81, 01, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 06, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 65
+- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 1 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 2 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7)
+- expression 4 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 5 operands: lhs = Counter(8), rhs = Counter(9)
+- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(10)
+- expression 7 operands: lhs = Counter(8), rhs = Counter(9)
+- expression 8 operands: lhs = Counter(12), rhs = Counter(14)
+- expression 9 operands: lhs = Counter(15), rhs = Counter(16)
+- expression 10 operands: lhs = Expression(11, Sub), rhs = Counter(17)
+- expression 11 operands: lhs = Counter(15), rhs = Counter(16)
+- expression 12 operands: lhs = Expression(16, Sub), rhs = Counter(18)
+- expression 13 operands: lhs = Counter(17), rhs = Counter(19)
+- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20)
+- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18)
+- expression 16 operands: lhs = Counter(17), rhs = Counter(19)
+- expression 17 operands: lhs = Counter(23), rhs = Expression(34, Sub)
+- expression 18 operands: lhs = Expression(35, Add), rhs = Counter(23)
+- expression 19 operands: lhs = Expression(36, Sub), rhs = Counter(21)
+- expression 20 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 21 operands: lhs = Expression(36, Sub), rhs = Counter(21)
+- expression 22 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 23 operands: lhs = Expression(35, Add), rhs = Counter(23)
+- expression 24 operands: lhs = Expression(36, Sub), rhs = Counter(21)
+- expression 25 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 26 operands: lhs = Expression(33, Add), rhs = Counter(24)
+- expression 27 operands: lhs = Counter(23), rhs = Expression(34, Sub)
+- expression 28 operands: lhs = Expression(35, Add), rhs = Counter(23)
+- expression 29 operands: lhs = Expression(36, Sub), rhs = Counter(21)
+- expression 30 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(25)
+- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(24)
+- expression 33 operands: lhs = Counter(23), rhs = Expression(34, Sub)
+- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(23)
+- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(21)
+- expression 36 operands: lhs = Counter(20), rhs = Counter(22)
+- expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub)
+- expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30)
+- expression 39 operands: lhs = Counter(28), rhs = Expression(63, Sub)
+- expression 40 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 41 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 42 operands: lhs = Counter(28), rhs = Expression(63, Sub)
+- expression 43 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 44 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 45 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 46 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 47 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 48 operands: lhs = Expression(62, Add), rhs = Counter(30)
+- expression 49 operands: lhs = Counter(28), rhs = Expression(63, Sub)
+- expression 50 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 51 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 52 operands: lhs = Expression(60, Add), rhs = Counter(31)
+- expression 53 operands: lhs = Counter(29), rhs = Expression(61, Sub)
+- expression 54 operands: lhs = Expression(62, Add), rhs = Counter(30)
+- expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub)
+- expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 57 operands: lhs = Counter(26), rhs = Counter(27)
+- expression 58 operands: lhs = Expression(59, Sub), rhs = Counter(32)
+- expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31)
+- expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub)
+- expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30)
+- expression 62 operands: lhs = Counter(28), rhs = Expression(63, Sub)
+- expression 63 operands: lhs = Expression(64, Sub), rhs = Counter(28)
+- expression 64 operands: lhs = Counter(26), rhs = Counter(27)
+Number of file 0 mappings: 51
+- Code(Counter(0)) at (prev + 6, 1) to (start + 3, 28)
+- Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28)
+- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 4, 31)
+ = (c1 - c2)
+- Code(Counter(3)) at (prev + 5, 5) to (start + 0, 31)
+- Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31)
+ = (c3 - c4)
+- Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28)
+- Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31)
+ = (c5 - c6)
+- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15)
+ = ((c5 - c6) - c7)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 48)
+- Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15)
+- Code(Zero) at (prev + 3, 32) to (start + 0, 48)
+- Code(Zero) at (prev + 0, 51) to (start + 0, 65)
+- Code(Zero) at (prev + 0, 75) to (start + 0, 90)
+- Code(Expression(7, Sub)) at (prev + 1, 5) to (start + 0, 15)
+ = (c8 - c9)
+- Code(Zero) at (prev + 5, 9) to (start + 3, 16)
+- Code(Zero) at (prev + 5, 13) to (start + 0, 27)
+- Code(Zero) at (prev + 2, 13) to (start + 0, 28)
+- Code(Expression(6, Sub)) at (prev + 4, 9) to (start + 5, 6)
+ = ((c8 - c9) - c10)
+- Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6)
+- Code(Expression(8, Sub)) at (prev + 4, 5) to (start + 3, 6)
+ = (c12 - c14)
+- Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6)
+- Code(Expression(11, Sub)) at (prev + 5, 8) to (start + 0, 15)
+ = (c15 - c16)
+- Code(Counter(17)) at (prev + 1, 9) to (start + 3, 10)
+- Code(Expression(10, Sub)) at (prev + 5, 9) to (start + 3, 10)
+ = ((c15 - c16) - c17)
+- Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15)
+ = ((c17 - c19) + c18)
+- Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19)
+- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
+- Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19)
+ = (((c17 - c19) + c18) - c20)
+- Code(Zero) at (prev + 3, 13) to (start + 0, 29)
+- Code(Expression(33, Add)) at (prev + 3, 5) to (start + 0, 15)
+ = (c23 + (((c20 - c22) + c21) - c23))
+- Code(Expression(35, Add)) at (prev + 1, 12) to (start + 0, 19)
+ = ((c20 - c22) + c21)
+- Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19)
+- Code(Expression(34, Sub)) at (prev + 2, 13) to (start + 0, 19)
+ = (((c20 - c22) + c21) - c23)
+- Code(Expression(32, Sub)) at (prev + 4, 5) to (start + 2, 19)
+ = ((c23 + (((c20 - c22) + c21) - c23)) - c24)
+- Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19)
+- Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19)
+ = (((c23 + (((c20 - c22) + c21) - c23)) - c24) - c25)
+- Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15)
+ = (c29 + ((c28 + ((c26 - c27) - c28)) - c30))
+- Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19)
+- Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14)
+- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19)
+- Code(Expression(62, Add)) at (prev + 2, 13) to (start + 0, 23)
+ = (c28 + ((c26 - c27) - c28))
+- Code(Expression(64, Sub)) at (prev + 1, 20) to (start + 0, 27)
+ = (c26 - c27)
+- Code(Counter(28)) at (prev + 1, 21) to (start + 0, 27)
+- Code(Expression(63, Sub)) at (prev + 2, 21) to (start + 0, 27)
+ = ((c26 - c27) - c28)
+- Code(Expression(61, Sub)) at (prev + 4, 13) to (start + 0, 19)
+ = ((c28 + ((c26 - c27) - c28)) - c30)
+- Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25)
+- Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15)
+ = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31)
+- Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34)
+ = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - c32)
+- Code(Zero) at (prev + 2, 5) to (start + 0, 15)
+- Code(Zero) at (prev + 3, 9) to (start + 0, 44)
+- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
+
diff --git a/tests/coverage-map/status-quo/issue-84561.rs b/tests/coverage-map/status-quo/issue-84561.rs
new file mode 100644
index 000000000..facf5b5b4
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-84561.rs
@@ -0,0 +1,182 @@
+// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
+
+// failure-status: 101
+#[derive(PartialEq, Eq)]
+struct Foo(u32);
+fn test3() {
+ let is_true = std::env::args().len() == 1;
+ let bar = Foo(1);
+ assert_eq!(bar, Foo(1));
+ let baz = Foo(0);
+ assert_ne!(baz, Foo(1));
+ println!("{:?}", Foo(1));
+ println!("{:?}", bar);
+ println!("{:?}", baz);
+
+ assert_eq!(Foo(1), Foo(1));
+ assert_ne!(Foo(0), Foo(1));
+ assert_eq!(Foo(2), Foo(2));
+ let bar = Foo(0);
+ assert_ne!(bar, Foo(3));
+ assert_ne!(Foo(0), Foo(4));
+ assert_eq!(Foo(3), Foo(3), "with a message");
+ println!("{:?}", bar);
+ println!("{:?}", Foo(1));
+
+ assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
+ assert_ne!(
+ Foo(0)
+ ,
+ Foo(5)
+ ,
+ "{}"
+ ,
+ if
+ is_true
+ {
+ "true message"
+ } else {
+ "false message"
+ }
+ );
+
+ let is_true = std::env::args().len() == 1;
+
+ assert_eq!(
+ Foo(1),
+ Foo(1)
+ );
+ assert_ne!(
+ Foo(0),
+ Foo(1)
+ );
+ assert_eq!(
+ Foo(2),
+ Foo(2)
+ );
+ let bar = Foo(1);
+ assert_ne!(
+ bar,
+ Foo(3)
+ );
+ if is_true {
+ assert_ne!(
+ Foo(0),
+ Foo(4)
+ );
+ } else {
+ assert_eq!(
+ Foo(3),
+ Foo(3)
+ );
+ }
+ if is_true {
+ assert_ne!(
+ Foo(0),
+ Foo(4),
+ "with a message"
+ );
+ } else {
+ assert_eq!(
+ Foo(3),
+ Foo(3),
+ "with a message"
+ );
+ }
+ assert_ne!(
+ if is_true {
+ Foo(0)
+ } else {
+ Foo(1)
+ },
+ Foo(5)
+ );
+ assert_ne!(
+ Foo(5),
+ if is_true {
+ Foo(0)
+ } else {
+ Foo(1)
+ }
+ );
+ assert_ne!(
+ if is_true {
+ assert_eq!(
+ Foo(3),
+ Foo(3)
+ );
+ Foo(0)
+ } else {
+ assert_ne!(
+ if is_true {
+ Foo(0)
+ } else {
+ Foo(1)
+ },
+ Foo(5)
+ );
+ Foo(1)
+ },
+ Foo(5),
+ "with a message"
+ );
+ assert_eq!(
+ Foo(1),
+ Foo(3),
+ "this assert should fail"
+ );
+ assert_eq!(
+ Foo(3),
+ Foo(3),
+ "this assert should not be reached"
+ );
+}
+
+impl std::fmt::Debug for Foo {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "try and succeed")?;
+ Ok(())
+ }
+}
+
+static mut DEBUG_LEVEL_ENABLED: bool = false;
+
+macro_rules! debug {
+ ($($arg:tt)+) => (
+ if unsafe { DEBUG_LEVEL_ENABLED } {
+ println!($($arg)+);
+ }
+ );
+}
+
+fn test1() {
+ debug!("debug is enabled");
+ debug!("debug is enabled");
+ let _ = 0;
+ debug!("debug is enabled");
+ unsafe {
+ DEBUG_LEVEL_ENABLED = true;
+ }
+ debug!("debug is enabled");
+}
+
+macro_rules! call_debug {
+ ($($arg:tt)+) => (
+ fn call_print(s: &str) {
+ print!("{}", s);
+ }
+
+ call_print("called from call_debug: ");
+ debug!($($arg)+);
+ );
+}
+
+fn test2() {
+ call_debug!("debug is enabled");
+}
+
+fn main() {
+ test1();
+ test2();
+ test3();
+}
diff --git a/tests/coverage-map/status-quo/issue-93054.cov-map b/tests/coverage-map/status-quo/issue-93054.cov-map
new file mode 100644
index 000000000..52fe7f58d
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-93054.cov-map
@@ -0,0 +1,24 @@
+Function name: issue_93054::foo2 (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 00, 1d]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 22, 1) to (start + 0, 29)
+
+Function name: issue_93054::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 00, 0d]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 30, 1) to (start + 0, 13)
+
+Function name: issue_93054::make (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1a, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 26, 1) to (start + 2, 2)
+
diff --git a/tests/coverage-map/status-quo/issue-93054.rs b/tests/coverage-map/status-quo/issue-93054.rs
new file mode 100644
index 000000000..da546cfee
--- /dev/null
+++ b/tests/coverage-map/status-quo/issue-93054.rs
@@ -0,0 +1,30 @@
+#![allow(dead_code, unreachable_code)]
+
+// Regression test for #93054: Functions using uninhabited types often only have a single,
+// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
+// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.
+
+// compile-flags: --edition=2021
+
+enum Never {}
+
+impl Never {
+ fn foo(self) {
+ match self {}
+ make().map(|never| match never {});
+ }
+
+ fn bar(&self) {
+ match *self {}
+ }
+}
+
+async fn foo2(never: Never) {
+ match never {}
+}
+
+fn make() -> Option<Never> {
+ None
+}
+
+fn main() {}
diff --git a/tests/coverage-map/status-quo/lazy_boolean.cov-map b/tests/coverage-map/status-quo/lazy_boolean.cov-map
new file mode 100644
index 000000000..b18a96404
--- /dev/null
+++ b/tests/coverage-map/status-quo/lazy_boolean.cov-map
@@ -0,0 +1,223 @@
+Function name: lazy_boolean::main
+Raw bytes (646): 0x[01, 01, a8, 01, 01, 05, 09, 9a, 05, 9f, 05, 09, 05, 02, 05, 02, 9f, 05, 09, 05, 02, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 97, 05, 00, 09, 9a, 05, 9f, 05, 09, 05, 02, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 8f, 05, 00, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 87, 05, 00, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ff, 04, 00, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, e7, 04, 25, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 25, e2, 04, e7, 04, 25, 21, ea, 04, ef, 04, 21, 1d, f2, 04, f7, 04, 1d, 19, fa, 04, ff, 04, 19, 15, 82, 05, 87, 05, 15, 11, 8a, 05, 8f, 05, 11, 0d, 92, 05, 97, 05, 0d, 09, 9a, 05, 9f, 05, 09, 05, 02, 1c, 01, 03, 01, 07, 0f, 05, 07, 10, 04, 06, 02, 04, 06, 00, 07, 97, 05, 02, 09, 00, 11, 9f, 05, 02, 0d, 00, 12, 9a, 05, 02, 0d, 00, 12, 8f, 05, 03, 09, 00, 11, 33, 02, 0d, 00, 12, 92, 05, 02, 0d, 00, 12, 87, 05, 02, 09, 00, 11, 6f, 00, 14, 00, 19, 11, 00, 1d, 00, 22, ff, 04, 01, 09, 00, 11, ab, 01, 00, 14, 00, 19, 15, 00, 1d, 00, 22, cb, 01, 04, 09, 00, 10, fa, 04, 01, 05, 03, 06, 19, 03, 06, 00, 07, f7, 04, 03, 09, 00, 10, 1d, 01, 05, 03, 06, f2, 04, 05, 05, 03, 06, ef, 04, 05, 09, 00, 10, ea, 04, 00, 11, 02, 06, 21, 02, 06, 00, 07, e7, 04, 02, 08, 00, 0f, 25, 00, 10, 02, 06, e2, 04, 02, 0c, 02, 06, df, 04, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 168
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 2 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 5 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 7 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 8 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 9 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 10 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 11 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 12 operands: lhs = Expression(165, Add), rhs = Zero
+- expression 13 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 14 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 15 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 16 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 17 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 18 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 19 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 20 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 21 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 22 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 23 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 24 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 25 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 26 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 27 operands: lhs = Expression(163, Add), rhs = Zero
+- expression 28 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 29 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 30 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 31 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 32 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 33 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 34 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 35 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 36 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 37 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 38 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 39 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 40 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 41 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 42 operands: lhs = Expression(161, Add), rhs = Zero
+- expression 43 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 44 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 45 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 46 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 47 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 48 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 49 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 50 operands: lhs = Expression(159, Add), rhs = Zero
+- expression 51 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 52 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 53 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 54 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 55 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 56 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 57 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 58 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 59 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 60 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 61 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 62 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 63 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 64 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 65 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 66 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 67 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 68 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 69 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 70 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 71 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 72 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 73 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 74 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 75 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 76 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 77 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 78 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 79 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 80 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 81 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 82 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 83 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 84 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 85 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 86 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 87 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 88 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 89 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 90 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 91 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 92 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 93 operands: lhs = Counter(7), rhs = Expression(156, Sub)
+- expression 94 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 95 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 96 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 97 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 98 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 99 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 100 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 101 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 102 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 103 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 104 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 105 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 106 operands: lhs = Expression(155, Add), rhs = Counter(8)
+- expression 107 operands: lhs = Counter(7), rhs = Expression(156, Sub)
+- expression 108 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 109 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 110 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 111 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 112 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 113 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 114 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 115 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 116 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 117 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 118 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 119 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 120 operands: lhs = Counter(8), rhs = Expression(154, Sub)
+- expression 121 operands: lhs = Expression(155, Add), rhs = Counter(8)
+- expression 122 operands: lhs = Counter(7), rhs = Expression(156, Sub)
+- expression 123 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 124 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 125 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 126 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 127 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 128 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 129 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 130 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 131 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 132 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 133 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 134 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 135 operands: lhs = Expression(153, Add), rhs = Counter(9)
+- expression 136 operands: lhs = Counter(8), rhs = Expression(154, Sub)
+- expression 137 operands: lhs = Expression(155, Add), rhs = Counter(8)
+- expression 138 operands: lhs = Counter(7), rhs = Expression(156, Sub)
+- expression 139 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 140 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 141 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 142 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 143 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 144 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 145 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 146 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 147 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 148 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 149 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 150 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 151 operands: lhs = Counter(9), rhs = Expression(152, Sub)
+- expression 152 operands: lhs = Expression(153, Add), rhs = Counter(9)
+- expression 153 operands: lhs = Counter(8), rhs = Expression(154, Sub)
+- expression 154 operands: lhs = Expression(155, Add), rhs = Counter(8)
+- expression 155 operands: lhs = Counter(7), rhs = Expression(156, Sub)
+- expression 156 operands: lhs = Expression(157, Add), rhs = Counter(7)
+- expression 157 operands: lhs = Counter(6), rhs = Expression(158, Sub)
+- expression 158 operands: lhs = Expression(159, Add), rhs = Counter(6)
+- expression 159 operands: lhs = Counter(5), rhs = Expression(160, Sub)
+- expression 160 operands: lhs = Expression(161, Add), rhs = Counter(5)
+- expression 161 operands: lhs = Counter(4), rhs = Expression(162, Sub)
+- expression 162 operands: lhs = Expression(163, Add), rhs = Counter(4)
+- expression 163 operands: lhs = Counter(3), rhs = Expression(164, Sub)
+- expression 164 operands: lhs = Expression(165, Add), rhs = Counter(3)
+- expression 165 operands: lhs = Counter(2), rhs = Expression(166, Sub)
+- expression 166 operands: lhs = Expression(167, Add), rhs = Counter(2)
+- expression 167 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 28
+- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15)
+- Code(Counter(1)) at (prev + 7, 16) to (start + 4, 6)
+- Code(Expression(0, Sub)) at (prev + 4, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(165, Add)) at (prev + 2, 9) to (start + 0, 17)
+ = (c2 + ((c1 + (c0 - c1)) - c2))
+- Code(Expression(167, Add)) at (prev + 2, 13) to (start + 0, 18)
+ = (c1 + (c0 - c1))
+- Code(Expression(166, Sub)) at (prev + 2, 13) to (start + 0, 18)
+ = ((c1 + (c0 - c1)) - c2)
+- Code(Expression(163, Add)) at (prev + 3, 9) to (start + 0, 17)
+ = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3))
+- Code(Expression(12, Add)) at (prev + 2, 13) to (start + 0, 18)
+ = ((c2 + ((c1 + (c0 - c1)) - c2)) + Zero)
+- Code(Expression(164, Sub)) at (prev + 2, 13) to (start + 0, 18)
+ = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)
+- Code(Expression(161, Add)) at (prev + 2, 9) to (start + 0, 17)
+ = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4))
+- Code(Expression(27, Add)) at (prev + 0, 20) to (start + 0, 25)
+ = ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) + Zero)
+- Code(Counter(4)) at (prev + 0, 29) to (start + 0, 34)
+- Code(Expression(159, Add)) at (prev + 1, 9) to (start + 0, 17)
+ = (c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5))
+- Code(Expression(42, Add)) at (prev + 0, 20) to (start + 0, 25)
+ = ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) + Zero)
+- Code(Counter(5)) at (prev + 0, 29) to (start + 0, 34)
+- Code(Expression(50, Add)) at (prev + 4, 9) to (start + 0, 16)
+ = ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) + Zero)
+- Code(Expression(158, Sub)) at (prev + 1, 5) to (start + 3, 6)
+ = ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)
+- Code(Counter(6)) at (prev + 3, 6) to (start + 0, 7)
+- Code(Expression(157, Add)) at (prev + 3, 9) to (start + 0, 16)
+ = (c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6))
+- Code(Counter(7)) at (prev + 1, 5) to (start + 3, 6)
+- Code(Expression(156, Sub)) at (prev + 5, 5) to (start + 3, 6)
+ = ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)
+- Code(Expression(155, Add)) at (prev + 5, 9) to (start + 0, 16)
+ = (c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7))
+- Code(Expression(154, Sub)) at (prev + 0, 17) to (start + 2, 6)
+ = ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)
+- Code(Counter(8)) at (prev + 2, 6) to (start + 0, 7)
+- Code(Expression(153, Add)) at (prev + 2, 8) to (start + 0, 15)
+ = (c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8))
+- Code(Counter(9)) at (prev + 0, 16) to (start + 2, 6)
+- Code(Expression(152, Sub)) at (prev + 2, 12) to (start + 2, 6)
+ = ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9)
+- Code(Expression(151, Add)) at (prev + 3, 1) to (start + 0, 2)
+ = (c9 + ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9))
+
diff --git a/tests/coverage-map/status-quo/lazy_boolean.rs b/tests/coverage-map/status-quo/lazy_boolean.rs
new file mode 100644
index 000000000..bb6219e85
--- /dev/null
+++ b/tests/coverage-map/status-quo/lazy_boolean.rs
@@ -0,0 +1,61 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let (mut a, mut b, mut c) = (0, 0, 0);
+ if is_true {
+ a = 1;
+ b = 10;
+ c = 100;
+ }
+ let
+ somebool
+ =
+ a < b
+ ||
+ b < c
+ ;
+ let
+ somebool
+ =
+ b < a
+ ||
+ b < c
+ ;
+ let somebool = a < b && b < c;
+ let somebool = b < a && b < c;
+
+ if
+ !
+ is_true
+ {
+ a = 2
+ ;
+ }
+
+ if
+ is_true
+ {
+ b = 30
+ ;
+ }
+ else
+ {
+ c = 400
+ ;
+ }
+
+ if !is_true {
+ a = 2;
+ }
+
+ if is_true {
+ b = 30;
+ } else {
+ c = 400;
+ }
+}
diff --git a/tests/coverage-map/status-quo/loop_break_value.cov-map b/tests/coverage-map/status-quo/loop_break_value.cov-map
new file mode 100644
index 000000000..75018442d
--- /dev/null
+++ b/tests/coverage-map/status-quo/loop_break_value.cov-map
@@ -0,0 +1,8 @@
+Function name: loop_break_value::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 01, 0a, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 3, 1) to (start + 10, 2)
+
diff --git a/tests/coverage-map/status-quo/loop_break_value.rs b/tests/coverage-map/status-quo/loop_break_value.rs
new file mode 100644
index 000000000..dbc4fad7a
--- /dev/null
+++ b/tests/coverage-map/status-quo/loop_break_value.rs
@@ -0,0 +1,13 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ let result
+ =
+ loop
+ {
+ break
+ 10
+ ;
+ }
+ ;
+}
diff --git a/tests/coverage-map/status-quo/loops_branches.cov-map b/tests/coverage-map/status-quo/loops_branches.cov-map
new file mode 100644
index 000000000..480bbfd97
--- /dev/null
+++ b/tests/coverage-map/status-quo/loops_branches.cov-map
@@ -0,0 +1,185 @@
+Function name: <loops_branches::DebugTest as core::fmt::Debug>::fmt
+Raw bytes (251): 0x[01, 01, 32, 05, 09, 00, 02, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, c3, 01, c7, 01, 0d, 00, 11, 15, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, ba, 01, 15, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, b6, 01, 1d, ba, 01, 15, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 15, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, af, 01, 11, 00, b2, 01, b6, 01, 1d, ba, 01, 15, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, 25, a7, 01, aa, 01, 19, af, 01, 11, 00, b2, 01, b6, 01, 1d, ba, 01, 15, bf, 01, 19, c3, 01, c7, 01, 0d, 00, 11, 15, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, ba, 01, 03, 0d, 00, 0e, bf, 01, 00, 12, 00, 17, 27, 01, 10, 00, 14, b6, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b2, 01, 01, 12, 00, 13, af, 01, 01, 11, 00, 22, aa, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, a3, 01, 01, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 50
+- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub)
+- expression 2 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 3 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 4 operands: lhs = Counter(3), rhs = Zero
+- expression 5 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 6 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 7 operands: lhs = Counter(3), rhs = Zero
+- expression 8 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 9 operands: lhs = Expression(46, Sub), rhs = Zero
+- expression 10 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 11 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 12 operands: lhs = Counter(3), rhs = Zero
+- expression 13 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 14 operands: lhs = Expression(46, Sub), rhs = Counter(5)
+- expression 15 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 16 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 17 operands: lhs = Counter(3), rhs = Zero
+- expression 18 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 19 operands: lhs = Expression(45, Sub), rhs = Counter(7)
+- expression 20 operands: lhs = Expression(46, Sub), rhs = Counter(5)
+- expression 21 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 22 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 23 operands: lhs = Counter(3), rhs = Zero
+- expression 24 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 25 operands: lhs = Zero, rhs = Expression(44, Sub)
+- expression 26 operands: lhs = Expression(45, Sub), rhs = Counter(7)
+- expression 27 operands: lhs = Expression(46, Sub), rhs = Counter(5)
+- expression 28 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 29 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 30 operands: lhs = Counter(3), rhs = Zero
+- expression 31 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 32 operands: lhs = Expression(43, Add), rhs = Counter(4)
+- expression 33 operands: lhs = Zero, rhs = Expression(44, Sub)
+- expression 34 operands: lhs = Expression(45, Sub), rhs = Counter(7)
+- expression 35 operands: lhs = Expression(46, Sub), rhs = Counter(5)
+- expression 36 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 37 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 38 operands: lhs = Counter(3), rhs = Zero
+- expression 39 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 40 operands: lhs = Counter(9), rhs = Expression(41, Add)
+- expression 41 operands: lhs = Expression(42, Sub), rhs = Counter(6)
+- expression 42 operands: lhs = Expression(43, Add), rhs = Counter(4)
+- expression 43 operands: lhs = Zero, rhs = Expression(44, Sub)
+- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(7)
+- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(5)
+- expression 46 operands: lhs = Expression(47, Add), rhs = Counter(6)
+- expression 47 operands: lhs = Expression(48, Add), rhs = Expression(49, Add)
+- expression 48 operands: lhs = Counter(3), rhs = Zero
+- expression 49 operands: lhs = Counter(4), rhs = Counter(5)
+Number of file 0 mappings: 20
+- Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16)
+- Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21)
+- Code(Zero) at (prev + 1, 23) to (start + 0, 27)
+- Code(Zero) at (prev + 0, 28) to (start + 0, 30)
+- Code(Expression(0, Sub)) at (prev + 1, 14) to (start + 0, 15)
+ = (c1 - c2)
+- Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 30)
+ = (Zero + (c1 - c2))
+- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31)
+- Code(Zero) at (prev + 1, 16) to (start + 1, 10)
+- Code(Expression(46, Sub)) at (prev + 3, 13) to (start + 0, 14)
+ = (((c3 + Zero) + (c4 + c5)) - c6)
+- Code(Expression(47, Add)) at (prev + 0, 18) to (start + 0, 23)
+ = ((c3 + Zero) + (c4 + c5))
+- Code(Expression(9, Add)) at (prev + 1, 16) to (start + 0, 20)
+ = ((((c3 + Zero) + (c4 + c5)) - c6) + Zero)
+- Code(Expression(45, Sub)) at (prev + 1, 20) to (start + 0, 25)
+ = ((((c3 + Zero) + (c4 + c5)) - c6) - c5)
+- Code(Zero) at (prev + 1, 27) to (start + 0, 31)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 34)
+- Code(Expression(44, Sub)) at (prev + 1, 18) to (start + 0, 19)
+ = (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)
+- Code(Expression(43, Add)) at (prev + 1, 17) to (start + 0, 34)
+ = (Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7))
+- Code(Expression(42, Sub)) at (prev + 0, 34) to (start + 0, 35)
+ = ((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4)
+- Code(Zero) at (prev + 1, 20) to (start + 1, 14)
+- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15)
+- Code(Expression(40, Add)) at (prev + 1, 5) to (start + 0, 6)
+ = (c9 + (((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) + c6))
+
+Function name: <loops_branches::DisplayTest as core::fmt::Display>::fmt
+Raw bytes (255): 0x[01, 01, 34, 01, 05, 02, 09, 00, 0e, 02, 09, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, c7, 01, cb, 01, 05, 0d, 11, 15, be, 01, 00, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, be, 01, 11, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, ba, 01, 1d, be, 01, 11, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, 00, b6, 01, ba, 01, 1d, be, 01, 11, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, b3, 01, 15, 00, b6, 01, ba, 01, 1d, be, 01, 11, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, ae, 01, cf, 01, b3, 01, 15, 00, b6, 01, ba, 01, 1d, be, 01, 11, c3, 01, 19, c7, 01, cb, 01, 05, 0d, 11, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, be, 01, 02, 0d, 00, 0e, c3, 01, 00, 12, 00, 17, 2f, 01, 10, 00, 15, 00, 00, 16, 01, 0e, ba, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b6, 01, 01, 12, 00, 13, b3, 01, 01, 11, 00, 22, ae, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, ab, 01, 01, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 52
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2)
+- expression 2 operands: lhs = Zero, rhs = Expression(3, Sub)
+- expression 3 operands: lhs = Expression(0, Sub), rhs = Counter(2)
+- expression 4 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 5 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 6 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 7 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 8 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 9 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 10 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 11 operands: lhs = Expression(47, Sub), rhs = Zero
+- expression 12 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 13 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 14 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 15 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 16 operands: lhs = Expression(47, Sub), rhs = Counter(4)
+- expression 17 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 18 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 19 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 20 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 21 operands: lhs = Expression(46, Sub), rhs = Counter(7)
+- expression 22 operands: lhs = Expression(47, Sub), rhs = Counter(4)
+- expression 23 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 24 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 25 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 26 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 27 operands: lhs = Zero, rhs = Expression(45, Sub)
+- expression 28 operands: lhs = Expression(46, Sub), rhs = Counter(7)
+- expression 29 operands: lhs = Expression(47, Sub), rhs = Counter(4)
+- expression 30 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 31 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 32 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 33 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 34 operands: lhs = Expression(44, Add), rhs = Counter(5)
+- expression 35 operands: lhs = Zero, rhs = Expression(45, Sub)
+- expression 36 operands: lhs = Expression(46, Sub), rhs = Counter(7)
+- expression 37 operands: lhs = Expression(47, Sub), rhs = Counter(4)
+- expression 38 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 39 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 40 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 41 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 42 operands: lhs = Expression(43, Sub), rhs = Expression(51, Add)
+- expression 43 operands: lhs = Expression(44, Add), rhs = Counter(5)
+- expression 44 operands: lhs = Zero, rhs = Expression(45, Sub)
+- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(7)
+- expression 46 operands: lhs = Expression(47, Sub), rhs = Counter(4)
+- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(6)
+- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(50, Add)
+- expression 49 operands: lhs = Counter(1), rhs = Counter(3)
+- expression 50 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 51 operands: lhs = Counter(6), rhs = Counter(9)
+Number of file 0 mappings: 20
+- Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17)
+- Code(Zero) at (prev + 1, 18) to (start + 1, 10)
+- Code(Expression(0, Sub)) at (prev + 2, 16) to (start + 0, 21)
+ = (c0 - c1)
+- Code(Zero) at (prev + 1, 23) to (start + 0, 27)
+- Code(Zero) at (prev + 0, 28) to (start + 0, 30)
+- Code(Expression(3, Sub)) at (prev + 1, 14) to (start + 0, 15)
+ = ((c0 - c1) - c2)
+- Code(Expression(2, Add)) at (prev + 1, 13) to (start + 0, 30)
+ = (Zero + ((c0 - c1) - c2))
+- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31)
+- Code(Expression(47, Sub)) at (prev + 2, 13) to (start + 0, 14)
+ = (((c1 + c3) + (c4 + c5)) - c6)
+- Code(Expression(48, Add)) at (prev + 0, 18) to (start + 0, 23)
+ = ((c1 + c3) + (c4 + c5))
+- Code(Expression(11, Add)) at (prev + 1, 16) to (start + 0, 21)
+ = ((((c1 + c3) + (c4 + c5)) - c6) + Zero)
+- Code(Zero) at (prev + 0, 22) to (start + 1, 14)
+- Code(Expression(46, Sub)) at (prev + 2, 20) to (start + 0, 25)
+ = ((((c1 + c3) + (c4 + c5)) - c6) - c4)
+- Code(Zero) at (prev + 1, 27) to (start + 0, 31)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 34)
+- Code(Expression(45, Sub)) at (prev + 1, 18) to (start + 0, 19)
+ = (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)
+- Code(Expression(44, Add)) at (prev + 1, 17) to (start + 0, 34)
+ = (Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7))
+- Code(Expression(43, Sub)) at (prev + 0, 34) to (start + 0, 35)
+ = ((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5)
+- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15)
+- Code(Expression(42, Add)) at (prev + 1, 5) to (start + 0, 6)
+ = (((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) + (c6 + c9))
+
+Function name: loops_branches::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 55, 1) to (start + 5, 2)
+
diff --git a/tests/coverage-map/status-quo/loops_branches.rs b/tests/coverage-map/status-quo/loops_branches.rs
new file mode 100644
index 000000000..f3a343bcc
--- /dev/null
+++ b/tests/coverage-map/status-quo/loops_branches.rs
@@ -0,0 +1,60 @@
+#![allow(unused_assignments, unused_variables, while_true)]
+
+// This test confirms that (1) unexecuted infinite loops are handled correctly by the
+// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped.
+
+struct DebugTest;
+
+impl std::fmt::Debug for DebugTest {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if true {
+ if false {
+ while true {}
+ }
+ write!(f, "cool")?;
+ } else {
+ }
+
+ for i in 0..10 {
+ if true {
+ if false {
+ while true {}
+ }
+ write!(f, "cool")?;
+ } else {
+ }
+ }
+ Ok(())
+ }
+}
+
+struct DisplayTest;
+
+impl std::fmt::Display for DisplayTest {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if false {
+ } else {
+ if false {
+ while true {}
+ }
+ write!(f, "cool")?;
+ }
+ for i in 0..10 {
+ if false {
+ } else {
+ if false {
+ while true {}
+ }
+ write!(f, "cool")?;
+ }
+ }
+ Ok(())
+ }
+}
+
+fn main() {
+ let debug_test = DebugTest;
+ println!("{:?}", debug_test);
+ let display_test = DisplayTest;
+ println!("{}", display_test);
+}
diff --git a/tests/coverage-map/status-quo/match_or_pattern.cov-map b/tests/coverage-map/status-quo/match_or_pattern.cov-map
new file mode 100644
index 000000000..d63407a99
--- /dev/null
+++ b/tests/coverage-map/status-quo/match_or_pattern.cov-map
@@ -0,0 +1,83 @@
+Function name: match_or_pattern::main
+Raw bytes (202): 0x[01, 01, 23, 01, 05, 05, 02, 09, 0d, 2f, 11, 09, 0d, 2b, 15, 2f, 11, 09, 0d, 15, 26, 2b, 15, 2f, 11, 09, 0d, 19, 1d, 57, 21, 19, 1d, 53, 25, 57, 21, 19, 1d, 25, 4e, 53, 25, 57, 21, 19, 1d, 29, 2d, 7f, 31, 29, 2d, 7b, 35, 7f, 31, 29, 2d, 35, 76, 7b, 35, 7f, 31, 29, 2d, 39, 3d, 8b, 01, 41, 39, 3d, 19, 01, 01, 01, 08, 0f, 05, 08, 10, 03, 06, 02, 03, 06, 00, 07, 07, 01, 0b, 00, 11, 11, 03, 1b, 00, 1d, 2f, 01, 0e, 00, 10, 2b, 02, 08, 00, 0f, 15, 00, 10, 03, 06, 26, 03, 06, 00, 07, 23, 01, 0b, 00, 11, 21, 01, 1b, 00, 1d, 57, 01, 0e, 00, 10, 53, 02, 08, 00, 0f, 25, 00, 10, 03, 06, 4e, 03, 06, 00, 07, 4b, 01, 0b, 00, 11, 31, 01, 1b, 00, 1d, 7f, 01, 0e, 00, 10, 7b, 02, 08, 00, 0f, 35, 00, 10, 03, 06, 76, 03, 06, 00, 07, 73, 01, 0b, 00, 11, 41, 01, 1b, 00, 1d, 8b, 01, 01, 0e, 00, 10, 87, 01, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 35
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(11, Add), rhs = Counter(4)
+- expression 4 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 5 operands: lhs = Expression(10, Add), rhs = Counter(5)
+- expression 6 operands: lhs = Expression(11, Add), rhs = Counter(4)
+- expression 7 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 8 operands: lhs = Counter(5), rhs = Expression(9, Sub)
+- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(5)
+- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(4)
+- expression 11 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 12 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 13 operands: lhs = Expression(21, Add), rhs = Counter(8)
+- expression 14 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 15 operands: lhs = Expression(20, Add), rhs = Counter(9)
+- expression 16 operands: lhs = Expression(21, Add), rhs = Counter(8)
+- expression 17 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 18 operands: lhs = Counter(9), rhs = Expression(19, Sub)
+- expression 19 operands: lhs = Expression(20, Add), rhs = Counter(9)
+- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(8)
+- expression 21 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 22 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 23 operands: lhs = Expression(31, Add), rhs = Counter(12)
+- expression 24 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 25 operands: lhs = Expression(30, Add), rhs = Counter(13)
+- expression 26 operands: lhs = Expression(31, Add), rhs = Counter(12)
+- expression 27 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 28 operands: lhs = Counter(13), rhs = Expression(29, Sub)
+- expression 29 operands: lhs = Expression(30, Add), rhs = Counter(13)
+- expression 30 operands: lhs = Expression(31, Add), rhs = Counter(12)
+- expression 31 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 32 operands: lhs = Counter(14), rhs = Counter(15)
+- expression 33 operands: lhs = Expression(34, Add), rhs = Counter(16)
+- expression 34 operands: lhs = Counter(14), rhs = Counter(15)
+Number of file 0 mappings: 25
+- Code(Counter(0)) at (prev + 1, 1) to (start + 8, 15)
+- Code(Counter(1)) at (prev + 8, 16) to (start + 3, 6)
+- Code(Expression(0, Sub)) at (prev + 3, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 11) to (start + 0, 17)
+ = (c1 + (c0 - c1))
+- Code(Counter(4)) at (prev + 3, 27) to (start + 0, 29)
+- Code(Expression(11, Add)) at (prev + 1, 14) to (start + 0, 16)
+ = (c2 + c3)
+- Code(Expression(10, Add)) at (prev + 2, 8) to (start + 0, 15)
+ = ((c2 + c3) + c4)
+- Code(Counter(5)) at (prev + 0, 16) to (start + 3, 6)
+- Code(Expression(9, Sub)) at (prev + 3, 6) to (start + 0, 7)
+ = (((c2 + c3) + c4) - c5)
+- Code(Expression(8, Add)) at (prev + 1, 11) to (start + 0, 17)
+ = (c5 + (((c2 + c3) + c4) - c5))
+- Code(Counter(8)) at (prev + 1, 27) to (start + 0, 29)
+- Code(Expression(21, Add)) at (prev + 1, 14) to (start + 0, 16)
+ = (c6 + c7)
+- Code(Expression(20, Add)) at (prev + 2, 8) to (start + 0, 15)
+ = ((c6 + c7) + c8)
+- Code(Counter(9)) at (prev + 0, 16) to (start + 3, 6)
+- Code(Expression(19, Sub)) at (prev + 3, 6) to (start + 0, 7)
+ = (((c6 + c7) + c8) - c9)
+- Code(Expression(18, Add)) at (prev + 1, 11) to (start + 0, 17)
+ = (c9 + (((c6 + c7) + c8) - c9))
+- Code(Counter(12)) at (prev + 1, 27) to (start + 0, 29)
+- Code(Expression(31, Add)) at (prev + 1, 14) to (start + 0, 16)
+ = (c10 + c11)
+- Code(Expression(30, Add)) at (prev + 2, 8) to (start + 0, 15)
+ = ((c10 + c11) + c12)
+- Code(Counter(13)) at (prev + 0, 16) to (start + 3, 6)
+- Code(Expression(29, Sub)) at (prev + 3, 6) to (start + 0, 7)
+ = (((c10 + c11) + c12) - c13)
+- Code(Expression(28, Add)) at (prev + 1, 11) to (start + 0, 17)
+ = (c13 + (((c10 + c11) + c12) - c13))
+- Code(Counter(16)) at (prev + 1, 27) to (start + 0, 29)
+- Code(Expression(34, Add)) at (prev + 1, 14) to (start + 0, 16)
+ = (c14 + c15)
+- Code(Expression(33, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = ((c14 + c15) + c16)
+
diff --git a/tests/coverage-map/status-quo/match_or_pattern.rs b/tests/coverage-map/status-quo/match_or_pattern.rs
new file mode 100644
index 000000000..ab7aee51d
--- /dev/null
+++ b/tests/coverage-map/status-quo/match_or_pattern.rs
@@ -0,0 +1,43 @@
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut a: u8 = 0;
+ let mut b: u8 = 0;
+ if is_true {
+ a = 2;
+ b = 0;
+ }
+ match (a, b) {
+ // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`.
+ // This test confirms a fix for Issue #79569.
+ (0 | 1, 2 | 3) => {}
+ _ => {}
+ }
+ if is_true {
+ a = 0;
+ b = 0;
+ }
+ match (a, b) {
+ (0 | 1, 2 | 3) => {}
+ _ => {}
+ }
+ if is_true {
+ a = 2;
+ b = 2;
+ }
+ match (a, b) {
+ (0 | 1, 2 | 3) => {}
+ _ => {}
+ }
+ if is_true {
+ a = 0;
+ b = 2;
+ }
+ match (a, b) {
+ (0 | 1, 2 | 3) => {}
+ _ => {}
+ }
+}
diff --git a/tests/coverage-map/status-quo/nested_loops.cov-map b/tests/coverage-map/status-quo/nested_loops.cov-map
new file mode 100644
index 000000000..35d92594e
--- /dev/null
+++ b/tests/coverage-map/status-quo/nested_loops.cov-map
@@ -0,0 +1,51 @@
+Function name: nested_loops::main
+Raw bytes (115): 0x[01, 01, 17, 01, 57, 05, 09, 03, 0d, 4e, 53, 03, 0d, 15, 19, 4b, 09, 4e, 53, 03, 0d, 15, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 42, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 05, 09, 11, 0d, 0d, 01, 01, 01, 02, 1b, 03, 04, 13, 00, 20, 4e, 01, 0d, 01, 18, 4b, 02, 12, 00, 17, 46, 01, 10, 00, 16, 05, 01, 11, 00, 16, 42, 01, 0e, 03, 16, 3e, 04, 11, 01, 1b, 11, 02, 15, 00, 21, 15, 01, 18, 02, 12, 19, 03, 0e, 00, 0f, 57, 02, 09, 00, 17, 5b, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 23
+- expression 0 operands: lhs = Counter(0), rhs = Expression(21, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add)
+- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 5 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 6 operands: lhs = Expression(18, Add), rhs = Counter(2)
+- expression 7 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add)
+- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 9 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 10 operands: lhs = Expression(17, Sub), rhs = Counter(1)
+- expression 11 operands: lhs = Expression(18, Add), rhs = Counter(2)
+- expression 12 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add)
+- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 14 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(6)
+- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(1)
+- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(2)
+- expression 18 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add)
+- expression 19 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 20 operands: lhs = Counter(5), rhs = Counter(6)
+- expression 21 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 22 operands: lhs = Counter(4), rhs = Counter(3)
+Number of file 0 mappings: 13
+- Code(Counter(0)) at (prev + 1, 1) to (start + 2, 27)
+- Code(Expression(0, Add)) at (prev + 4, 19) to (start + 0, 32)
+ = (c0 + (c1 + c2))
+- Code(Expression(19, Sub)) at (prev + 1, 13) to (start + 1, 24)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Expression(18, Add)) at (prev + 2, 18) to (start + 0, 23)
+ = (((c0 + (c1 + c2)) - c3) + (c5 + c6))
+- Code(Expression(17, Sub)) at (prev + 1, 16) to (start + 0, 22)
+ = ((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2)
+- Code(Counter(1)) at (prev + 1, 17) to (start + 0, 22)
+- Code(Expression(16, Sub)) at (prev + 1, 14) to (start + 3, 22)
+ = (((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1)
+- Code(Expression(15, Sub)) at (prev + 4, 17) to (start + 1, 27)
+ = ((((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1) - c6)
+- Code(Counter(4)) at (prev + 2, 21) to (start + 0, 33)
+- Code(Counter(5)) at (prev + 1, 24) to (start + 2, 18)
+- Code(Counter(6)) at (prev + 3, 14) to (start + 0, 15)
+- Code(Expression(21, Add)) at (prev + 2, 9) to (start + 0, 23)
+ = (c1 + c2)
+- Code(Expression(22, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c4 + c3)
+
diff --git a/tests/coverage-map/status-quo/nested_loops.rs b/tests/coverage-map/status-quo/nested_loops.rs
new file mode 100644
index 000000000..4c7c78427
--- /dev/null
+++ b/tests/coverage-map/status-quo/nested_loops.rs
@@ -0,0 +1,25 @@
+fn main() {
+ let is_true = std::env::args().len() == 1;
+ let mut countdown = 10;
+
+ 'outer: while countdown > 0 {
+ let mut a = 100;
+ let mut b = 100;
+ for _ in 0..50 {
+ if a < 30 {
+ break;
+ }
+ a -= 5;
+ b -= 5;
+ if b < 90 {
+ a -= 10;
+ if is_true {
+ break 'outer;
+ } else {
+ a -= 2;
+ }
+ }
+ }
+ countdown -= 1;
+ }
+}
diff --git a/tests/coverage-map/status-quo/no_cov_crate.cov-map b/tests/coverage-map/status-quo/no_cov_crate.cov-map
new file mode 100644
index 000000000..7ab5995dc
--- /dev/null
+++ b/tests/coverage-map/status-quo/no_cov_crate.cov-map
@@ -0,0 +1,78 @@
+Function name: no_cov_crate::add_coverage_1
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 14, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 20, 1) to (start + 2, 2)
+
+Function name: no_cov_crate::add_coverage_2
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 18, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 24, 1) to (start + 2, 2)
+
+Function name: no_cov_crate::add_coverage_not_called (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2)
+
+Function name: no_cov_crate::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 4d, 01, 0b, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 77, 1) to (start + 11, 2)
+
+Function name: no_cov_crate::nested_fns::outer
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 05, 0c, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 49, 5) to (start + 12, 6)
+
+Function name: no_cov_crate::nested_fns::outer_both_covered
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 3f, 05, 0b, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 63, 5) to (start + 11, 6)
+
+Function name: no_cov_crate::nested_fns::outer_both_covered::inner
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 67, 9) to (start + 1, 23)
+- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14)
+- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10)
+ = (c1 + (c0 - c1))
+
+Function name: no_cov_crate::nested_fns::outer_not_covered::inner
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 26, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 38, 9) to (start + 1, 23)
+- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14)
+- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10)
+ = (c1 + (c0 - c1))
+
diff --git a/tests/coverage-map/status-quo/no_cov_crate.rs b/tests/coverage-map/status-quo/no_cov_crate.rs
new file mode 100644
index 000000000..e12e4bc55
--- /dev/null
+++ b/tests/coverage-map/status-quo/no_cov_crate.rs
@@ -0,0 +1,88 @@
+// Enables `coverage(off)` on the entire crate
+#![feature(coverage_attribute)]
+
+#[coverage(off)]
+fn do_not_add_coverage_1() {
+ println!("called but not covered");
+}
+
+fn do_not_add_coverage_2() {
+ #![coverage(off)]
+ println!("called but not covered");
+}
+
+#[coverage(off)]
+#[allow(dead_code)]
+fn do_not_add_coverage_not_called() {
+ println!("not called and not covered");
+}
+
+fn add_coverage_1() {
+ println!("called and covered");
+}
+
+fn add_coverage_2() {
+ println!("called and covered");
+}
+
+#[allow(dead_code)]
+fn add_coverage_not_called() {
+ println!("not called but covered");
+}
+
+// FIXME: These test-cases illustrate confusing results of nested functions.
+// See https://github.com/rust-lang/rust/issues/93319
+mod nested_fns {
+ #[coverage(off)]
+ pub fn outer_not_covered(is_true: bool) {
+ fn inner(is_true: bool) {
+ if is_true {
+ println!("called and covered");
+ } else {
+ println!("absolutely not covered");
+ }
+ }
+ println!("called but not covered");
+ inner(is_true);
+ }
+
+ pub fn outer(is_true: bool) {
+ println!("called and covered");
+ inner_not_covered(is_true);
+
+ #[coverage(off)]
+ fn inner_not_covered(is_true: bool) {
+ if is_true {
+ println!("called but not covered");
+ } else {
+ println!("absolutely not covered");
+ }
+ }
+ }
+
+ pub fn outer_both_covered(is_true: bool) {
+ println!("called and covered");
+ inner(is_true);
+
+ fn inner(is_true: bool) {
+ if is_true {
+ println!("called and covered");
+ } else {
+ println!("absolutely not covered");
+ }
+ }
+ }
+}
+
+fn main() {
+ let is_true = std::env::args().len() == 1;
+
+ do_not_add_coverage_1();
+ do_not_add_coverage_2();
+ add_coverage_1();
+ add_coverage_2();
+
+ nested_fns::outer_not_covered(is_true);
+ nested_fns::outer(is_true);
+ nested_fns::outer_both_covered(is_true);
+}
diff --git a/tests/coverage-map/status-quo/overflow.cov-map b/tests/coverage-map/status-quo/overflow.cov-map
new file mode 100644
index 000000000..bfffd9b2a
--- /dev/null
+++ b/tests/coverage-map/status-quo/overflow.cov-map
@@ -0,0 +1,43 @@
+Function name: overflow::main
+Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0f, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 8
+- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1)
+- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 7 operands: lhs = Counter(2), rhs = Counter(3)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 27)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24)
+ = (c0 + (c1 + (c2 + c3)))
+- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26)
+ = ((c0 + (c1 + (c2 + c3))) - c4)
+- Code(Counter(1)) at (prev + 0, 27) to (start + 3, 10)
+- Code(Expression(4, Sub)) at (prev + 3, 19) to (start + 0, 32)
+ = (((c0 + (c1 + (c2 + c3))) - c4) - c1)
+- Code(Counter(2)) at (prev + 0, 33) to (start + 3, 10)
+- Code(Counter(3)) at (prev + 3, 10) to (start + 0, 11)
+- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (c1 + (c2 + c3))
+- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2)
+
+Function name: overflow::might_overflow
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 18)
+- Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 5, 2)
+ = (c1 + (c0 - c1))
+
diff --git a/tests/coverage-map/status-quo/overflow.rs b/tests/coverage-map/status-quo/overflow.rs
new file mode 100644
index 000000000..bbb65c1b3
--- /dev/null
+++ b/tests/coverage-map/status-quo/overflow.rs
@@ -0,0 +1,63 @@
+#![allow(unused_assignments)]
+// failure-status: 101
+
+fn might_overflow(to_add: u32) -> u32 {
+ if to_add > 5 {
+ println!("this will probably overflow");
+ }
+ let add_to = u32::MAX - 5;
+ println!("does {} + {} overflow?", add_to, to_add);
+ let result = to_add + add_to;
+ println!("continuing after overflow check");
+ result
+}
+
+fn main() -> Result<(), u8> {
+ let mut countdown = 10;
+ while countdown > 0 {
+ if countdown == 1 {
+ let result = might_overflow(10);
+ println!("Result: {}", result);
+ } else if countdown < 5 {
+ let result = might_overflow(1);
+ println!("Result: {}", result);
+ }
+ countdown -= 1;
+ }
+ Ok(())
+}
+
+// Notes:
+// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`,
+// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`.
+// 2. This test confirms the coverage generated when a program passes or fails a
+// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case).
+// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`,
+// compiler-generated assertion failures are assumed to be a symptom of a program bug, not
+// expected behavior. To simplify the coverage graphs and keep instrumented programs as
+// small and fast as possible, `Assert` terminators are assumed to always succeed, and
+// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not
+// get its own coverage counter.
+// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive.
+// In this test, the final count for the statements after the `if` block in `might_overflow()`
+// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending
+// on the MIR graph and the structure of the code, this count could have been 3 (which might
+// have been valid for the overflowed add `+`, but should have been 4 for the lines before
+// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented
+// via StatementKind::Counter at the end of the block, but (as in the case in this test),
+// a CounterKind::Expression is always evaluated. In this case, the expression was based on
+// a `Counter` incremented as part of the evaluation of the `if` expression, which was
+// executed, and counted, 4 times, before reaching the overflow add.
+
+// If the program did not overflow, the coverage for `might_overflow()` would look like this:
+//
+// 4| |fn might_overflow(to_add: u32) -> u32 {
+// 5| 4| if to_add > 5 {
+// 6| 0| println!("this will probably overflow");
+// 7| 4| }
+// 8| 4| let add_to = u32::MAX - 5;
+// 9| 4| println!("does {} + {} overflow?", add_to, to_add);
+// 10| 4| let result = to_add + add_to;
+// 11| 4| println!("continuing after overflow check");
+// 12| 4| result
+// 13| 4|}
diff --git a/tests/coverage-map/status-quo/panic_unwind.cov-map b/tests/coverage-map/status-quo/panic_unwind.cov-map
new file mode 100644
index 000000000..f6089ce55
--- /dev/null
+++ b/tests/coverage-map/status-quo/panic_unwind.cov-map
@@ -0,0 +1,40 @@
+Function name: panic_unwind::main
+Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 8
+- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1)
+- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add)
+- expression 7 operands: lhs = Counter(2), rhs = Counter(3)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24)
+ = (c0 + (c1 + (c2 + c3)))
+- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26)
+ = ((c0 + (c1 + (c2 + c3))) - c4)
+- Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10)
+- Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32)
+ = (((c0 + (c1 + (c2 + c3))) - c4) - c1)
+- Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10)
+- Code(Counter(3)) at (prev + 2, 10) to (start + 0, 11)
+- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23)
+ = (c1 + (c2 + c3))
+- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2)
+
+Function name: panic_unwind::might_panic
+Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 01, 14, 05, 02, 09, 01, 19, 02, 02, 0c, 03, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20)
+- Code(Counter(1)) at (prev + 2, 9) to (start + 1, 25)
+- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 3, 2)
+ = (c0 - c1)
+
diff --git a/tests/coverage-map/status-quo/panic_unwind.rs b/tests/coverage-map/status-quo/panic_unwind.rs
new file mode 100644
index 000000000..638d2eb6a
--- /dev/null
+++ b/tests/coverage-map/status-quo/panic_unwind.rs
@@ -0,0 +1,31 @@
+#![allow(unused_assignments)]
+// failure-status: 101
+
+fn might_panic(should_panic: bool) {
+ if should_panic {
+ println!("panicking...");
+ panic!("panics");
+ } else {
+ println!("Don't Panic");
+ }
+}
+
+fn main() -> Result<(), u8> {
+ let mut countdown = 10;
+ while countdown > 0 {
+ if countdown == 1 {
+ might_panic(true);
+ } else if countdown < 5 {
+ might_panic(false);
+ }
+ countdown -= 1;
+ }
+ Ok(())
+}
+
+// Notes:
+// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
+// `try_error_result.rs`.
+// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
+// normal program exit cleanup, including writing out the current values of the coverage
+// counters.
diff --git a/tests/coverage-map/status-quo/partial_eq.cov-map b/tests/coverage-map/status-quo/partial_eq.cov-map
new file mode 100644
index 000000000..dd61cd77a
--- /dev/null
+++ b/tests/coverage-map/status-quo/partial_eq.cov-map
@@ -0,0 +1,64 @@
+Function name: <partial_eq::Version as core::clone::Clone>::clone (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 0a, 00, 0f]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 15)
+
+Function name: <partial_eq::Version as core::cmp::Ord>::cmp (unused)
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 33, 00, 34, 00, 00, 35, 00, 36]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 4, 51) to (start + 0, 52)
+- Code(Zero) at (prev + 0, 53) to (start + 0, 54)
+
+Function name: <partial_eq::Version as core::cmp::PartialEq>::eq (unused)
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 18, 00, 19, 00, 00, 20, 00, 21]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 4, 24) to (start + 0, 25)
+- Code(Zero) at (prev + 0, 32) to (start + 0, 33)
+
+Function name: <partial_eq::Version as core::cmp::PartialOrd>::partial_cmp
+Raw bytes (22): 0x[01, 01, 04, 07, 0b, 05, 09, 0f, 15, 0d, 11, 02, 01, 04, 27, 00, 28, 03, 00, 30, 00, 31]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5)
+- expression 3 operands: lhs = Counter(3), rhs = Counter(4)
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 4, 39) to (start + 0, 40)
+- Code(Expression(0, Add)) at (prev + 0, 48) to (start + 0, 49)
+ = ((c1 + c2) + ((c3 + c4) + c5))
+
+Function name: <partial_eq::Version as core::fmt::Debug>::fmt
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 11, 00, 16]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 4, 17) to (start + 0, 22)
+
+Function name: <partial_eq::Version>::new
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 05, 06, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 12, 5) to (start + 6, 6)
+
+Function name: partial_eq::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 05, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 21, 1) to (start + 5, 2)
+
diff --git a/tests/coverage-map/status-quo/partial_eq.rs b/tests/coverage-map/status-quo/partial_eq.rs
new file mode 100644
index 000000000..dd8b42c18
--- /dev/null
+++ b/tests/coverage-map/status-quo/partial_eq.rs
@@ -0,0 +1,46 @@
+// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the
+// structure of this test.
+
+#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
+pub struct Version {
+ major: usize,
+ minor: usize,
+ patch: usize,
+}
+
+impl Version {
+ pub fn new(major: usize, minor: usize, patch: usize) -> Self {
+ Self {
+ major,
+ minor,
+ patch,
+ }
+ }
+}
+
+fn main() {
+ let version_3_2_1 = Version::new(3, 2, 1);
+ let version_3_3_0 = Version::new(3, 3, 0);
+
+ println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0);
+}
+
+/*
+
+This test verifies a bug was fixed that otherwise generated this error:
+
+thread 'rustc' panicked at 'No counters provided the source_hash for function:
+ Instance {
+ def: Item(WithOptConstParam {
+ did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp),
+ const_param_did: None
+ }),
+ args: []
+ }'
+The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage
+without a code region associated with any `Counter`. Code regions were associated with at least
+one expression, which is allowed, but the `function_source_hash` was only passed to the codegen
+(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the
+`function_source_hash` without a code region, if necessary.
+
+*/
diff --git a/tests/coverage-map/status-quo/simple_loop.cov-map b/tests/coverage-map/status-quo/simple_loop.cov-map
new file mode 100644
index 000000000..eb49c2324
--- /dev/null
+++ b/tests/coverage-map/status-quo/simple_loop.cov-map
@@ -0,0 +1,28 @@
+Function name: simple_loop::main
+Raw bytes (59): 0x[01, 01, 0a, 01, 05, 27, 09, 05, 02, 23, 09, 27, 09, 05, 02, 1e, 00, 23, 09, 27, 09, 05, 02, 07, 01, 03, 01, 09, 10, 05, 0a, 05, 05, 06, 02, 05, 06, 00, 07, 23, 05, 0d, 02, 0e, 1e, 04, 0d, 00, 12, 09, 02, 0a, 03, 0a, 1b, 06, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 10
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(9, Add), rhs = Counter(2)
+- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 3 operands: lhs = Expression(8, Add), rhs = Counter(2)
+- expression 4 operands: lhs = Expression(9, Add), rhs = Counter(2)
+- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero
+- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(2)
+- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(2)
+- expression 9 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 7
+- Code(Counter(0)) at (prev + 3, 1) to (start + 9, 16)
+- Code(Counter(1)) at (prev + 10, 5) to (start + 5, 6)
+- Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(8, Add)) at (prev + 5, 13) to (start + 2, 14)
+ = ((c1 + (c0 - c1)) + c2)
+- Code(Expression(7, Sub)) at (prev + 4, 13) to (start + 0, 18)
+ = (((c1 + (c0 - c1)) + c2) - c2)
+- Code(Counter(2)) at (prev + 2, 10) to (start + 3, 10)
+- Code(Expression(6, Add)) at (prev + 6, 1) to (start + 0, 2)
+ = ((((c1 + (c0 - c1)) + c2) - c2) + Zero)
+
diff --git a/tests/coverage-map/status-quo/simple_loop.rs b/tests/coverage-map/status-quo/simple_loop.rs
new file mode 100644
index 000000000..6f7f23475
--- /dev/null
+++ b/tests/coverage-map/status-quo/simple_loop.rs
@@ -0,0 +1,35 @@
+#![allow(unused_assignments)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 0;
+
+ if
+ is_true
+ {
+ countdown
+ =
+ 10
+ ;
+ }
+
+ loop
+ {
+ if
+ countdown
+ ==
+ 0
+ {
+ break
+ ;
+ }
+ countdown
+ -=
+ 1
+ ;
+ }
+}
diff --git a/tests/coverage-map/status-quo/simple_match.cov-map b/tests/coverage-map/status-quo/simple_match.cov-map
new file mode 100644
index 000000000..d5389f04b
--- /dev/null
+++ b/tests/coverage-map/status-quo/simple_match.cov-map
@@ -0,0 +1,36 @@
+Function name: simple_match::main
+Raw bytes (82): 0x[01, 01, 0e, 01, 05, 2f, 33, 05, 02, 09, 0d, 2b, 11, 2f, 33, 05, 02, 09, 0d, 26, 00, 2b, 11, 2f, 33, 05, 02, 09, 0d, 09, 00, 0a, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 2b, 05, 09, 00, 0d, 26, 05, 0d, 00, 16, 09, 02, 0d, 00, 0e, 23, 02, 11, 02, 12, 37, 04, 0d, 07, 0e, 0d, 0a, 0d, 00, 0f, 11, 03, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 14
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(11, Add), rhs = Expression(12, Add)
+- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 4 operands: lhs = Expression(10, Add), rhs = Counter(4)
+- expression 5 operands: lhs = Expression(11, Add), rhs = Expression(12, Add)
+- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 7 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 8 operands: lhs = Expression(9, Sub), rhs = Zero
+- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(4)
+- expression 10 operands: lhs = Expression(11, Add), rhs = Expression(12, Add)
+- expression 11 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+- expression 12 operands: lhs = Counter(2), rhs = Counter(3)
+- expression 13 operands: lhs = Counter(2), rhs = Zero
+Number of file 0 mappings: 10
+- Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15)
+- Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(10, Add)) at (prev + 5, 9) to (start + 0, 13)
+ = ((c1 + (c0 - c1)) + (c2 + c3))
+- Code(Expression(9, Sub)) at (prev + 5, 13) to (start + 0, 22)
+ = (((c1 + (c0 - c1)) + (c2 + c3)) - c4)
+- Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14)
+- Code(Expression(8, Add)) at (prev + 2, 17) to (start + 2, 18)
+ = ((((c1 + (c0 - c1)) + (c2 + c3)) - c4) + Zero)
+- Code(Expression(13, Add)) at (prev + 4, 13) to (start + 7, 14)
+ = (c2 + Zero)
+- Code(Counter(3)) at (prev + 10, 13) to (start + 0, 15)
+- Code(Counter(4)) at (prev + 3, 1) to (start + 0, 2)
+
diff --git a/tests/coverage-map/status-quo/simple_match.rs b/tests/coverage-map/status-quo/simple_match.rs
new file mode 100644
index 000000000..be99e59a8
--- /dev/null
+++ b/tests/coverage-map/status-quo/simple_match.rs
@@ -0,0 +1,43 @@
+#![allow(unused_assignments, unused_variables)]
+
+fn main() {
+ // Initialize test constants in a way that cannot be determined at compile time, to ensure
+ // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+ // dependent conditions.
+ let is_true = std::env::args().len() == 1;
+
+ let mut countdown = 1;
+ if is_true {
+ countdown = 0;
+ }
+
+ for
+ _
+ in
+ 0..2
+ {
+ let z
+ ;
+ match
+ countdown
+ {
+ x
+ if
+ x
+ <
+ 1
+ =>
+ {
+ z = countdown
+ ;
+ let y = countdown
+ ;
+ countdown = 10
+ ;
+ }
+ _
+ =>
+ {}
+ }
+ }
+}
diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map
new file mode 100644
index 000000000..7156a66cf
--- /dev/null
+++ b/tests/coverage-map/status-quo/sort_groups.cov-map
@@ -0,0 +1,68 @@
+Function name: sort_groups::generic_fn::<&str>
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12)
+- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: sort_groups::generic_fn::<()>
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12)
+- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: sort_groups::generic_fn::<i32>
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12)
+- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: sort_groups::main
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13)
+- Code(Zero) at (prev + 4, 14) to (start + 2, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2)
+ = (c1 + (c0 - c1))
+
+Function name: sort_groups::other_fn
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 17)
+
diff --git a/tests/coverage-map/status-quo/sort_groups.rs b/tests/coverage-map/status-quo/sort_groups.rs
new file mode 100644
index 000000000..f89f9f3ec
--- /dev/null
+++ b/tests/coverage-map/status-quo/sort_groups.rs
@@ -0,0 +1,23 @@
+// compile-flags: --edition=2021
+
+// Demonstrate that `sort_subviews.py` can sort instantiation groups into a
+// predictable order, while preserving their heterogeneous contents.
+
+fn main() {
+ let cond = std::env::args().len() > 1;
+ generic_fn::<()>(cond);
+ generic_fn::<&'static str>(!cond);
+ if false {
+ generic_fn::<char>(cond);
+ }
+ generic_fn::<i32>(cond);
+ other_fn();
+}
+
+fn generic_fn<T>(cond: bool) {
+ if cond {
+ println!("{}", std::any::type_name::<T>());
+ }
+}
+
+fn other_fn() {}
diff --git a/tests/coverage-map/status-quo/test_harness.cov-map b/tests/coverage-map/status-quo/test_harness.cov-map
new file mode 100644
index 000000000..b0e955dd1
--- /dev/null
+++ b/tests/coverage-map/status-quo/test_harness.cov-map
@@ -0,0 +1,24 @@
+Function name: test_harness::my_test
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 00, 10]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 10, 1) to (start + 0, 16)
+
+Function name: test_harness::my_test::{closure#0}
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 09, 01, 00, 08]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 9, 1) to (start + 0, 8)
+
+Function name: test_harness::unused (unused)
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 0f]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 15)
+
diff --git a/tests/coverage-map/status-quo/test_harness.rs b/tests/coverage-map/status-quo/test_harness.rs
new file mode 100644
index 000000000..12a755734
--- /dev/null
+++ b/tests/coverage-map/status-quo/test_harness.rs
@@ -0,0 +1,10 @@
+// Verify that the entry point injected by the test harness doesn't cause
+// weird artifacts in the coverage report (e.g. issue #10749).
+
+// compile-flags: --test
+
+#[allow(dead_code)]
+fn unused() {}
+
+#[test]
+fn my_test() {}
diff --git a/tests/coverage-map/status-quo/tight_inf_loop.cov-map b/tests/coverage-map/status-quo/tight_inf_loop.cov-map
new file mode 100644
index 000000000..76884212c
--- /dev/null
+++ b/tests/coverage-map/status-quo/tight_inf_loop.cov-map
@@ -0,0 +1,12 @@
+Function name: tight_inf_loop::main
+Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 1
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+Number of file 0 mappings: 3
+- Code(Counter(0)) at (prev + 1, 1) to (start + 1, 13)
+- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
+- Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 1, 2)
+ = (c0 - c1)
+
diff --git a/tests/coverage-map/status-quo/tight_inf_loop.rs b/tests/coverage-map/status-quo/tight_inf_loop.rs
new file mode 100644
index 000000000..cef99027a
--- /dev/null
+++ b/tests/coverage-map/status-quo/tight_inf_loop.rs
@@ -0,0 +1,5 @@
+fn main() {
+ if false {
+ loop {}
+ }
+}
diff --git a/tests/coverage-map/status-quo/try_error_result.cov-map b/tests/coverage-map/status-quo/try_error_result.cov-map
new file mode 100644
index 000000000..b52e78d11
--- /dev/null
+++ b/tests/coverage-map/status-quo/try_error_result.cov-map
@@ -0,0 +1,226 @@
+Function name: <try_error_result::Thing1>::get_thing_2
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 28, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 1a, 07, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 40, 5) to (start + 1, 24)
+- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20)
+- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 26)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (c1 + (c0 - c1))
+
+Function name: <try_error_result::Thing2>::call
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 13, 07, 02, 05, 00, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 24)
+- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20)
+- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6)
+ = (c1 + (c0 - c1))
+
+Function name: try_error_result::call
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 07, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20)
+- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16)
+- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: try_error_result::main
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 70, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 07, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 112, 1) to (start + 2, 12)
+- Code(Counter(1)) at (prev + 3, 5) to (start + 0, 6)
+- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 11)
+ = (c0 - c1)
+- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = (c1 + (c0 - c1))
+
+Function name: try_error_result::test1
+Raw bytes (77): 0x[01, 01, 09, 01, 07, 05, 09, 03, 0d, 1d, 11, 16, 1d, 03, 0d, 1f, 0d, 11, 23, 15, 19, 0b, 01, 0c, 01, 02, 17, 03, 07, 09, 00, 0e, 16, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 0e, 01, 0d, 00, 2a, 15, 00, 2a, 00, 2b, 12, 04, 0d, 00, 2a, 19, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 1b, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 9
+- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(7), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(7)
+- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(3)
+- expression 7 operands: lhs = Counter(4), rhs = Expression(8, Add)
+- expression 8 operands: lhs = Counter(5), rhs = Counter(6)
+Number of file 0 mappings: 11
+- Code(Counter(0)) at (prev + 12, 1) to (start + 2, 23)
+- Code(Expression(0, Add)) at (prev + 7, 9) to (start + 0, 14)
+ = (c0 + (c1 + c2))
+- Code(Expression(5, Sub)) at (prev + 2, 9) to (start + 4, 26)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(7)) at (prev + 6, 13) to (start + 0, 41)
+- Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42)
+- Code(Expression(3, Sub)) at (prev + 1, 13) to (start + 0, 42)
+ = (c7 - c4)
+- Code(Counter(5)) at (prev + 0, 42) to (start + 0, 43)
+- Code(Expression(4, Sub)) at (prev + 4, 13) to (start + 0, 42)
+ = (((c0 + (c1 + c2)) - c3) - c7)
+- Code(Counter(6)) at (prev + 0, 42) to (start + 0, 43)
+- Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11)
+- Code(Expression(6, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = ((c4 + (c5 + c6)) + c3)
+
+Function name: try_error_result::test2
+Raw bytes (373): 0x[01, 01, 41, 01, 07, 05, 09, 03, 0d, 41, 11, 52, 15, 41, 11, 4a, 1d, 4e, 19, 52, 15, 41, 11, 4e, 00, 52, 15, 41, 11, 4e, 19, 52, 15, 41, 11, 46, 00, 4a, 1d, 4e, 19, 52, 15, 41, 11, 6a, 25, 49, 21, 49, 21, 66, 00, 6a, 25, 49, 21, 9a, 01, 2d, 9e, 01, 29, a2, 01, 41, 03, 0d, a2, 01, 41, 03, 0d, 9e, 01, 29, a2, 01, 41, 03, 0d, 96, 01, 00, 9a, 01, 2d, 9e, 01, 29, a2, 01, 41, 03, 0d, ba, 01, 35, 45, 31, 45, 31, b6, 01, 00, ba, 01, 35, 45, 31, d2, 01, 3d, 4d, 39, 4d, 39, ce, 01, 00, d2, 01, 3d, 4d, 39, db, 01, 0d, 11, df, 01, e3, 01, f3, 01, 15, e7, 01, eb, 01, ef, 01, 19, 1d, 21, 25, f7, 01, fb, 01, 29, 2d, ff, 01, 83, 02, 31, 35, 39, 3d, 28, 01, 3c, 01, 03, 17, 03, 08, 09, 00, 0e, a2, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 52, 00, 31, 03, 35, 15, 04, 11, 00, 12, 4e, 02, 11, 04, 12, 46, 05, 11, 00, 14, 2b, 00, 17, 00, 41, 19, 00, 41, 00, 42, 4a, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 43, 01, 0d, 00, 20, 66, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 6a, 00, 43, 00, 60, 25, 00, 60, 00, 61, 63, 01, 0d, 00, 20, 96, 01, 04, 11, 00, 14, 9e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 9a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 93, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, ba, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, b3, 01, 01, 0d, 00, 20, ce, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, d2, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, cb, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, d7, 01, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 65
+- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(20, Sub), rhs = Counter(5)
+- expression 5 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 6 operands: lhs = Expression(18, Sub), rhs = Counter(7)
+- expression 7 operands: lhs = Expression(19, Sub), rhs = Counter(6)
+- expression 8 operands: lhs = Expression(20, Sub), rhs = Counter(5)
+- expression 9 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 10 operands: lhs = Expression(19, Sub), rhs = Zero
+- expression 11 operands: lhs = Expression(20, Sub), rhs = Counter(5)
+- expression 12 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 13 operands: lhs = Expression(19, Sub), rhs = Counter(6)
+- expression 14 operands: lhs = Expression(20, Sub), rhs = Counter(5)
+- expression 15 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 16 operands: lhs = Expression(17, Sub), rhs = Zero
+- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(7)
+- expression 18 operands: lhs = Expression(19, Sub), rhs = Counter(6)
+- expression 19 operands: lhs = Expression(20, Sub), rhs = Counter(5)
+- expression 20 operands: lhs = Counter(16), rhs = Counter(4)
+- expression 21 operands: lhs = Expression(26, Sub), rhs = Counter(9)
+- expression 22 operands: lhs = Counter(18), rhs = Counter(8)
+- expression 23 operands: lhs = Counter(18), rhs = Counter(8)
+- expression 24 operands: lhs = Expression(25, Sub), rhs = Zero
+- expression 25 operands: lhs = Expression(26, Sub), rhs = Counter(9)
+- expression 26 operands: lhs = Counter(18), rhs = Counter(8)
+- expression 27 operands: lhs = Expression(38, Sub), rhs = Counter(11)
+- expression 28 operands: lhs = Expression(39, Sub), rhs = Counter(10)
+- expression 29 operands: lhs = Expression(40, Sub), rhs = Counter(16)
+- expression 30 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 31 operands: lhs = Expression(40, Sub), rhs = Counter(16)
+- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 33 operands: lhs = Expression(39, Sub), rhs = Counter(10)
+- expression 34 operands: lhs = Expression(40, Sub), rhs = Counter(16)
+- expression 35 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 36 operands: lhs = Expression(37, Sub), rhs = Zero
+- expression 37 operands: lhs = Expression(38, Sub), rhs = Counter(11)
+- expression 38 operands: lhs = Expression(39, Sub), rhs = Counter(10)
+- expression 39 operands: lhs = Expression(40, Sub), rhs = Counter(16)
+- expression 40 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 41 operands: lhs = Expression(46, Sub), rhs = Counter(13)
+- expression 42 operands: lhs = Counter(17), rhs = Counter(12)
+- expression 43 operands: lhs = Counter(17), rhs = Counter(12)
+- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero
+- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(13)
+- expression 46 operands: lhs = Counter(17), rhs = Counter(12)
+- expression 47 operands: lhs = Expression(52, Sub), rhs = Counter(15)
+- expression 48 operands: lhs = Counter(19), rhs = Counter(14)
+- expression 49 operands: lhs = Counter(19), rhs = Counter(14)
+- expression 50 operands: lhs = Expression(51, Sub), rhs = Zero
+- expression 51 operands: lhs = Expression(52, Sub), rhs = Counter(15)
+- expression 52 operands: lhs = Counter(19), rhs = Counter(14)
+- expression 53 operands: lhs = Expression(54, Add), rhs = Counter(3)
+- expression 54 operands: lhs = Counter(4), rhs = Expression(55, Add)
+- expression 55 operands: lhs = Expression(56, Add), rhs = Expression(60, Add)
+- expression 56 operands: lhs = Counter(5), rhs = Expression(57, Add)
+- expression 57 operands: lhs = Expression(58, Add), rhs = Expression(59, Add)
+- expression 58 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 59 operands: lhs = Counter(8), rhs = Counter(9)
+- expression 60 operands: lhs = Expression(61, Add), rhs = Expression(62, Add)
+- expression 61 operands: lhs = Counter(10), rhs = Counter(11)
+- expression 62 operands: lhs = Expression(63, Add), rhs = Expression(64, Add)
+- expression 63 operands: lhs = Counter(12), rhs = Counter(13)
+- expression 64 operands: lhs = Counter(14), rhs = Counter(15)
+Number of file 0 mappings: 40
+- Code(Counter(0)) at (prev + 60, 1) to (start + 3, 23)
+- Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14)
+ = (c0 + (c1 + c2))
+- Code(Expression(40, Sub)) at (prev + 2, 9) to (start + 4, 26)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47)
+- Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48)
+- Code(Expression(20, Sub)) at (prev + 0, 49) to (start + 3, 53)
+ = (c16 - c4)
+- Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18)
+- Code(Expression(19, Sub)) at (prev + 2, 17) to (start + 4, 18)
+ = ((c16 - c4) - c5)
+- Code(Expression(17, Sub)) at (prev + 5, 17) to (start + 0, 20)
+ = ((((c16 - c4) - c5) - c6) - c7)
+- Code(Expression(10, Add)) at (prev + 0, 23) to (start + 0, 65)
+ = (((c16 - c4) - c5) + Zero)
+- Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66)
+- Code(Expression(18, Sub)) at (prev + 0, 67) to (start + 0, 95)
+ = (((c16 - c4) - c5) - c6)
+- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96)
+- Code(Expression(16, Add)) at (prev + 1, 13) to (start + 0, 32)
+ = (((((c16 - c4) - c5) - c6) - c7) + Zero)
+- Code(Expression(25, Sub)) at (prev + 1, 17) to (start + 0, 20)
+ = ((c18 - c8) - c9)
+- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65)
+- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66)
+- Code(Expression(26, Sub)) at (prev + 0, 67) to (start + 0, 96)
+ = (c18 - c8)
+- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97)
+- Code(Expression(24, Add)) at (prev + 1, 13) to (start + 0, 32)
+ = (((c18 - c8) - c9) + Zero)
+- Code(Expression(37, Sub)) at (prev + 4, 17) to (start + 0, 20)
+ = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11)
+- Code(Expression(39, Sub)) at (prev + 0, 23) to (start + 0, 66)
+ = (((c0 + (c1 + c2)) - c3) - c16)
+- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67)
+- Code(Expression(38, Sub)) at (prev + 0, 68) to (start + 0, 97)
+ = ((((c0 + (c1 + c2)) - c3) - c16) - c10)
+- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98)
+- Code(Expression(36, Add)) at (prev + 1, 13) to (start + 0, 32)
+ = ((((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) + Zero)
+- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20)
+ = ((c17 - c12) - c13)
+- Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54)
+- Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55)
+- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47)
+ = (c17 - c12)
+- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48)
+- Code(Expression(44, Add)) at (prev + 1, 13) to (start + 0, 32)
+ = (((c17 - c12) - c13) + Zero)
+- Code(Expression(51, Sub)) at (prev + 1, 17) to (start + 0, 20)
+ = ((c19 - c14) - c15)
+- Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54)
+- Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18)
+- Code(Expression(52, Sub)) at (prev + 1, 18) to (start + 0, 47)
+ = (c19 - c14)
+- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18)
+- Code(Expression(50, Add)) at (prev + 2, 13) to (start + 0, 32)
+ = (((c19 - c14) - c15) + Zero)
+- Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11)
+- Code(Expression(53, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = ((c4 + ((c5 + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15))))) + c3)
+
diff --git a/tests/coverage-map/status-quo/try_error_result.rs b/tests/coverage-map/status-quo/try_error_result.rs
new file mode 100644
index 000000000..557cbf22b
--- /dev/null
+++ b/tests/coverage-map/status-quo/try_error_result.rs
@@ -0,0 +1,118 @@
+#![allow(unused_assignments)]
+// failure-status: 1
+
+fn call(return_error: bool) -> Result<(), ()> {
+ if return_error {
+ Err(())
+ } else {
+ Ok(())
+ }
+}
+
+fn test1() -> Result<(), ()> {
+ let mut
+ countdown = 10
+ ;
+ for
+ _
+ in
+ 0..10
+ {
+ countdown
+ -= 1
+ ;
+ if
+ countdown < 5
+ {
+ call(/*return_error=*/ true)?;
+ call(/*return_error=*/ false)?;
+ }
+ else
+ {
+ call(/*return_error=*/ false)?;
+ }
+ }
+ Ok(())
+}
+
+struct Thing1;
+impl Thing1 {
+ fn get_thing_2(&self, return_error: bool) -> Result<Thing2, ()> {
+ if return_error {
+ Err(())
+ } else {
+ Ok(Thing2 {})
+ }
+ }
+}
+
+struct Thing2;
+impl Thing2 {
+ fn call(&self, return_error: bool) -> Result<u32, ()> {
+ if return_error {
+ Err(())
+ } else {
+ Ok(57)
+ }
+ }
+}
+
+fn test2() -> Result<(), ()> {
+ let thing1 = Thing1{};
+ let mut
+ countdown = 10
+ ;
+ for
+ _
+ in
+ 0..10
+ {
+ countdown
+ -= 1
+ ;
+ if
+ countdown < 5
+ {
+ thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail");
+ thing1
+ .
+ get_thing_2(/*return_error=*/ false)
+ ?
+ .
+ call(/*return_error=*/ true)
+ .
+ expect_err(
+ "call should fail"
+ );
+ let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?;
+ assert_eq!(val, 57);
+ let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?;
+ assert_eq!(val, 57);
+ }
+ else
+ {
+ let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?;
+ assert_eq!(val, 57);
+ let val = thing1
+ .get_thing_2(/*return_error=*/ false)?
+ .call(/*return_error=*/ false)?;
+ assert_eq!(val, 57);
+ let val = thing1
+ .get_thing_2(/*return_error=*/ false)
+ ?
+ .call(/*return_error=*/ false)
+ ?
+ ;
+ assert_eq!(val, 57);
+ }
+ }
+ Ok(())
+}
+
+fn main() -> Result<(), ()> {
+ test1().expect_err("test1 should fail");
+ test2()
+ ?
+ ;
+ Ok(())
+}
diff --git a/tests/coverage-map/status-quo/unused.cov-map b/tests/coverage-map/status-quo/unused.cov-map
new file mode 100644
index 000000000..c8b8f195f
--- /dev/null
+++ b/tests/coverage-map/status-quo/unused.cov-map
@@ -0,0 +1,94 @@
+Function name: unused::foo::<f32>
+Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(1), rhs = Counter(2)
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17)
+ = (c0 + (c1 + c2))
+- Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25)
+- Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15)
+ = (c1 + c2)
+- Code(Counter(3)) at (prev + 2, 1) to (start + 0, 2)
+
+Function name: unused::foo::<u32>
+Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 4
+- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add)
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3)
+- expression 3 operands: lhs = Counter(1), rhs = Counter(2)
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17)
+ = (c0 + (c1 + c2))
+- Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15)
+ = ((c0 + (c1 + c2)) - c3)
+- Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25)
+- Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15)
+ = (c1 + c2)
+- Code(Counter(3)) at (prev + 2, 1) to (start + 0, 2)
+
+Function name: unused::main
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 25, 01, 04, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 1
+- Code(Counter(0)) at (prev + 37, 1) to (start + 4, 2)
+
+Function name: unused::unused_func (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 13, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 19, 1) to (start + 1, 14)
+- Code(Zero) at (prev + 1, 15) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: unused::unused_func2 (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 19, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 25, 1) to (start + 1, 14)
+- Code(Zero) at (prev + 1, 15) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: unused::unused_func3 (unused)
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 1f, 01, 01, 0e, 00, 01, 0f, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 31, 1) to (start + 1, 14)
+- Code(Zero) at (prev + 1, 15) to (start + 2, 6)
+- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
+- Code(Zero) at (prev + 1, 1) to (start + 0, 2)
+
+Function name: unused::unused_template_func::<_> (unused)
+Raw bytes (34): 0x[01, 01, 00, 06, 01, 0b, 01, 01, 12, 00, 02, 0b, 00, 11, 00, 01, 09, 00, 0f, 00, 00, 13, 00, 19, 00, 01, 09, 00, 0f, 00, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 6
+- Code(Counter(0)) at (prev + 11, 1) to (start + 1, 18)
+- Code(Zero) at (prev + 2, 11) to (start + 0, 17)
+- Code(Zero) at (prev + 1, 9) to (start + 0, 15)
+- Code(Zero) at (prev + 0, 19) to (start + 0, 25)
+- Code(Zero) at (prev + 1, 9) to (start + 0, 15)
+- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
+
diff --git a/tests/coverage-map/status-quo/unused.rs b/tests/coverage-map/status-quo/unused.rs
new file mode 100644
index 000000000..d985af135
--- /dev/null
+++ b/tests/coverage-map/status-quo/unused.rs
@@ -0,0 +1,41 @@
+#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)]
+
+fn foo<T>(x: T) {
+ let mut i = 0;
+ while i < 10 {
+ i != 0 || i != 0;
+ i += 1;
+ }
+}
+
+fn unused_template_func<T>(x: T) {
+ let mut i = 0;
+ while i < 10 {
+ i != 0 || i != 0;
+ i += 1;
+ }
+}
+
+fn unused_func(mut a: u32) {
+ if a != 0 {
+ a += 1;
+ }
+}
+
+fn unused_func2(mut a: u32) {
+ if a != 0 {
+ a += 1;
+ }
+}
+
+fn unused_func3(mut a: u32) {
+ if a != 0 {
+ a += 1;
+ }
+}
+
+fn main() -> Result<(), u8> {
+ foo::<u32>(0);
+ foo::<f32>(0.0);
+ Ok(())
+}
diff --git a/tests/coverage-map/status-quo/while.cov-map b/tests/coverage-map/status-quo/while.cov-map
new file mode 100644
index 000000000..cfd2be96a
--- /dev/null
+++ b/tests/coverage-map/status-quo/while.cov-map
@@ -0,0 +1,15 @@
+Function name: while::main
+Raw bytes (28): 0x[01, 01, 02, 01, 05, 03, 05, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 2
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1)
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16)
+- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20)
+ = (c0 + c1)
+- Code(Zero) at (prev + 0, 21) to (start + 1, 6)
+- Code(Expression(1, Sub)) at (prev + 2, 1) to (start + 0, 2)
+ = ((c0 + c1) - c1)
+
diff --git a/tests/coverage-map/status-quo/while.rs b/tests/coverage-map/status-quo/while.rs
new file mode 100644
index 000000000..781b90b35
--- /dev/null
+++ b/tests/coverage-map/status-quo/while.rs
@@ -0,0 +1,5 @@
+fn main() {
+ let num = 9;
+ while num >= 10 {
+ }
+}
diff --git a/tests/coverage-map/status-quo/while_early_ret.cov-map b/tests/coverage-map/status-quo/while_early_ret.cov-map
new file mode 100644
index 000000000..369ebe891
--- /dev/null
+++ b/tests/coverage-map/status-quo/while_early_ret.cov-map
@@ -0,0 +1,26 @@
+Function name: while_early_ret::main
+Raw bytes (61): 0x[01, 01, 06, 01, 05, 03, 09, 0e, 05, 03, 09, 17, 09, 0d, 11, 09, 01, 04, 01, 01, 1b, 03, 03, 09, 02, 0a, 0e, 05, 0d, 02, 0e, 0a, 06, 15, 02, 16, 0d, 04, 15, 00, 1b, 11, 04, 15, 00, 1b, 05, 03, 0a, 03, 0a, 09, 06, 05, 00, 0b, 13, 01, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 6
+- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
+- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2)
+- expression 2 operands: lhs = Expression(3, Sub), rhs = Counter(1)
+- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2)
+- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(2)
+- expression 5 operands: lhs = Counter(3), rhs = Counter(4)
+Number of file 0 mappings: 9
+- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 27)
+- Code(Expression(0, Add)) at (prev + 3, 9) to (start + 2, 10)
+ = (c0 + c1)
+- Code(Expression(3, Sub)) at (prev + 5, 13) to (start + 2, 14)
+ = ((c0 + c1) - c2)
+- Code(Expression(2, Sub)) at (prev + 6, 21) to (start + 2, 22)
+ = (((c0 + c1) - c2) - c1)
+- Code(Counter(3)) at (prev + 4, 21) to (start + 0, 27)
+- Code(Counter(4)) at (prev + 4, 21) to (start + 0, 27)
+- Code(Counter(1)) at (prev + 3, 10) to (start + 3, 10)
+- Code(Counter(2)) at (prev + 6, 5) to (start + 0, 11)
+- Code(Expression(4, Add)) at (prev + 1, 1) to (start + 0, 2)
+ = ((c3 + c4) + c2)
+
diff --git a/tests/coverage-map/status-quo/while_early_ret.rs b/tests/coverage-map/status-quo/while_early_ret.rs
new file mode 100644
index 000000000..b2f0eee2c
--- /dev/null
+++ b/tests/coverage-map/status-quo/while_early_ret.rs
@@ -0,0 +1,42 @@
+#![allow(unused_assignments)]
+// failure-status: 1
+
+fn main() -> Result<(), u8> {
+ let mut countdown = 10;
+ while
+ countdown
+ >
+ 0
+ {
+ if
+ countdown
+ <
+ 5
+ {
+ return
+ if
+ countdown
+ >
+ 8
+ {
+ Ok(())
+ }
+ else
+ {
+ Err(1)
+ }
+ ;
+ }
+ countdown
+ -=
+ 1
+ ;
+ }
+ Ok(())
+}
+
+// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and
+// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux
+// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program
+// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical
+// to the coverage test for early returns, but this is a limitation that should be fixed.
diff --git a/tests/coverage-map/status-quo/yield.cov-map b/tests/coverage-map/status-quo/yield.cov-map
new file mode 100644
index 000000000..16caa2db3
--- /dev/null
+++ b/tests/coverage-map/status-quo/yield.cov-map
@@ -0,0 +1,72 @@
+Function name: yield::main
+Raw bytes (118): 0x[01, 01, 11, 01, 00, 05, 09, 0d, 00, 0d, 11, 32, 15, 0d, 11, 11, 15, 2e, 00, 32, 15, 0d, 11, 2e, 00, 32, 15, 0d, 11, 19, 1d, 21, 00, 25, 29, 2d, 00, 10, 01, 07, 01, 01, 16, 03, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 07, 01, 0e, 00, 34, 0b, 02, 0b, 00, 2e, 32, 01, 22, 00, 27, 2e, 00, 2c, 00, 2e, 1b, 01, 0e, 00, 34, 1f, 03, 09, 00, 16, 2b, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 37, 01, 0e, 00, 34, 3b, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 3f, 01, 0e, 00, 34, 43, 02, 01, 00, 02]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 17
+- expression 0 operands: lhs = Counter(0), rhs = Zero
+- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
+- expression 2 operands: lhs = Counter(3), rhs = Zero
+- expression 3 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 4 operands: lhs = Expression(12, Sub), rhs = Counter(5)
+- expression 5 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 6 operands: lhs = Counter(4), rhs = Counter(5)
+- expression 7 operands: lhs = Expression(11, Sub), rhs = Zero
+- expression 8 operands: lhs = Expression(12, Sub), rhs = Counter(5)
+- expression 9 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 10 operands: lhs = Expression(11, Sub), rhs = Zero
+- expression 11 operands: lhs = Expression(12, Sub), rhs = Counter(5)
+- expression 12 operands: lhs = Counter(3), rhs = Counter(4)
+- expression 13 operands: lhs = Counter(6), rhs = Counter(7)
+- expression 14 operands: lhs = Counter(8), rhs = Zero
+- expression 15 operands: lhs = Counter(9), rhs = Counter(10)
+- expression 16 operands: lhs = Counter(11), rhs = Zero
+Number of file 0 mappings: 16
+- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 22)
+- Code(Expression(0, Add)) at (prev + 6, 11) to (start + 0, 46)
+ = (c0 + Zero)
+- Code(Counter(3)) at (prev + 1, 39) to (start + 0, 41)
+- Code(Expression(1, Add)) at (prev + 1, 14) to (start + 0, 52)
+ = (c1 + c2)
+- Code(Expression(2, Add)) at (prev + 2, 11) to (start + 0, 46)
+ = (c3 + Zero)
+- Code(Expression(12, Sub)) at (prev + 1, 34) to (start + 0, 39)
+ = (c3 - c4)
+- Code(Expression(11, Sub)) at (prev + 0, 44) to (start + 0, 46)
+ = ((c3 - c4) - c5)
+- Code(Expression(6, Add)) at (prev + 1, 14) to (start + 0, 52)
+ = (c4 + c5)
+- Code(Expression(7, Add)) at (prev + 3, 9) to (start + 0, 22)
+ = (((c3 - c4) - c5) + Zero)
+- Code(Expression(10, Add)) at (prev + 7, 11) to (start + 0, 46)
+ = (((c3 - c4) - c5) + Zero)
+- Code(Counter(8)) at (prev + 1, 39) to (start + 0, 41)
+- Code(Expression(13, Add)) at (prev + 1, 14) to (start + 0, 52)
+ = (c6 + c7)
+- Code(Expression(14, Add)) at (prev + 2, 11) to (start + 0, 46)
+ = (c8 + Zero)
+- Code(Counter(11)) at (prev + 1, 39) to (start + 0, 41)
+- Code(Expression(15, Add)) at (prev + 1, 14) to (start + 0, 52)
+ = (c9 + c10)
+- Code(Expression(16, Add)) at (prev + 2, 1) to (start + 0, 2)
+ = (c11 + Zero)
+
+Function name: yield::main::{closure#0}
+Raw bytes (14): 0x[01, 01, 00, 02, 01, 08, 1c, 01, 10, 05, 02, 10, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 2
+- Code(Counter(0)) at (prev + 8, 28) to (start + 1, 16)
+- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6)
+
+Function name: yield::main::{closure#1}
+Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 1c, 01, 10, 05, 02, 09, 00, 10, 09, 01, 09, 00, 10, 0d, 01, 10, 01, 06]
+Number of files: 1
+- file 0 => global file 1
+Number of expressions: 0
+Number of file 0 mappings: 4
+- Code(Counter(0)) at (prev + 22, 28) to (start + 1, 16)
+- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16)
+- Code(Counter(2)) at (prev + 1, 9) to (start + 0, 16)
+- Code(Counter(3)) at (prev + 1, 16) to (start + 1, 6)
+
diff --git a/tests/coverage-map/status-quo/yield.rs b/tests/coverage-map/status-quo/yield.rs
new file mode 100644
index 000000000..361275c92
--- /dev/null
+++ b/tests/coverage-map/status-quo/yield.rs
@@ -0,0 +1,37 @@
+#![feature(generators, generator_trait)]
+#![allow(unused_assignments)]
+
+use std::ops::{Generator, GeneratorState};
+use std::pin::Pin;
+
+fn main() {
+ let mut generator = || {
+ yield 1;
+ return "foo";
+ };
+
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Yielded(1) => {}
+ _ => panic!("unexpected value from resume"),
+ }
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Complete("foo") => {}
+ _ => panic!("unexpected value from resume"),
+ }
+
+ let mut generator = || {
+ yield 1;
+ yield 2;
+ yield 3;
+ return "foo";
+ };
+
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Yielded(1) => {}
+ _ => panic!("unexpected value from resume"),
+ }
+ match Pin::new(&mut generator).resume(()) {
+ GeneratorState::Yielded(2) => {}
+ _ => panic!("unexpected value from resume"),
+ }
+}