@@ -56,6 +56,10 @@ pub(super) struct MCDCDecision {
5656
5757#[ derive( Default ) ]
5858pub ( 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 ,
5963 pub ( super ) code_mappings : Vec < CodeMapping > ,
6064 pub ( super ) branch_pairs : Vec < BranchPair > ,
6165 pub ( super ) mcdc_bitmap_bytes : u32 ,
@@ -106,6 +110,7 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
106110 ) ;
107111
108112 ExtractedMappings {
113+ num_bcbs : basic_coverage_blocks. num_nodes ( ) ,
109114 code_mappings,
110115 branch_pairs,
111116 mcdc_bitmap_bytes,
@@ -115,12 +120,10 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
115120}
116121
117122impl 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 > {
122124 // Fully destructure self to make sure we don't miss any fields that have mappings.
123125 let Self {
126+ num_bcbs,
124127 code_mappings,
125128 branch_pairs,
126129 mcdc_bitmap_bytes : _,
@@ -129,7 +132,7 @@ impl ExtractedMappings {
129132 } = self ;
130133
131134 // 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 ) ;
133136 let mut insert = |bcb| {
134137 bcbs_with_counter_mappings. insert ( bcb) ;
135138 } ;
0 commit comments