@@ -64,17 +64,22 @@ impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
6464        function_source_hash :  u64 , 
6565        id :  CounterValueReference , 
6666        region :  CodeRegion , 
67-     )  { 
68-         debug ! ( 
69-             "adding counter to coverage_regions: instance={:?}, function_source_hash={}, id={:?}, \  
70-               at {:?}", 
71-             instance,  function_source_hash,  id,  region, 
72-         ) ; 
73-         let  mut  coverage_regions = self . coverage_context ( ) . function_coverage_map . borrow_mut ( ) ; 
74-         coverage_regions
75-             . entry ( instance) 
76-             . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
77-             . add_counter ( function_source_hash,  id,  region) ; 
67+     )  -> bool  { 
68+         if  let  Some ( coverage_context)  = self . coverage_context ( )  { 
69+             debug ! ( 
70+                 "adding counter to coverage_regions: instance={:?}, function_source_hash={}, id={:?}, \  
71+                  at {:?}", 
72+                 instance,  function_source_hash,  id,  region, 
73+             ) ; 
74+             let  mut  coverage_regions = coverage_context. function_coverage_map . borrow_mut ( ) ; 
75+             coverage_regions
76+                 . entry ( instance) 
77+                 . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
78+                 . add_counter ( function_source_hash,  id,  region) ; 
79+             true 
80+         }  else  { 
81+             false 
82+         } 
7883    } 
7984
8085    fn  add_counter_expression_region ( 
@@ -85,29 +90,39 @@ impl CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
8590        op :  Op , 
8691        rhs :  ExpressionOperandId , 
8792        region :  CodeRegion , 
88-     )  { 
89-         debug ! ( 
90-             "adding counter expression to coverage_regions: instance={:?}, id={:?}, {:?} {:?} {:?}, \  
91-               at {:?}", 
92-             instance,  id,  lhs,  op,  rhs,  region, 
93-         ) ; 
94-         let  mut  coverage_regions = self . coverage_context ( ) . function_coverage_map . borrow_mut ( ) ; 
95-         coverage_regions
96-             . entry ( instance) 
97-             . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
98-             . add_counter_expression ( id,  lhs,  op,  rhs,  region) ; 
93+     )  -> bool  { 
94+         if  let  Some ( coverage_context)  = self . coverage_context ( )  { 
95+             debug ! ( 
96+                 "adding counter expression to coverage_regions: instance={:?}, id={:?}, {:?} {:?} {:?}, \  
97+                  at {:?}", 
98+                 instance,  id,  lhs,  op,  rhs,  region, 
99+             ) ; 
100+             let  mut  coverage_regions = coverage_context. function_coverage_map . borrow_mut ( ) ; 
101+             coverage_regions
102+                 . entry ( instance) 
103+                 . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
104+                 . add_counter_expression ( id,  lhs,  op,  rhs,  region) ; 
105+             true 
106+         }  else  { 
107+             false 
108+         } 
99109    } 
100110
101-     fn  add_unreachable_region ( & mut  self ,  instance :  Instance < ' tcx > ,  region :  CodeRegion )  { 
102-         debug ! ( 
103-             "adding unreachable code to coverage_regions: instance={:?}, at {:?}" , 
104-             instance,  region, 
105-         ) ; 
106-         let  mut  coverage_regions = self . coverage_context ( ) . function_coverage_map . borrow_mut ( ) ; 
107-         coverage_regions
108-             . entry ( instance) 
109-             . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
110-             . add_unreachable_region ( region) ; 
111+     fn  add_unreachable_region ( & mut  self ,  instance :  Instance < ' tcx > ,  region :  CodeRegion )  -> bool  { 
112+         if  let  Some ( coverage_context)  = self . coverage_context ( )  { 
113+             debug ! ( 
114+                 "adding unreachable code to coverage_regions: instance={:?}, at {:?}" , 
115+                 instance,  region, 
116+             ) ; 
117+             let  mut  coverage_regions = coverage_context. function_coverage_map . borrow_mut ( ) ; 
118+             coverage_regions
119+                 . entry ( instance) 
120+                 . or_insert_with ( || FunctionCoverage :: new ( self . tcx ,  instance) ) 
121+                 . add_unreachable_region ( region) ; 
122+             true 
123+         }  else  { 
124+             false 
125+         } 
111126    } 
112127} 
113128
0 commit comments