Skip to content

Commit 92f6c8e

Browse files
committed
coverage: Add another simple test for guarded match arms
1 parent 6733502 commit 92f6c8e

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Function name: guard_simple::never_taken
2+
Raw bytes (56): 0x[01, 01, 04, 01, 05, 11, 09, 0f, 0d, 05, 09, 08, 01, 08, 01, 02, 1e, 20, 05, 02, 02, 0e, 00, 1e, 05, 00, 22, 00, 24, 11, 01, 0e, 00, 1e, 20, 09, 06, 00, 0e, 00, 1e, 09, 00, 22, 00, 24, 0d, 01, 0e, 00, 10, 0b, 02, 01, 00, 02]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 4
6+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
7+
- expression 1 operands: lhs = Counter(4), rhs = Counter(2)
8+
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(3)
9+
- expression 3 operands: lhs = Counter(1), rhs = Counter(2)
10+
Number of file 0 mappings: 8
11+
- Code(Counter(0)) at (prev + 8, 1) to (start + 2, 30)
12+
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 2, 14) to (start + 0, 30)
13+
true = c1
14+
false = (c0 - c1)
15+
- Code(Counter(1)) at (prev + 0, 34) to (start + 0, 36)
16+
- Code(Counter(4)) at (prev + 1, 14) to (start + 0, 30)
17+
- Branch { true: Counter(2), false: Expression(1, Sub) } at (prev + 0, 14) to (start + 0, 30)
18+
true = c2
19+
false = (c4 - c2)
20+
- Code(Counter(2)) at (prev + 0, 34) to (start + 0, 36)
21+
- Code(Counter(3)) at (prev + 1, 14) to (start + 0, 16)
22+
- Code(Expression(2, Add)) at (prev + 2, 1) to (start + 0, 2)
23+
= ((c1 + c2) + c3)
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |//@ edition: 2021
3+
LL| |//@ compile-flags: -Zcoverage-options=branch
4+
LL| |//@ llvm-cov-flags: --show-branches=count
5+
LL| |
6+
LL| |use core::hint::black_box;
7+
LL| |
8+
LL| 1|fn never_taken() {
9+
LL| 1| match black_box(false) {
10+
LL| 1| _ if black_box(false) => {}
11+
^0
12+
------------------
13+
| Branch (LL:14): [True: 0, False: 1]
14+
------------------
15+
LL| 1| _ if black_box(false) => {}
16+
^0
17+
------------------
18+
| Branch (LL:14): [True: 0, False: 1]
19+
------------------
20+
LL| 1| _ => {}
21+
LL| | }
22+
LL| 1|}
23+
LL| |
24+
LL| |#[coverage(off)]
25+
LL| |fn main() {
26+
LL| | never_taken();
27+
LL| |}
28+

tests/coverage/branch/guard-simple.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(coverage_attribute)]
2+
//@ edition: 2021
3+
//@ compile-flags: -Zcoverage-options=branch
4+
//@ llvm-cov-flags: --show-branches=count
5+
6+
use core::hint::black_box;
7+
8+
fn never_taken() {
9+
match black_box(false) {
10+
_ if black_box(false) => {}
11+
_ if black_box(false) => {}
12+
_ => {}
13+
}
14+
}
15+
16+
#[coverage(off)]
17+
fn main() {
18+
never_taken();
19+
}

0 commit comments

Comments
 (0)