@@ -132,6 +132,7 @@ fn build_poll_switch<'tcx>(
132
132
body : & mut Body < ' tcx > ,
133
133
poll_enum : Ty < ' tcx > ,
134
134
poll_unit_place : & Place < ' tcx > ,
135
+ fut_pin_place : & Place < ' tcx > ,
135
136
ready_block : BasicBlock ,
136
137
yield_block : BasicBlock ,
137
138
) -> BasicBlock {
@@ -162,9 +163,11 @@ fn build_poll_switch<'tcx>(
162
163
Rvalue :: Discriminant ( * poll_unit_place) ,
163
164
) ) ) ,
164
165
} ;
166
+ let storage_dead =
167
+ Statement { source_info, kind : StatementKind :: StorageDead ( fut_pin_place. local ) } ;
165
168
let unreachable_block = insert_term_block ( body, TerminatorKind :: Unreachable ) ;
166
169
body. basic_blocks_mut ( ) . push ( BasicBlockData {
167
- statements : [ discr_assign] . to_vec ( ) ,
170
+ statements : [ storage_dead , discr_assign] . to_vec ( ) ,
168
171
terminator : Some ( Terminator {
169
172
source_info,
170
173
kind : TerminatorKind :: SwitchInt {
@@ -332,10 +335,17 @@ pub(super) fn expand_async_drops<'tcx>(
332
335
kind : StatementKind :: Assign ( Box :: new ( ( context_ref_place, arg) ) ) ,
333
336
} ) ;
334
337
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) ;
337
338
let ( pin_bb, fut_pin_place) =
338
339
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
+ ) ;
339
349
let call_bb = build_poll_call (
340
350
tcx,
341
351
body,
@@ -357,16 +367,17 @@ pub(super) fn expand_async_drops<'tcx>(
357
367
body. local_decls . push ( LocalDecl :: new ( context_mut_ref, source_info. span ) ) ,
358
368
) ;
359
369
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 ) ;
360
372
let drop_switch_block = build_poll_switch (
361
373
tcx,
362
374
body,
363
375
poll_enum,
364
376
& poll_unit_place,
377
+ & fut_pin_place2,
365
378
drop. unwrap ( ) ,
366
379
drop_yield_block,
367
380
) ;
368
- let ( pin_bb2, fut_pin_place2) =
369
- build_pin_fut ( tcx, body, fut_place, UnwindAction :: Continue ) ;
370
381
let drop_call_bb = build_poll_call (
371
382
tcx,
372
383
body,
0 commit comments