Skip to content

Commit bddf980

Browse files
author
zhuyunxing
committed
coverage. Fix test typo and reformat
1 parent bc513ac commit bddf980

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

compiler/rustc_mir_transform/src/coverage/mappings.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ use std::collections::BTreeSet;
22

33
use rustc_data_structures::fx::FxIndexMap;
44
use rustc_data_structures::graph::DirectedGraph;
5-
use rustc_index::bit_set::BitSet;
65
use rustc_index::IndexVec;
6+
use rustc_index::bit_set::BitSet;
77
use rustc_middle::mir::coverage::{
88
BlockMarkerId, BranchSpan, ConditionId, ConditionInfo, CoverageInfoHi, CoverageKind,
99
};
1010
use rustc_middle::mir::{self, BasicBlock, StatementKind};
1111
use rustc_middle::ty::TyCtxt;
1212
use rustc_span::Span;
1313

14+
use crate::coverage::ExtractedHirInfo;
1415
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, START_BCB};
1516
use crate::coverage::spans::extract_refined_covspans;
1617
use crate::coverage::unexpand::unexpand_into_body_span;
17-
use crate::coverage::ExtractedHirInfo;
1818
use crate::errors::MCDCExceedsTestVectorLimit;
1919

2020
/// Associates an ordinary executable code span with its corresponding BCB.
@@ -330,11 +330,7 @@ pub(super) fn extract_mcdc_mappings(
330330
.reduce(|lhs, rhs| lhs.to(rhs))
331331
.map(
332332
|joint_span| {
333-
if decision_span.contains(joint_span) {
334-
decision_span
335-
} else {
336-
joint_span
337-
}
333+
if decision_span.contains(joint_span) { decision_span } else { joint_span }
338334
},
339335
)
340336
.expect("branch mappings are ensured to be non-empty as checked above");

tests/coverage/mcdc/condition-limit.cov-map

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function name: condition_limit::accpet_7_conditions
1+
Function name: condition_limit::accept_7_conditions
22
Raw bytes (232): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 12, 01, 07, 01, 02, 09, 28, 08, 07, 02, 08, 00, 27, 30, 05, 02, 01, 07, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 7a, 1d, 07, 06, 00, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 30, 76, 19, 06, 05, 00, 00, 12, 00, 13, 76, 00, 17, 00, 18, 30, 72, 15, 05, 04, 00, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 30, 6e, 11, 04, 03, 00, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 30, 6a, 0d, 03, 02, 00, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 30, 21, 09, 02, 00, 00, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 06, 00, 07, 97, 01, 01, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1

tests/coverage/mcdc/condition-limit.coverage

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
55
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
7-
LL| 2|fn accpet_7_conditions(bool_arr: [bool; 7]) {
7+
LL| 2|fn accept_7_conditions(bool_arr: [bool; 7]) {
88
LL| 2| let [a, b, c, d, e, f, g] = bool_arr;
99
LL| 2| if a && b && c && d && e && f && g {
1010
^1 ^1 ^1 ^1 ^1 ^1
@@ -50,7 +50,7 @@
5050
LL| |
5151
LL| |#[coverage(off)]
5252
LL| |fn main() {
53-
LL| | accpet_7_conditions([false; 7]);
54-
LL| | accpet_7_conditions([true; 7]);
53+
LL| | accept_7_conditions([false; 7]);
54+
LL| | accept_7_conditions([true; 7]);
5555
LL| |}
5656

tests/coverage/mcdc/condition-limit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ compile-flags: -Zcoverage-options=mcdc
55
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

7-
fn accpet_7_conditions(bool_arr: [bool; 7]) {
7+
fn accept_7_conditions(bool_arr: [bool; 7]) {
88
let [a, b, c, d, e, f, g] = bool_arr;
99
if a && b && c && d && e && f && g {
1010
core::hint::black_box("hello");
@@ -13,6 +13,6 @@ fn accpet_7_conditions(bool_arr: [bool; 7]) {
1313

1414
#[coverage(off)]
1515
fn main() {
16-
accpet_7_conditions([false; 7]);
17-
accpet_7_conditions([true; 7]);
16+
accept_7_conditions([false; 7]);
17+
accept_7_conditions([true; 7]);
1818
}

tests/coverage/mcdc/if.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
LL| |
163163
LL| 4|fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) {
164164
LL| 4| // Contradict to `mcdc_check_tree_decision`,
165-
LL| 4| // 100% branch coverage of this expression does not mean indicates 100% mcdc coverage.
165+
LL| 4| // 100% branch coverage of this expression does not indicate 100% mcdc coverage.
166166
LL| 4| if (a || b) && c {
167167
^1
168168
------------------

tests/coverage/mcdc/if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn mcdc_check_tree_decision(a: bool, b: bool, c: bool) {
4848

4949
fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) {
5050
// Contradict to `mcdc_check_tree_decision`,
51-
// 100% branch coverage of this expression does not mean indicates 100% mcdc coverage.
51+
// 100% branch coverage of this expression does not indicate 100% mcdc coverage.
5252
if (a || b) && c {
5353
say("pass");
5454
} else {

0 commit comments

Comments
 (0)