@@ -99,14 +99,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
9999 let mut coverage_counters =
100100 CoverageCounters :: make_bcb_counters ( & basic_coverage_blocks, bcb_has_counter_mappings) ;
101101
102- let mappings = create_mappings (
103- mir_body,
104- tcx,
105- & hir_info,
106- & extracted_mappings,
107- & basic_coverage_blocks,
108- & mut coverage_counters,
109- ) ;
102+ let mappings = create_mappings ( tcx, & hir_info, & extracted_mappings, & mut coverage_counters) ;
110103 if mappings. is_empty ( ) {
111104 // No spans could be converted into valid mappings, so skip this function.
112105 debug ! ( "no spans could be converted into valid mappings; skipping" ) ;
@@ -145,11 +138,9 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
145138/// Precondition: All BCBs corresponding to those spans have been given
146139/// coverage counters.
147140fn create_mappings < ' tcx > (
148- mir_body : & mut mir:: Body < ' tcx > ,
149141 tcx : TyCtxt < ' tcx > ,
150142 hir_info : & ExtractedHirInfo ,
151143 extracted_mappings : & ExtractedMappings ,
152- basic_coverage_blocks : & CoverageGraph ,
153144 coverage_counters : & mut CoverageCounters ,
154145) -> Vec < Mapping > {
155146 let source_map = tcx. sess . source_map ( ) ;
@@ -198,7 +189,7 @@ fn create_mappings<'tcx>(
198189 Some ( Mapping { kind, code_region } )
199190 } ,
200191 ) ) ;
201- let mut term_for_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
192+ let mut term_for_sum_of_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
202193 let counters = bcbs
203194 . into_iter ( )
204195 . copied ( )
@@ -210,28 +201,15 @@ fn create_mappings<'tcx>(
210201 . into_iter ( )
211202 . fold ( None , |acc, val| Some ( coverage_counters. make_sum_expression ( acc, val) ) )
212203 . expect ( "counters must be non-empty" ) ;
213- // Since the counter is a sum of multiple counters, it should be marked used in
214- // all associated bcbs in case it were markered as `Zero`.
215- if bcbs. len ( ) > 1
216- && let counters:: BcbCounter :: Expression { id } = counter
217- {
218- for & bcb in bcbs {
219- inject_statement (
220- mir_body,
221- CoverageKind :: ExpressionUsed { id } ,
222- basic_coverage_blocks[ bcb] . leader_bb ( ) ,
223- ) ;
224- }
225- }
226204 counter. as_term ( )
227205 } ;
228206
229207 // MCDC branch mappings are appended with their decisions in case decisions were ignored.
230208 mappings. extend ( mcdc_degraded_branches. iter ( ) . filter_map (
231209 |& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info : _ } | {
232210 let code_region = region_for_span ( span) ?;
233- let true_term = term_for_bcbs ( true_bcbs) ;
234- let false_term = term_for_bcbs ( false_bcbs) ;
211+ let true_term = term_for_sum_of_bcbs ( true_bcbs) ;
212+ let false_term = term_for_sum_of_bcbs ( false_bcbs) ;
235213 Some ( Mapping { kind : MappingKind :: Branch { true_term, false_term } , code_region } )
236214 } ,
237215 ) ) ;
@@ -243,8 +221,8 @@ fn create_mappings<'tcx>(
243221 . filter_map (
244222 |& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info } | {
245223 let code_region = region_for_span ( span) ?;
246- let true_term = term_for_bcbs ( true_bcbs) ;
247- let false_term = term_for_bcbs ( false_bcbs) ;
224+ let true_term = term_for_sum_of_bcbs ( true_bcbs) ;
225+ let false_term = term_for_sum_of_bcbs ( false_bcbs) ;
248226 Some ( Mapping {
249227 kind : MappingKind :: MCDCBranch {
250228 true_term,
0 commit comments