@@ -95,12 +95,13 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
95
95
96
96
let coverage_counters = counters:: make_bcb_counters ( & graph, & bcbs_with_counter_mappings) ;
97
97
98
- let mappings = create_mappings ( & extracted_mappings, & coverage_counters ) ;
98
+ let mappings = create_mappings ( & extracted_mappings) ;
99
99
if mappings. is_empty ( ) {
100
100
// No spans could be converted into valid mappings, so skip this function.
101
101
debug ! ( "no spans could be converted into valid mappings; skipping" ) ;
102
102
return ;
103
103
}
104
+ let term_for_bcb = coverage_counters. node_counters . clone ( ) ;
104
105
105
106
inject_coverage_statements ( mir_body, & graph, & extracted_mappings, & coverage_counters) ;
106
107
@@ -116,26 +117,24 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
116
117
mir_body. function_coverage_info = Some ( Box :: new ( FunctionCoverageInfo {
117
118
function_source_hash : hir_info. function_source_hash ,
118
119
body_span : hir_info. body_span ,
120
+
119
121
num_counters : coverage_counters. num_counters ( ) ,
120
- mcdc_bitmap_bits : extracted_mappings. mcdc_bitmap_bits ,
121
122
expressions : coverage_counters. into_expressions ( ) ,
123
+
122
124
mappings,
125
+ term_for_bcb,
126
+
127
+ mcdc_bitmap_bits : extracted_mappings. mcdc_bitmap_bits ,
123
128
mcdc_num_condition_bitmaps,
124
129
} ) ) ;
125
130
}
126
131
127
- /// For each coverage span extracted from MIR, create a corresponding
128
- /// mapping.
132
+ /// For each coverage span extracted from MIR, create a corresponding mapping.
129
133
///
130
- /// Precondition: All BCBs corresponding to those spans have been given
131
- /// coverage counters.
132
- fn create_mappings (
133
- extracted_mappings : & ExtractedMappings ,
134
- coverage_counters : & CoverageCounters ,
135
- ) -> Vec < Mapping > {
136
- let term_for_bcb =
137
- |bcb| coverage_counters. term_for_bcb ( bcb) . expect ( "all BCBs with spans were given counters" ) ;
138
-
134
+ /// FIXME(Zalathar): This used to be where BCBs in the extracted mappings were
135
+ /// resolved to a `CovTerm`. But that is now handled elsewhere, so this
136
+ /// function can potentially be simplified even further.
137
+ fn create_mappings ( extracted_mappings : & ExtractedMappings ) -> Vec < Mapping > {
139
138
// Fully destructure the mappings struct to make sure we don't miss any kinds.
140
139
let ExtractedMappings {
141
140
num_bcbs : _,
@@ -150,23 +149,18 @@ fn create_mappings(
150
149
mappings. extend ( code_mappings. iter ( ) . map (
151
150
// Ordinary code mappings are the simplest kind.
152
151
|& mappings:: CodeMapping { span, bcb } | {
153
- let kind = MappingKind :: Code ( term_for_bcb ( bcb) ) ;
152
+ let kind = MappingKind :: Code { bcb } ;
154
153
Mapping { kind, span }
155
154
} ,
156
155
) ) ;
157
156
158
157
mappings. extend ( branch_pairs. iter ( ) . map (
159
158
|& mappings:: BranchPair { span, true_bcb, false_bcb } | {
160
- let true_term = term_for_bcb ( true_bcb) ;
161
- let false_term = term_for_bcb ( false_bcb) ;
162
- let kind = MappingKind :: Branch { true_term, false_term } ;
159
+ let kind = MappingKind :: Branch { true_bcb, false_bcb } ;
163
160
Mapping { kind, span }
164
161
} ,
165
162
) ) ;
166
163
167
- let term_for_bcb =
168
- |bcb| coverage_counters. term_for_bcb ( bcb) . expect ( "all BCBs with spans were given counters" ) ;
169
-
170
164
// MCDC branch mappings are appended with their decisions in case decisions were ignored.
171
165
mappings. extend ( mcdc_degraded_branches. iter ( ) . map (
172
166
|& mappings:: MCDCBranch {
@@ -176,11 +170,7 @@ fn create_mappings(
176
170
condition_info : _,
177
171
true_index : _,
178
172
false_index : _,
179
- } | {
180
- let true_term = term_for_bcb ( true_bcb) ;
181
- let false_term = term_for_bcb ( false_bcb) ;
182
- Mapping { kind : MappingKind :: Branch { true_term, false_term } , span }
183
- } ,
173
+ } | { Mapping { kind : MappingKind :: Branch { true_bcb, false_bcb } , span } } ,
184
174
) ) ;
185
175
186
176
for ( decision, branches) in mcdc_mappings {
@@ -201,12 +191,10 @@ fn create_mappings(
201
191
true_index : _,
202
192
false_index : _,
203
193
} | {
204
- let true_term = term_for_bcb ( true_bcb) ;
205
- let false_term = term_for_bcb ( false_bcb) ;
206
194
Mapping {
207
195
kind : MappingKind :: MCDCBranch {
208
- true_term ,
209
- false_term ,
196
+ true_bcb ,
197
+ false_bcb ,
210
198
mcdc_params : condition_info,
211
199
} ,
212
200
span,
0 commit comments