@@ -4,7 +4,8 @@ use rustc_data_structures::captures::Captures;
44use rustc_data_structures:: fx:: FxIndexSet ;
55use rustc_index:: bit_set:: BitSet ;
66use rustc_middle:: mir:: coverage:: {
7- CodeRegion , CounterId , CovTerm , Expression , ExpressionId , FunctionCoverageInfo , Mapping , Op ,
7+ CodeRegion , CounterId , CovTerm , Expression , ExpressionId , FunctionCoverageInfo , Mapping ,
8+ MappingKind , Op ,
89} ;
910use rustc_middle:: ty:: Instance ;
1011use rustc_span:: Symbol ;
@@ -64,8 +65,8 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
6465 // For each expression ID that is directly used by one or more mappings,
6566 // mark it as not-yet-seen. This indicates that we expect to see a
6667 // 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 {
6970 expressions_seen. remove ( id) ;
7071 }
7172 }
@@ -221,20 +222,21 @@ impl<'tcx> FunctionCoverage<'tcx> {
221222 /// that will be used by `mapgen` when preparing for FFI.
222223 pub ( crate ) fn counter_regions (
223224 & self ,
224- ) -> impl Iterator < Item = ( Counter , & CodeRegion ) > + ExactSizeIterator {
225+ ) -> impl Iterator < Item = ( MappingKind , & CodeRegion ) > + ExactSizeIterator {
225226 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)
229231 } )
230232 }
231233
232234 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 )
238240 }
239241}
240242
0 commit comments