Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3f670c601be2f58554d33e493c52388969ccebc0
Choose a base ref
..
head repository: rust-lang/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fa7454a856c467be5608692939c745ecff9f9064
Choose a head ref
12 changes: 5 additions & 7 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
@@ -152,7 +152,8 @@ fn create_mappings<'tcx>(
let mut arms_rev = arm_list.iter().rev();

let mut rest_counter = {
// The last arm's span is ignored.
// The last arm's span is ignored, because its BCB is only used as the
// false branch of the second-last arm; it's not a branch of its own.
let Some(&BcbBranchArm { span: _, bcb }) = arms_rev.next() else { continue };
coverage_counters.bcb_counter(bcb).expect("all relevant BCBs have counters")
};
@@ -165,12 +166,9 @@ fn create_mappings<'tcx>(
false_term: rest_counter.as_term(),
};

mappings.extend::<Option<_>>(
try {
let code_region = make_code_region(source_map, file_name, span, body_span)?;
Mapping { kind, code_region }
},
);
if let Some(code_region) = make_code_region(source_map, file_name, span, body_span) {
mappings.push(Mapping { kind, code_region });
}

// FIXME: Avoid creating an unused expression on the last iteration.
rest_counter = coverage_counters.make_expression(true_counter, Op::Add, rest_counter);
12 changes: 6 additions & 6 deletions tests/coverage/branch/match-arms.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: match_arms::guards
Raw bytes (180): 0x[01, 01, 22, 31, 1f, 2d, 37, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 2d, 37, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 6f, 25, 73, 21, 77, 1d, 7b, 19, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 10, 01, 31, 01, 01, 10, 29, 03, 0b, 00, 10, 20, 35, 03, 01, 09, 00, 13, 19, 00, 11, 00, 29, 20, 19, 09, 00, 17, 00, 1b, 20, 31, 1f, 01, 09, 00, 13, 1d, 00, 11, 00, 29, 20, 1d, 0d, 00, 17, 00, 1b, 20, 2d, 37, 01, 09, 00, 13, 21, 00, 11, 00, 29, 20, 21, 11, 00, 17, 00, 1b, 20, 29, 7b, 01, 09, 00, 13, 25, 00, 11, 00, 29, 20, 25, 15, 00, 17, 00, 1b, 7b, 01, 0e, 00, 18, 6b, 03, 05, 01, 02]
Raw bytes (180): 0x[01, 01, 22, 31, 1f, 2d, 37, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 2d, 37, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 29, 7b, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 6f, 25, 73, 21, 77, 1d, 7b, 19, 7f, 15, 83, 01, 11, 87, 01, 0d, 00, 09, 10, 01, 30, 01, 01, 10, 29, 03, 0b, 00, 10, 20, 35, 03, 01, 09, 00, 13, 19, 00, 11, 00, 29, 20, 19, 09, 00, 17, 00, 1b, 20, 31, 1f, 01, 09, 00, 13, 1d, 00, 11, 00, 29, 20, 1d, 0d, 00, 17, 00, 1b, 20, 2d, 37, 01, 09, 00, 13, 21, 00, 11, 00, 29, 20, 21, 11, 00, 17, 00, 1b, 20, 29, 7b, 01, 09, 00, 13, 25, 00, 11, 00, 29, 20, 25, 15, 00, 17, 00, 1b, 7b, 01, 0e, 00, 18, 6b, 03, 05, 01, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 34
@@ -38,7 +38,7 @@ Number of expressions: 34
- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(3)
- expression 33 operands: lhs = Zero, rhs = Counter(2)
Number of file 0 mappings: 16
- Code(Counter(0)) at (prev + 49, 1) to (start + 1, 16)
- Code(Counter(0)) at (prev + 48, 1) to (start + 1, 16)
- Code(Counter(10)) at (prev + 3, 11) to (start + 0, 16)
- Branch { true: Counter(13), false: Expression(0, Add) } at (prev + 1, 9) to (start + 0, 19)
true = c13
@@ -74,7 +74,7 @@ Number of file 0 mappings: 16
= ((((((((Zero + c2) + c3) + c4) + c5) + c6) + c7) + c8) + c9)

Function name: match_arms::match_arms
Raw bytes (102): 0x[01, 01, 15, 0d, 17, 09, 4a, 05, 4f, 53, 11, 09, 0d, 09, 4a, 05, 4f, 53, 11, 09, 0d, 05, 4f, 53, 11, 09, 0d, 05, 4f, 53, 11, 09, 0d, 43, 4a, 47, 09, 11, 0d, 05, 4f, 53, 11, 09, 0d, 0a, 01, 19, 01, 01, 10, 05, 03, 0b, 00, 10, 20, 11, 03, 01, 09, 00, 13, 11, 00, 11, 00, 21, 20, 0d, 17, 01, 09, 00, 13, 0d, 00, 11, 00, 21, 20, 09, 4a, 01, 09, 00, 13, 09, 00, 11, 00, 21, 4a, 01, 11, 00, 21, 3f, 03, 05, 01, 02]
Raw bytes (102): 0x[01, 01, 15, 0d, 17, 09, 4a, 05, 4f, 53, 11, 09, 0d, 09, 4a, 05, 4f, 53, 11, 09, 0d, 05, 4f, 53, 11, 09, 0d, 05, 4f, 53, 11, 09, 0d, 43, 4a, 47, 09, 11, 0d, 05, 4f, 53, 11, 09, 0d, 0a, 01, 18, 01, 01, 10, 05, 03, 0b, 00, 10, 20, 11, 03, 01, 09, 00, 13, 11, 00, 11, 00, 21, 20, 0d, 17, 01, 09, 00, 13, 0d, 00, 11, 00, 21, 20, 09, 4a, 01, 09, 00, 13, 09, 00, 11, 00, 21, 4a, 01, 11, 00, 21, 3f, 03, 05, 01, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 21
@@ -100,7 +100,7 @@ Number of expressions: 21
- expression 19 operands: lhs = Expression(20, Add), rhs = Counter(4)
- expression 20 operands: lhs = Counter(2), rhs = Counter(3)
Number of file 0 mappings: 10
- Code(Counter(0)) at (prev + 25, 1) to (start + 1, 16)
- Code(Counter(0)) at (prev + 24, 1) to (start + 1, 16)
- Code(Counter(1)) at (prev + 3, 11) to (start + 0, 16)
- Branch { true: Counter(4), false: Expression(0, Add) } at (prev + 1, 9) to (start + 0, 19)
true = c4
@@ -120,7 +120,7 @@ Number of file 0 mappings: 10
= (((c4 + c3) + c2) + (c1 - ((c2 + c3) + c4)))

Function name: match_arms::or_patterns
Raw bytes (75): 0x[01, 01, 0d, 11, 0d, 05, 2f, 33, 11, 09, 0d, 09, 2a, 05, 2f, 33, 11, 09, 0d, 03, 27, 09, 2a, 05, 2f, 33, 11, 09, 0d, 09, 01, 26, 01, 01, 10, 05, 03, 0b, 00, 10, 11, 01, 11, 00, 12, 0d, 00, 1e, 00, 1f, 03, 00, 24, 00, 2e, 09, 01, 11, 00, 12, 2a, 00, 1e, 00, 1f, 27, 00, 24, 00, 2e, 23, 03, 05, 01, 02]
Raw bytes (75): 0x[01, 01, 0d, 11, 0d, 05, 2f, 33, 11, 09, 0d, 09, 2a, 05, 2f, 33, 11, 09, 0d, 03, 27, 09, 2a, 05, 2f, 33, 11, 09, 0d, 09, 01, 25, 01, 01, 10, 05, 03, 0b, 00, 10, 11, 01, 11, 00, 12, 0d, 00, 1e, 00, 1f, 03, 00, 24, 00, 2e, 09, 01, 11, 00, 12, 2a, 00, 1e, 00, 1f, 27, 00, 24, 00, 2e, 23, 03, 05, 01, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 13
@@ -138,7 +138,7 @@ Number of expressions: 13
- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(4)
- expression 12 operands: lhs = Counter(2), rhs = Counter(3)
Number of file 0 mappings: 9
- Code(Counter(0)) at (prev + 38, 1) to (start + 1, 16)
- Code(Counter(0)) at (prev + 37, 1) to (start + 1, 16)
- Code(Counter(1)) at (prev + 3, 11) to (start + 0, 16)
- Code(Counter(4)) at (prev + 1, 17) to (start + 0, 18)
- Code(Counter(3)) at (prev + 0, 30) to (start + 0, 31)
3 changes: 1 addition & 2 deletions tests/coverage/branch/match-arms.coverage
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@
LL| |//@ compile-flags: -Zcoverage-options=branch
LL| |//@ llvm-cov-flags: --show-branches=count
LL| |
LL| |// Tests for branch coverage of the lazy boolean operators `&&` and `||`,
LL| |// as ordinary expressions that aren't part of an `if` condition or similar.
LL| |// Tests for branch coverage of various kinds of match arms.
LL| |
LL| |// Helper macro to prevent start-of-function spans from being merged into
LL| |// spans on the lines we care about.
3 changes: 1 addition & 2 deletions tests/coverage/branch/match-arms.rs
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@
//@ compile-flags: -Zcoverage-options=branch
//@ llvm-cov-flags: --show-branches=count

// Tests for branch coverage of the lazy boolean operators `&&` and `||`,
// as ordinary expressions that aren't part of an `if` condition or similar.
// Tests for branch coverage of various kinds of match arms.

// Helper macro to prevent start-of-function spans from being merged into
// spans on the lines we care about.