@@ -69,18 +69,6 @@ pub(crate) enum DeclareLetBindings {
69
69
LetNotPermitted ,
70
70
}
71
71
72
- /// Used by [`Builder::bind_matched_candidate_for_arm_body`] to determine
73
- /// whether or not to call [`Builder::storage_live_binding`] to emit
74
- /// [`StatementKind::StorageLive`].
75
- #[ derive( Clone , Copy ) ]
76
- pub ( crate ) enum EmitStorageLive {
77
- /// Yes, emit `StorageLive` as normal.
78
- Yes ,
79
- /// No, don't emit `StorageLive`. The caller has taken responsibility for
80
- /// emitting `StorageLive` as appropriate.
81
- No ,
82
- }
83
-
84
72
/// Used by [`Builder::storage_live_binding`] and [`Builder::bind_matched_candidate_for_arm_body`]
85
73
/// to decide whether to schedule drops.
86
74
#[ derive( Clone , Copy , Debug ) ]
@@ -207,7 +195,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
207
195
Some ( args. variable_source_info . scope ) ,
208
196
args. variable_source_info . span ,
209
197
args. declare_let_bindings ,
210
- EmitStorageLive :: Yes ,
211
198
) ,
212
199
_ => {
213
200
let mut block = block;
@@ -479,7 +466,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
479
466
& built_match_tree. fake_borrow_temps ,
480
467
scrutinee_span,
481
468
Some ( ( arm, match_scope) ) ,
482
- EmitStorageLive :: Yes ,
483
469
) ;
484
470
485
471
this. fixed_temps_scope = old_dedup_scope;
@@ -533,7 +519,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
533
519
fake_borrow_temps : & [ ( Place < ' tcx > , Local , FakeBorrowKind ) ] ,
534
520
scrutinee_span : Span ,
535
521
arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
536
- emit_storage_live : EmitStorageLive ,
537
522
) -> BasicBlock {
538
523
if branch. sub_branches . len ( ) == 1 {
539
524
let [ sub_branch] = branch. sub_branches . try_into ( ) . unwrap ( ) ;
@@ -544,7 +529,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
544
529
scrutinee_span,
545
530
arm_match_scope,
546
531
ScheduleDrops :: Yes ,
547
- emit_storage_live,
548
532
)
549
533
} else {
550
534
// It's helpful to avoid scheduling drops multiple times to save
@@ -577,7 +561,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
577
561
scrutinee_span,
578
562
arm_match_scope,
579
563
schedule_drops,
580
- emit_storage_live,
581
564
) ;
582
565
if arm. is_none ( ) {
583
566
schedule_drops = ScheduleDrops :: No ;
@@ -741,7 +724,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
741
724
& [ ] ,
742
725
irrefutable_pat. span ,
743
726
None ,
744
- EmitStorageLive :: Yes ,
745
727
)
746
728
. unit ( )
747
729
}
@@ -2364,7 +2346,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2364
2346
source_scope : Option < SourceScope > ,
2365
2347
scope_span : Span ,
2366
2348
declare_let_bindings : DeclareLetBindings ,
2367
- emit_storage_live : EmitStorageLive ,
2368
2349
) -> BlockAnd < ( ) > {
2369
2350
let expr_span = self . thir [ expr_id] . span ;
2370
2351
let scrutinee = unpack ! ( block = self . lower_scrutinee( block, expr_id, expr_span) ) ;
@@ -2398,14 +2379,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2398
2379
}
2399
2380
}
2400
2381
2401
- let success = self . bind_pattern (
2402
- self . source_info ( pat. span ) ,
2403
- branch,
2404
- & [ ] ,
2405
- expr_span,
2406
- None ,
2407
- emit_storage_live,
2408
- ) ;
2382
+ let success = self . bind_pattern ( self . source_info ( pat. span ) , branch, & [ ] , expr_span, None ) ;
2409
2383
2410
2384
// If branch coverage is enabled, record this branch.
2411
2385
self . visit_coverage_conditional_let ( pat, success, built_tree. otherwise_block ) ;
@@ -2428,7 +2402,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2428
2402
scrutinee_span : Span ,
2429
2403
arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
2430
2404
schedule_drops : ScheduleDrops ,
2431
- emit_storage_live : EmitStorageLive ,
2432
2405
) -> BasicBlock {
2433
2406
debug ! ( "bind_and_guard_matched_candidate(subbranch={:?})" , sub_branch) ;
2434
2407
@@ -2547,7 +2520,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2547
2520
post_guard_block,
2548
2521
ScheduleDrops :: Yes ,
2549
2522
by_value_bindings,
2550
- emit_storage_live,
2551
2523
) ;
2552
2524
2553
2525
post_guard_block
@@ -2559,7 +2531,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2559
2531
block,
2560
2532
schedule_drops,
2561
2533
sub_branch. bindings . iter ( ) ,
2562
- emit_storage_live,
2563
2534
) ;
2564
2535
block
2565
2536
}
@@ -2730,7 +2701,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2730
2701
block : BasicBlock ,
2731
2702
schedule_drops : ScheduleDrops ,
2732
2703
bindings : impl IntoIterator < Item = & ' b Binding < ' tcx > > ,
2733
- emit_storage_live : EmitStorageLive ,
2734
2704
) where
2735
2705
' tcx : ' b ,
2736
2706
{
@@ -2740,19 +2710,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2740
2710
// Assign each of the bindings. This may trigger moves out of the candidate.
2741
2711
for binding in bindings {
2742
2712
let source_info = self . source_info ( binding. span ) ;
2743
- let local = match emit_storage_live {
2744
- // Here storages are already alive, probably because this is a binding
2745
- // from let-else.
2746
- // We just need to schedule drop for the value.
2747
- EmitStorageLive :: No => self . var_local_id ( binding. var_id , OutsideGuard ) . into ( ) ,
2748
- EmitStorageLive :: Yes => self . storage_live_binding (
2749
- block,
2750
- binding. var_id ,
2751
- binding. span ,
2752
- OutsideGuard ,
2753
- schedule_drops,
2754
- ) ,
2755
- } ;
2713
+ let local = self . storage_live_binding (
2714
+ block,
2715
+ binding. var_id ,
2716
+ binding. span ,
2717
+ OutsideGuard ,
2718
+ schedule_drops,
2719
+ ) ;
2756
2720
if matches ! ( schedule_drops, ScheduleDrops :: Yes ) {
2757
2721
self . schedule_drop_for_binding ( binding. var_id , binding. span , OutsideGuard ) ;
2758
2722
}
0 commit comments