@@ -233,6 +233,8 @@ where
233
233
. patch_terminator ( bb, TerminatorKind :: Goto { target : self . succ } ) ;
234
234
}
235
235
DropStyle :: Static => {
236
+ let loc = self . terminator_loc ( bb) ;
237
+ self . elaborator . clear_drop_flag ( loc, self . path , DropFlagMode :: Deep ) ;
236
238
self . elaborator . patch ( ) . patch_terminator (
237
239
bb,
238
240
TerminatorKind :: Drop {
@@ -243,7 +245,9 @@ where
243
245
) ;
244
246
}
245
247
DropStyle :: Conditional => {
246
- let drop_bb = self . complete_drop ( self . succ , self . unwind ) ;
248
+ let unwind = self . unwind ; // FIXME(#43234)
249
+ let succ = self . succ ;
250
+ let drop_bb = self . complete_drop ( Some ( DropFlagMode :: Deep ) , succ, unwind) ;
247
251
self . elaborator
248
252
. patch ( )
249
253
. patch_terminator ( bb, TerminatorKind :: Goto { target : drop_bb } ) ;
@@ -315,7 +319,7 @@ where
315
319
// our own drop flag.
316
320
path : self . path ,
317
321
}
318
- . complete_drop ( succ, unwind)
322
+ . complete_drop ( None , succ, unwind)
319
323
}
320
324
}
321
325
@@ -344,7 +348,13 @@ where
344
348
// Clear the "master" drop flag at the end. This is needed
345
349
// because the "master" drop protects the ADT's discriminant,
346
350
// which is invalidated after the ADT is dropped.
347
- ( self . drop_flag_reset_block ( DropFlagMode :: Shallow , self . succ , self . unwind ) , self . unwind )
351
+ let ( succ, unwind) = ( self . succ , self . unwind ) ; // FIXME(#43234)
352
+ (
353
+ self . drop_flag_reset_block ( DropFlagMode :: Shallow , succ, unwind) ,
354
+ unwind. map ( |unwind| {
355
+ self . drop_flag_reset_block ( DropFlagMode :: Shallow , unwind, Unwind :: InCleanup )
356
+ } ) ,
357
+ )
348
358
}
349
359
350
360
/// Creates a full drop ladder, consisting of 2 connected half-drop-ladders
@@ -878,7 +888,11 @@ where
878
888
self . open_drop_for_adt ( def, substs)
879
889
}
880
890
}
881
- ty:: Dynamic ( ..) => self . complete_drop ( self . succ , self . unwind ) ,
891
+ ty:: Dynamic ( ..) => {
892
+ let unwind = self . unwind ; // FIXME(#43234)
893
+ let succ = self . succ ;
894
+ self . complete_drop ( Some ( DropFlagMode :: Deep ) , succ, unwind)
895
+ }
882
896
ty:: Array ( ety, size) => {
883
897
let size = size. try_eval_usize ( self . tcx ( ) , self . elaborator . param_env ( ) ) ;
884
898
self . open_drop_for_array ( ety, size)
@@ -889,10 +903,20 @@ where
889
903
}
890
904
}
891
905
892
- fn complete_drop ( & mut self , succ : BasicBlock , unwind : Unwind ) -> BasicBlock {
893
- debug ! ( "complete_drop(succ={:?}, unwind={:?})" , succ, unwind) ;
906
+ fn complete_drop (
907
+ & mut self ,
908
+ drop_mode : Option < DropFlagMode > ,
909
+ succ : BasicBlock ,
910
+ unwind : Unwind ,
911
+ ) -> BasicBlock {
912
+ debug ! ( "complete_drop({:?},{:?})" , self , drop_mode) ;
894
913
895
914
let drop_block = self . drop_block ( succ, unwind) ;
915
+ let drop_block = if let Some ( mode) = drop_mode {
916
+ self . drop_flag_reset_block ( mode, drop_block, unwind)
917
+ } else {
918
+ drop_block
919
+ } ;
896
920
897
921
self . drop_flag_test_block ( drop_block, succ, unwind)
898
922
}
@@ -907,11 +931,6 @@ where
907
931
) -> BasicBlock {
908
932
debug ! ( "drop_flag_reset_block({:?},{:?})" , self , mode) ;
909
933
910
- if unwind. is_cleanup ( ) {
911
- // The drop flag isn't read again on the unwind path, so don't
912
- // bother setting it.
913
- return succ;
914
- }
915
934
let block = self . new_block ( unwind, TerminatorKind :: Goto { target : succ } ) ;
916
935
let block_start = Location { block, statement_index : 0 } ;
917
936
self . elaborator . clear_drop_flag ( block_start, self . path , mode) ;
@@ -1028,6 +1047,11 @@ where
1028
1047
self . elaborator . patch ( ) . new_temp ( ty, self . source_info . span )
1029
1048
}
1030
1049
1050
+ fn terminator_loc ( & mut self , bb : BasicBlock ) -> Location {
1051
+ let body = self . elaborator . body ( ) ;
1052
+ self . elaborator . patch ( ) . terminator_loc ( body, bb)
1053
+ }
1054
+
1031
1055
fn constant_usize ( & self , val : u16 ) -> Operand < ' tcx > {
1032
1056
Operand :: Constant ( box Constant {
1033
1057
span : self . source_info . span ,
0 commit comments