@@ -56,6 +56,10 @@ pub(super) struct MCDCDecision {
56
56
57
57
#[ derive( Default ) ]
58
58
pub ( super ) struct ExtractedMappings {
59
+ /// Store our own copy of [`CoverageGraph::num_nodes`], so that we don't
60
+ /// need access to the whole graph when allocating per-BCB data. This is
61
+ /// only public so that other code can still use exhaustive destructuring.
62
+ pub ( super ) num_bcbs : usize ,
59
63
pub ( super ) code_mappings : Vec < CodeMapping > ,
60
64
pub ( super ) branch_pairs : Vec < BranchPair > ,
61
65
pub ( super ) mcdc_bitmap_bytes : u32 ,
@@ -106,6 +110,7 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
106
110
) ;
107
111
108
112
ExtractedMappings {
113
+ num_bcbs : basic_coverage_blocks. num_nodes ( ) ,
109
114
code_mappings,
110
115
branch_pairs,
111
116
mcdc_bitmap_bytes,
@@ -115,12 +120,10 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
115
120
}
116
121
117
122
impl ExtractedMappings {
118
- pub ( super ) fn all_bcbs_with_counter_mappings (
119
- & self ,
120
- basic_coverage_blocks : & CoverageGraph , // Only used for allocating a correctly-sized set
121
- ) -> BitSet < BasicCoverageBlock > {
123
+ pub ( super ) fn all_bcbs_with_counter_mappings ( & self ) -> BitSet < BasicCoverageBlock > {
122
124
// Fully destructure self to make sure we don't miss any fields that have mappings.
123
125
let Self {
126
+ num_bcbs,
124
127
code_mappings,
125
128
branch_pairs,
126
129
mcdc_bitmap_bytes : _,
@@ -129,7 +132,7 @@ impl ExtractedMappings {
129
132
} = self ;
130
133
131
134
// Identify which BCBs have one or more mappings.
132
- let mut bcbs_with_counter_mappings = BitSet :: new_empty ( basic_coverage_blocks . num_nodes ( ) ) ;
135
+ let mut bcbs_with_counter_mappings = BitSet :: new_empty ( * num_bcbs ) ;
133
136
let mut insert = |bcb| {
134
137
bcbs_with_counter_mappings. insert ( bcb) ;
135
138
} ;
0 commit comments