@@ -163,18 +163,14 @@ where
163
163
} ) ;
164
164
}
165
165
DropStyle :: Static => {
166
- let loc = self . terminator_loc ( bb) ;
167
- self . elaborator . clear_drop_flag ( loc, self . path , DropFlagMode :: Deep ) ;
168
166
self . elaborator . patch ( ) . patch_terminator ( bb, TerminatorKind :: Drop {
169
167
location : self . place . clone ( ) ,
170
168
target : self . succ ,
171
169
unwind : self . unwind . into_option ( ) ,
172
170
} ) ;
173
171
}
174
172
DropStyle :: Conditional => {
175
- let unwind = self . unwind ; // FIXME(#43234)
176
- let succ = self . succ ;
177
- let drop_bb = self . complete_drop ( Some ( DropFlagMode :: Deep ) , succ, unwind) ;
173
+ let drop_bb = self . complete_drop ( self . succ , self . unwind ) ;
178
174
self . elaborator . patch ( ) . patch_terminator ( bb, TerminatorKind :: Goto {
179
175
target : drop_bb
180
176
} ) ;
@@ -236,7 +232,7 @@ where
236
232
// Using `self.path` here to condition the drop on
237
233
// our own drop flag.
238
234
path : self . path
239
- } . complete_drop ( None , succ, unwind)
235
+ } . complete_drop ( succ, unwind)
240
236
}
241
237
}
242
238
@@ -265,13 +261,7 @@ where
265
261
// Clear the "master" drop flag at the end. This is needed
266
262
// because the "master" drop protects the ADT's discriminant,
267
263
// which is invalidated after the ADT is dropped.
268
- let ( succ, unwind) = ( self . succ , self . unwind ) ; // FIXME(#43234)
269
- (
270
- self . drop_flag_reset_block ( DropFlagMode :: Shallow , succ, unwind) ,
271
- unwind. map ( |unwind| {
272
- self . drop_flag_reset_block ( DropFlagMode :: Shallow , unwind, Unwind :: InCleanup )
273
- } )
274
- )
264
+ ( self . drop_flag_reset_block ( DropFlagMode :: Shallow , self . succ , self . unwind ) , self . unwind )
275
265
}
276
266
277
267
/// Creates a full drop ladder, consisting of 2 connected half-drop-ladders
@@ -827,9 +817,7 @@ where
827
817
}
828
818
}
829
819
ty:: Dynamic ( ..) => {
830
- let unwind = self . unwind ; // FIXME(#43234)
831
- let succ = self . succ ;
832
- self . complete_drop ( Some ( DropFlagMode :: Deep ) , succ, unwind)
820
+ self . complete_drop ( self . succ , self . unwind )
833
821
}
834
822
ty:: Array ( ety, size) => {
835
823
let size = size. try_eval_usize ( self . tcx ( ) , self . elaborator . param_env ( ) ) ;
@@ -850,18 +838,12 @@ where
850
838
/// drop(self.place)
851
839
fn complete_drop (
852
840
& mut self ,
853
- drop_mode : Option < DropFlagMode > ,
854
841
succ : BasicBlock ,
855
842
unwind : Unwind ,
856
843
) -> BasicBlock {
857
- debug ! ( "complete_drop({:?},{:?})" , self , drop_mode ) ;
844
+ debug ! ( "complete_drop(succ= {:?}, unwind= {:?})" , succ , unwind ) ;
858
845
859
846
let drop_block = self . drop_block ( succ, unwind) ;
860
- let drop_block = if let Some ( mode) = drop_mode {
861
- self . drop_flag_reset_block ( mode, drop_block, unwind)
862
- } else {
863
- drop_block
864
- } ;
865
847
866
848
self . drop_flag_test_block ( drop_block, succ, unwind)
867
849
}
@@ -873,6 +855,11 @@ where
873
855
{
874
856
debug ! ( "drop_flag_reset_block({:?},{:?})" , self , mode) ;
875
857
858
+ if unwind. is_cleanup ( ) {
859
+ // The drop flag isn't read again on the unwind path, so don't
860
+ // bother setting it.
861
+ return succ;
862
+ }
876
863
let block = self . new_block ( unwind, TerminatorKind :: Goto { target : succ } ) ;
877
864
let block_start = Location { block : block, statement_index : 0 } ;
878
865
self . elaborator . clear_drop_flag ( block_start, self . path , mode) ;
@@ -976,11 +963,6 @@ where
976
963
self . elaborator . patch ( ) . new_temp ( ty, self . source_info . span )
977
964
}
978
965
979
- fn terminator_loc ( & mut self , bb : BasicBlock ) -> Location {
980
- let body = self . elaborator . body ( ) ;
981
- self . elaborator . patch ( ) . terminator_loc ( body, bb)
982
- }
983
-
984
966
fn constant_usize ( & self , val : u16 ) -> Operand < ' tcx > {
985
967
Operand :: Constant ( box Constant {
986
968
span : self . source_info . span ,
0 commit comments