@@ -227,6 +227,8 @@ struct Builder<'a, 'tcx> {
227227 // the root (most of them do) and saves us from retracing many sub-paths
228228 // many times, and rechecking many nodes.
229229 lint_level_roots_cache : GrowableBitSet < hir:: ItemLocalId > ,
230+
231+ coverage : Option < coverageinfo:: HirInfoBuilder > ,
230232}
231233
232234type CaptureMap < ' tcx > = SortedIndexMultiMap < usize , hir:: HirId , Capture < ' tcx > > ;
@@ -757,6 +759,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
757759 unit_temp : None ,
758760 var_debug_info : vec ! [ ] ,
759761 lint_level_roots_cache : GrowableBitSet :: new_empty ( ) ,
762+ coverage : coverageinfo:: HirInfoBuilder :: new_if_enabled_and_eligible ( tcx, def) ,
760763 } ;
761764
762765 assert_eq ! ( builder. cfg. start_new_block( ) , START_BLOCK ) ;
@@ -776,12 +779,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
776779 }
777780 }
778781
779- let coverage_hir_info = if self . tcx . sess . instrument_coverage ( ) {
780- coverageinfo:: make_coverage_hir_info_if_eligible ( self . tcx , self . def_id )
781- } else {
782- None
783- } ;
784-
785782 Body :: new (
786783 MirSource :: item ( self . def_id . to_def_id ( ) ) ,
787784 self . cfg . basic_blocks ,
@@ -793,7 +790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
793790 self . fn_span ,
794791 self . coroutine_kind ,
795792 None ,
796- coverage_hir_info ,
793+ self . coverage . map ( |coverage| coverage . finish ( self . tcx , self . def_id ) ) ,
797794 )
798795 }
799796
0 commit comments