@@ -216,6 +216,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
216
216
217
217
target_blocks
218
218
} ;
219
+ let target_blocks = make_target_blocks ( self ) ;
219
220
220
221
let place = place_builder. to_place ( self ) ;
221
222
let place_ty = place. ty ( & self . local_decls , self . tcx ) ;
@@ -224,7 +225,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
224
225
let source_info = self . source_info ( test. span ) ;
225
226
match test. kind {
226
227
TestKind :: Switch { adt_def, ref variants } => {
227
- let target_blocks = make_target_blocks ( self ) ;
228
228
// Variants is a BitVec of indexes into adt_def.variants.
229
229
let num_enum_variants = adt_def. variants ( ) . len ( ) ;
230
230
debug_assert_eq ! ( target_blocks. len( ) , num_enum_variants + 1 ) ;
@@ -270,7 +270,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
270
270
}
271
271
272
272
TestKind :: SwitchInt { switch_ty, ref options } => {
273
- let target_blocks = make_target_blocks ( self ) ;
274
273
let terminator = if * switch_ty. kind ( ) == ty:: Bool {
275
274
assert ! ( !options. is_empty( ) && options. len( ) <= 2 ) ;
276
275
let [ first_bb, second_bb] = * target_blocks else {
@@ -340,7 +339,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
340
339
) ;
341
340
self . non_scalar_compare (
342
341
eq_block,
343
- make_target_blocks ,
342
+ target_blocks ,
344
343
source_info,
345
344
value,
346
345
ref_str,
@@ -351,15 +350,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
351
350
if !ty. is_scalar ( ) {
352
351
// Use `PartialEq::eq` instead of `BinOp::Eq`
353
352
// (the binop can only handle primitives)
354
- self . non_scalar_compare (
355
- block,
356
- make_target_blocks,
357
- source_info,
358
- value,
359
- place,
360
- ty,
361
- ) ;
362
- } else if let [ success, fail] = * make_target_blocks ( self ) {
353
+ self . non_scalar_compare ( block, target_blocks, source_info, value, place, ty) ;
354
+ } else if let [ success, fail] = * target_blocks {
363
355
assert_eq ! ( value. ty( ) , ty) ;
364
356
let expect = self . literal_operand ( test. span , value) ;
365
357
let val = Operand :: Copy ( place) ;
@@ -371,7 +363,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
371
363
372
364
TestKind :: Range ( ref range) => {
373
365
let lower_bound_success = self . cfg . start_new_block ( ) ;
374
- let target_blocks = make_target_blocks ( self ) ;
375
366
376
367
// Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
377
368
// FIXME: skip useless comparison when the range is half-open.
@@ -401,8 +392,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
401
392
}
402
393
403
394
TestKind :: Len { len, op } => {
404
- let target_blocks = make_target_blocks ( self ) ;
405
-
406
395
let usize_ty = self . tcx . types . usize ;
407
396
let actual = self . temp ( usize_ty, test. span ) ;
408
397
@@ -466,7 +455,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
466
455
fn non_scalar_compare (
467
456
& mut self ,
468
457
block : BasicBlock ,
469
- make_target_blocks : impl FnOnce ( & mut Self ) -> Vec < BasicBlock > ,
458
+ target_blocks : Vec < BasicBlock > ,
470
459
source_info : SourceInfo ,
471
460
value : Const < ' tcx > ,
472
461
mut val : Place < ' tcx > ,
@@ -591,7 +580,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
591
580
) ;
592
581
self . diverge_from ( block) ;
593
582
594
- let [ success_block, fail_block] = * make_target_blocks ( self ) else {
583
+ let [ success_block, fail_block] = * target_blocks else {
595
584
bug ! ( "`TestKind::Eq` should have two target blocks" )
596
585
} ;
597
586
// check the result
0 commit comments