@@ -69,18 +69,6 @@ pub(crate) enum DeclareLetBindings {
6969 LetNotPermitted ,
7070}
7171
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-
8472/// Used by [`Builder::storage_live_binding`] and [`Builder::bind_matched_candidate_for_arm_body`]
8573/// to decide whether to schedule drops.
8674#[ derive( Clone , Copy , Debug ) ]
@@ -207,7 +195,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
207195 Some ( args. variable_source_info . scope ) ,
208196 args. variable_source_info . span ,
209197 args. declare_let_bindings ,
210- EmitStorageLive :: Yes ,
211198 ) ,
212199 _ => {
213200 let mut block = block;
@@ -479,7 +466,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
479466 & built_match_tree. fake_borrow_temps ,
480467 scrutinee_span,
481468 Some ( ( arm, match_scope) ) ,
482- EmitStorageLive :: Yes ,
483469 ) ;
484470
485471 this. fixed_temps_scope = old_dedup_scope;
@@ -533,7 +519,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
533519 fake_borrow_temps : & [ ( Place < ' tcx > , Local , FakeBorrowKind ) ] ,
534520 scrutinee_span : Span ,
535521 arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
536- emit_storage_live : EmitStorageLive ,
537522 ) -> BasicBlock {
538523 if branch. sub_branches . len ( ) == 1 {
539524 let [ sub_branch] = branch. sub_branches . try_into ( ) . unwrap ( ) ;
@@ -544,7 +529,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
544529 scrutinee_span,
545530 arm_match_scope,
546531 ScheduleDrops :: Yes ,
547- emit_storage_live,
548532 )
549533 } else {
550534 // It's helpful to avoid scheduling drops multiple times to save
@@ -577,7 +561,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
577561 scrutinee_span,
578562 arm_match_scope,
579563 schedule_drops,
580- emit_storage_live,
581564 ) ;
582565 if arm. is_none ( ) {
583566 schedule_drops = ScheduleDrops :: No ;
@@ -741,7 +724,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
741724 & [ ] ,
742725 irrefutable_pat. span ,
743726 None ,
744- EmitStorageLive :: Yes ,
745727 )
746728 . unit ( )
747729 }
@@ -2364,7 +2346,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
23642346 source_scope : Option < SourceScope > ,
23652347 scope_span : Span ,
23662348 declare_let_bindings : DeclareLetBindings ,
2367- emit_storage_live : EmitStorageLive ,
23682349 ) -> BlockAnd < ( ) > {
23692350 let expr_span = self . thir [ expr_id] . span ;
23702351 let scrutinee = unpack ! ( block = self . lower_scrutinee( block, expr_id, expr_span) ) ;
@@ -2398,14 +2379,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
23982379 }
23992380 }
24002381
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 ) ;
24092383
24102384 // If branch coverage is enabled, record this branch.
24112385 self . visit_coverage_conditional_let ( pat, success, built_tree. otherwise_block ) ;
@@ -2428,7 +2402,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
24282402 scrutinee_span : Span ,
24292403 arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
24302404 schedule_drops : ScheduleDrops ,
2431- emit_storage_live : EmitStorageLive ,
24322405 ) -> BasicBlock {
24332406 debug ! ( "bind_and_guard_matched_candidate(subbranch={:?})" , sub_branch) ;
24342407
@@ -2547,7 +2520,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
25472520 post_guard_block,
25482521 ScheduleDrops :: Yes ,
25492522 by_value_bindings,
2550- emit_storage_live,
25512523 ) ;
25522524
25532525 post_guard_block
@@ -2559,7 +2531,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
25592531 block,
25602532 schedule_drops,
25612533 sub_branch. bindings . iter ( ) ,
2562- emit_storage_live,
25632534 ) ;
25642535 block
25652536 }
@@ -2730,7 +2701,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
27302701 block : BasicBlock ,
27312702 schedule_drops : ScheduleDrops ,
27322703 bindings : impl IntoIterator < Item = & ' b Binding < ' tcx > > ,
2733- emit_storage_live : EmitStorageLive ,
27342704 ) where
27352705 ' tcx : ' b ,
27362706 {
@@ -2740,19 +2710,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
27402710 // Assign each of the bindings. This may trigger moves out of the candidate.
27412711 for binding in bindings {
27422712 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+ ) ;
27562720 if matches ! ( schedule_drops, ScheduleDrops :: Yes ) {
27572721 self . schedule_drop_for_binding ( binding. var_id , binding. span , OutsideGuard ) ;
27582722 }
0 commit comments