@@ -106,6 +106,16 @@ fn fill_region_tables<'tcx>(
106
106
ids_info : & ' tcx CoverageIdsInfo ,
107
107
covfun : & mut CovfunRecord < ' tcx > ,
108
108
) {
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
+
109
119
// Currently a function's mappings must all be in the same file, so use the
110
120
// first mapping's span to determine the file.
111
121
let source_map = tcx. sess . source_map ( ) ;
@@ -137,16 +147,6 @@ fn fill_region_tables<'tcx>(
137
147
// For each counter/region pair in this function+file, convert it to a
138
148
// form suitable for FFI.
139
149
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
-
150
150
let Some ( coords) = make_coords ( span) else { continue } ;
151
151
let cov_span = coords. make_coverage_span ( local_file_id) ;
152
152
0 commit comments