@@ -13,22 +13,14 @@ use crate::coverage::spans::{
13
13
};
14
14
use crate::coverage::ExtractedHirInfo;
15
15
16
- #[derive(Clone, Copy, Debug)]
17
- pub(super) enum BcbMappingKind {
18
- /// Associates an ordinary executable code span with its corresponding BCB.
19
- Code(BasicCoverageBlock),
20
- //
21
- // Branch and MC/DC mappings are more complex, so they are represented
22
- // separately.
23
- }
24
-
16
+ /// Associates an ordinary executable code span with its corresponding BCB.
25
17
#[derive(Debug)]
26
- pub(super) struct BcbMapping {
27
- pub(super) kind: BcbMappingKind,
18
+ pub(super) struct CodeMapping {
28
19
pub(super) span: Span,
20
+ pub(super) bcb: BasicCoverageBlock,
29
21
}
30
22
31
- /// This is separate from [`BcbMappingKind `] to help prepare for larger changes
23
+ /// This is separate from [`MCDCBranch `] to help prepare for larger changes
32
24
/// that will be needed for improved branch coverage in the future.
33
25
/// (See <https://github.com/rust-lang/rust/pull/124217>.)
34
26
#[derive(Debug)]
@@ -62,7 +54,7 @@ pub(super) struct MCDCDecision {
62
54
63
55
pub(super) struct CoverageSpans {
64
56
bcb_has_mappings: BitSet<BasicCoverageBlock>,
65
- pub(super) mappings : Vec<BcbMapping >,
57
+ pub(super) code_mappings : Vec<CodeMapping >,
66
58
pub(super) branch_pairs: Vec<BcbBranchPair>,
67
59
test_vector_bitmap_bytes: u32,
68
60
pub(super) mcdc_branches: Vec<MCDCBranch>,
@@ -88,7 +80,7 @@ pub(super) fn generate_coverage_spans(
88
80
hir_info: &ExtractedHirInfo,
89
81
basic_coverage_blocks: &CoverageGraph,
90
82
) -> Option<CoverageSpans> {
91
- let mut mappings = vec![];
83
+ let mut code_mappings = vec![];
92
84
let mut branch_pairs = vec![];
93
85
let mut mcdc_branches = vec![];
94
86
let mut mcdc_decisions = vec![];
@@ -99,10 +91,10 @@ pub(super) fn generate_coverage_spans(
99
91
// outer function will be unhelpful, so just keep the signature span
100
92
// and ignore all of the spans in the MIR body.
101
93
if let Some(span) = hir_info.fn_sig_span_extended {
102
- mappings .push(BcbMapping { kind: BcbMappingKind::Code(START_BCB), span });
94
+ code_mappings .push(CodeMapping { span, bcb: START_BCB });
103
95
}
104
96
} else {
105
- extract_refined_covspans(mir_body, hir_info, basic_coverage_blocks, &mut mappings );
97
+ extract_refined_covspans(mir_body, hir_info, basic_coverage_blocks, &mut code_mappings );
106
98
107
99
branch_pairs.extend(extract_branch_pairs(mir_body, hir_info, basic_coverage_blocks));
108
100
@@ -115,7 +107,7 @@ pub(super) fn generate_coverage_spans(
115
107
);
116
108
}
117
109
118
- if mappings .is_empty()
110
+ if code_mappings .is_empty()
119
111
&& branch_pairs.is_empty()
120
112
&& mcdc_branches.is_empty()
121
113
&& mcdc_decisions.is_empty()
@@ -129,10 +121,8 @@ pub(super) fn generate_coverage_spans(
129
121
bcb_has_mappings.insert(bcb);
130
122
};
131
123
132
- for &BcbMapping { kind, span: _ } in &mappings {
133
- match kind {
134
- BcbMappingKind::Code(bcb) => insert(bcb),
135
- }
124
+ for &CodeMapping { span: _, bcb } in &code_mappings {
125
+ insert(bcb);
136
126
}
137
127
for &BcbBranchPair { true_bcb, false_bcb, .. } in &branch_pairs {
138
128
insert(true_bcb);
@@ -154,7 +144,7 @@ pub(super) fn generate_coverage_spans(
154
144
155
145
Some(CoverageSpans {
156
146
bcb_has_mappings,
157
- mappings ,
147
+ code_mappings ,
158
148
branch_pairs,
159
149
test_vector_bitmap_bytes,
160
150
mcdc_branches,
0 commit comments