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