@@ -13,22 +13,14 @@ use crate::coverage::spans::{
1313} ;
1414use crate :: coverage:: ExtractedHirInfo ;
1515
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.
2517#[ derive( Debug ) ]
26- pub ( super ) struct BcbMapping {
27- pub ( super ) kind : BcbMappingKind ,
18+ pub ( super ) struct CodeMapping {
2819 pub ( super ) span : Span ,
20+ pub ( super ) bcb : BasicCoverageBlock ,
2921}
3022
31- /// This is separate from [`BcbMappingKind `] to help prepare for larger changes
23+ /// This is separate from [`MCDCBranch `] to help prepare for larger changes
3224/// that will be needed for improved branch coverage in the future.
3325/// (See <https://github.com/rust-lang/rust/pull/124217>.)
3426#[ derive( Debug ) ]
@@ -62,7 +54,7 @@ pub(super) struct MCDCDecision {
6254
6355pub ( super ) struct CoverageSpans {
6456 bcb_has_mappings : BitSet < BasicCoverageBlock > ,
65- pub ( super ) mappings : Vec < BcbMapping > ,
57+ pub ( super ) code_mappings : Vec < CodeMapping > ,
6658 pub ( super ) branch_pairs : Vec < BcbBranchPair > ,
6759 test_vector_bitmap_bytes : u32 ,
6860 pub ( super ) mcdc_branches : Vec < MCDCBranch > ,
@@ -88,7 +80,7 @@ pub(super) fn generate_coverage_spans(
8880 hir_info : & ExtractedHirInfo ,
8981 basic_coverage_blocks : & CoverageGraph ,
9082) -> Option < CoverageSpans > {
91- let mut mappings = vec ! [ ] ;
83+ let mut code_mappings = vec ! [ ] ;
9284 let mut branch_pairs = vec ! [ ] ;
9385 let mut mcdc_branches = vec ! [ ] ;
9486 let mut mcdc_decisions = vec ! [ ] ;
@@ -99,10 +91,10 @@ pub(super) fn generate_coverage_spans(
9991 // outer function will be unhelpful, so just keep the signature span
10092 // and ignore all of the spans in the MIR body.
10193 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 } ) ;
10395 }
10496 } 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 ) ;
10698
10799 branch_pairs. extend ( extract_branch_pairs ( mir_body, hir_info, basic_coverage_blocks) ) ;
108100
@@ -115,7 +107,7 @@ pub(super) fn generate_coverage_spans(
115107 ) ;
116108 }
117109
118- if mappings . is_empty ( )
110+ if code_mappings . is_empty ( )
119111 && branch_pairs. is_empty ( )
120112 && mcdc_branches. is_empty ( )
121113 && mcdc_decisions. is_empty ( )
@@ -129,10 +121,8 @@ pub(super) fn generate_coverage_spans(
129121 bcb_has_mappings. insert ( bcb) ;
130122 } ;
131123
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) ;
136126 }
137127 for & BcbBranchPair { true_bcb, false_bcb, .. } in & branch_pairs {
138128 insert ( true_bcb) ;
@@ -154,7 +144,7 @@ pub(super) fn generate_coverage_spans(
154144
155145 Some ( CoverageSpans {
156146 bcb_has_mappings,
157- mappings ,
147+ code_mappings ,
158148 branch_pairs,
159149 test_vector_bitmap_bytes,
160150 mcdc_branches,
0 commit comments