@@ -4,7 +4,8 @@ use rustc_data_structures::captures::Captures;
4
4
use rustc_data_structures:: fx:: FxIndexSet ;
5
5
use rustc_index:: bit_set:: BitSet ;
6
6
use rustc_middle:: mir:: coverage:: {
7
- CodeRegion , CounterId , CovTerm , Expression , ExpressionId , FunctionCoverageInfo , Mapping , Op ,
7
+ CodeRegion , CounterId , CovTerm , Expression , ExpressionId , FunctionCoverageInfo , Mapping ,
8
+ MappingKind , Op ,
8
9
} ;
9
10
use rustc_middle:: ty:: Instance ;
10
11
use rustc_span:: Symbol ;
@@ -64,8 +65,8 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
64
65
// For each expression ID that is directly used by one or more mappings,
65
66
// mark it as not-yet-seen. This indicates that we expect to see a
66
67
// corresponding `ExpressionUsed` statement during MIR traversal.
67
- for Mapping { term, .. } in & function_coverage_info. mappings {
68
- if let & CovTerm :: Expression ( id) = term {
68
+ for term in function_coverage_info. mappings . iter ( ) . flat_map ( |m| m . kind . terms ( ) ) {
69
+ if let CovTerm :: Expression ( id) = term {
69
70
expressions_seen. remove ( id) ;
70
71
}
71
72
}
@@ -221,20 +222,21 @@ impl<'tcx> FunctionCoverage<'tcx> {
221
222
/// that will be used by `mapgen` when preparing for FFI.
222
223
pub ( crate ) fn counter_regions (
223
224
& self ,
224
- ) -> impl Iterator < Item = ( Counter , & CodeRegion ) > + ExactSizeIterator {
225
+ ) -> impl Iterator < Item = ( MappingKind , & CodeRegion ) > + ExactSizeIterator {
225
226
self . function_coverage_info . mappings . iter ( ) . map ( move |mapping| {
226
- let & Mapping { term, ref code_region } = mapping;
227
- let counter = self . counter_for_term ( term) ;
228
- ( counter, code_region)
227
+ let Mapping { kind, code_region } = mapping;
228
+ let kind =
229
+ kind. map_terms ( |term| if self . is_zero_term ( term) { CovTerm :: Zero } else { term } ) ;
230
+ ( kind, code_region)
229
231
} )
230
232
}
231
233
232
234
fn counter_for_term ( & self , term : CovTerm ) -> Counter {
233
- if is_zero_term ( & self . counters_seen , & self . zero_expressions , term) {
234
- Counter :: ZERO
235
- } else {
236
- Counter :: from_term ( term )
237
- }
235
+ if self . is_zero_term ( term ) { Counter :: ZERO } else { Counter :: from_term ( term) }
236
+ }
237
+
238
+ fn is_zero_term ( & self , term : CovTerm ) -> bool {
239
+ is_zero_term ( & self . counters_seen , & self . zero_expressions , term )
238
240
}
239
241
}
240
242
0 commit comments