@@ -132,6 +132,7 @@ fn build_poll_switch<'tcx>(
132132 body : & mut Body < ' tcx > ,
133133 poll_enum : Ty < ' tcx > ,
134134 poll_unit_place : & Place < ' tcx > ,
135+ fut_pin_place : & Place < ' tcx > ,
135136 ready_block : BasicBlock ,
136137 yield_block : BasicBlock ,
137138) -> BasicBlock {
@@ -162,9 +163,11 @@ fn build_poll_switch<'tcx>(
162163 Rvalue :: Discriminant ( * poll_unit_place) ,
163164 ) ) ) ,
164165 } ;
166+ let storage_dead =
167+ Statement { source_info, kind : StatementKind :: StorageDead ( fut_pin_place. local ) } ;
165168 let unreachable_block = insert_term_block ( body, TerminatorKind :: Unreachable ) ;
166169 body. basic_blocks_mut ( ) . push ( BasicBlockData {
167- statements : [ discr_assign] . to_vec ( ) ,
170+ statements : [ storage_dead , discr_assign] . to_vec ( ) ,
168171 terminator : Some ( Terminator {
169172 source_info,
170173 kind : TerminatorKind :: SwitchInt {
@@ -332,10 +335,17 @@ pub(super) fn expand_async_drops<'tcx>(
332335 kind : StatementKind :: Assign ( Box :: new ( ( context_ref_place, arg) ) ) ,
333336 } ) ;
334337 let yield_block = insert_term_block ( body, TerminatorKind :: Unreachable ) ; // `kind` replaced later to yield
335- let switch_block =
336- build_poll_switch ( tcx, body, poll_enum, & poll_unit_place, target, yield_block) ;
337338 let ( pin_bb, fut_pin_place) =
338339 build_pin_fut ( tcx, body, fut_place. clone ( ) , UnwindAction :: Continue ) ;
340+ let switch_block = build_poll_switch (
341+ tcx,
342+ body,
343+ poll_enum,
344+ & poll_unit_place,
345+ & fut_pin_place,
346+ target,
347+ yield_block,
348+ ) ;
339349 let call_bb = build_poll_call (
340350 tcx,
341351 body,
@@ -357,16 +367,17 @@ pub(super) fn expand_async_drops<'tcx>(
357367 body. local_decls . push ( LocalDecl :: new ( context_mut_ref, source_info. span ) ) ,
358368 ) ;
359369 let drop_yield_block = insert_term_block ( body, TerminatorKind :: Unreachable ) ; // `kind` replaced later to yield
370+ let ( pin_bb2, fut_pin_place2) =
371+ build_pin_fut ( tcx, body, fut_place, UnwindAction :: Continue ) ;
360372 let drop_switch_block = build_poll_switch (
361373 tcx,
362374 body,
363375 poll_enum,
364376 & poll_unit_place,
377+ & fut_pin_place2,
365378 drop. unwrap ( ) ,
366379 drop_yield_block,
367380 ) ;
368- let ( pin_bb2, fut_pin_place2) =
369- build_pin_fut ( tcx, body, fut_place, UnwindAction :: Continue ) ;
370381 let drop_call_bb = build_poll_call (
371382 tcx,
372383 body,
0 commit comments