@@ -180,7 +180,12 @@ fn create_mappings(
180
180
) ) ;
181
181
182
182
for ( decision, branches) in mcdc_mappings {
183
- let num_conditions = branches. len ( ) as u16 ;
183
+ // FIXME(#134497): Previously it was possible for some of these branch
184
+ // conversions to fail, in which case the remaining branches in the
185
+ // decision would be degraded to plain `MappingKind::Branch`.
186
+ // The changes in #134497 made that failure impossible, because the
187
+ // fallible step was deferred to codegen. But the corresponding code
188
+ // in codegen wasn't updated to detect the need for a degrade step.
184
189
let conditions = branches
185
190
. into_iter ( )
186
191
. map (
@@ -206,24 +211,13 @@ fn create_mappings(
206
211
)
207
212
. collect :: < Vec < _ > > ( ) ;
208
213
209
- if conditions. len ( ) == num_conditions as usize {
210
- // LLVM requires end index for counter mapping regions.
211
- let kind = MappingKind :: MCDCDecision ( DecisionInfo {
212
- bitmap_idx : ( decision. bitmap_idx + decision. num_test_vectors ) as u32 ,
213
- num_conditions,
214
- } ) ;
215
- let span = decision. span ;
216
- mappings. extend ( std:: iter:: once ( Mapping { kind, span } ) . chain ( conditions. into_iter ( ) ) ) ;
217
- } else {
218
- mappings. extend ( conditions. into_iter ( ) . map ( |mapping| {
219
- let MappingKind :: MCDCBranch { true_term, false_term, mcdc_params : _ } =
220
- mapping. kind
221
- else {
222
- unreachable ! ( "all mappings here are MCDCBranch as shown above" ) ;
223
- } ;
224
- Mapping { kind : MappingKind :: Branch { true_term, false_term } , span : mapping. span }
225
- } ) )
226
- }
214
+ // LLVM requires end index for counter mapping regions.
215
+ let kind = MappingKind :: MCDCDecision ( DecisionInfo {
216
+ bitmap_idx : ( decision. bitmap_idx + decision. num_test_vectors ) as u32 ,
217
+ num_conditions : u16:: try_from ( conditions. len ( ) ) . unwrap ( ) ,
218
+ } ) ;
219
+ let span = decision. span ;
220
+ mappings. extend ( std:: iter:: once ( Mapping { kind, span } ) . chain ( conditions. into_iter ( ) ) ) ;
227
221
}
228
222
229
223
mappings
0 commit comments