@@ -106,6 +106,16 @@ fn fill_region_tables<'tcx>(
106106 ids_info : & ' tcx CoverageIdsInfo ,
107107 covfun : & mut CovfunRecord < ' tcx > ,
108108) {
109+ // If this function is unused, replace all counters with zero.
110+ let counter_for_bcb = |bcb : BasicCoverageBlock | -> ffi:: Counter {
111+ let term = if covfun. is_used {
112+ ids_info. term_for_bcb [ bcb] . expect ( "every BCB in a mapping was given a term" )
113+ } else {
114+ CovTerm :: Zero
115+ } ;
116+ ffi:: Counter :: from_term ( term)
117+ } ;
118+
109119 // Currently a function's mappings must all be in the same file, so use the
110120 // first mapping's span to determine the file.
111121 let source_map = tcx. sess . source_map ( ) ;
@@ -137,16 +147,6 @@ fn fill_region_tables<'tcx>(
137147 // For each counter/region pair in this function+file, convert it to a
138148 // form suitable for FFI.
139149 for & Mapping { ref kind, span } in & fn_cov_info. mappings {
140- // If this function is unused, replace all counters with zero.
141- let counter_for_bcb = |bcb : BasicCoverageBlock | -> ffi:: Counter {
142- let term = if covfun. is_used {
143- ids_info. term_for_bcb [ bcb] . expect ( "every BCB in a mapping was given a term" )
144- } else {
145- CovTerm :: Zero
146- } ;
147- ffi:: Counter :: from_term ( term)
148- } ;
149-
150150 let Some ( coords) = make_coords ( span) else { continue } ;
151151 let cov_span = coords. make_coverage_span ( local_file_id) ;
152152
0 commit comments