@@ -879,56 +879,19 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
879
879
let tcx = self . tcx ( ) ;
880
880
let unit_temp = Place :: Local ( self . new_temp ( tcx. mk_nil ( ) ) ) ;
881
881
let free_func = tcx. require_lang_item ( lang_items:: BoxFreeFnLangItem ) ;
882
- let free_sig = tcx. fn_sig ( free_func) . skip_binder ( ) . clone ( ) ;
883
- let free_inputs = free_sig. inputs ( ) ;
884
- // If the box_free function takes a *mut T, transform the Box into
885
- // such a pointer before calling box_free. Otherwise, pass it all
886
- // the fields in the Box as individual arguments.
887
- let ( stmts, args) = if free_inputs. len ( ) == 1 && free_inputs[ 0 ] . is_mutable_pointer ( ) {
888
- let ty = substs. type_at ( 0 ) ;
889
- let ref_ty = tcx. mk_ref ( tcx. types . re_erased , ty:: TypeAndMut {
890
- ty : ty,
891
- mutbl : hir:: Mutability :: MutMutable
892
- } ) ;
893
- let ptr_ty = tcx. mk_mut_ptr ( ty) ;
894
- let ref_tmp = Place :: Local ( self . new_temp ( ref_ty) ) ;
895
- let ptr_tmp = Place :: Local ( self . new_temp ( ptr_ty) ) ;
896
- let stmts = vec ! [
897
- self . assign( & ref_tmp, Rvalue :: Ref (
898
- tcx. types. re_erased,
899
- BorrowKind :: Mut { allow_two_phase_borrow: false } ,
900
- self . place. clone( ) . deref( )
901
- ) ) ,
902
- self . assign( & ptr_tmp, Rvalue :: Cast (
903
- CastKind :: Misc ,
904
- Operand :: Move ( ref_tmp) ,
905
- ptr_ty,
906
- ) ) ,
907
- ] ;
908
- ( stmts, vec ! [ Operand :: Move ( ptr_tmp) ] )
909
- } else {
910
- let args = adt. variants [ 0 ] . fields . iter ( ) . enumerate ( ) . map ( |( i, f) | {
911
- let field = Field :: new ( i) ;
912
- let field_ty = f. ty ( self . tcx ( ) , substs) ;
913
- Operand :: Move ( self . place . clone ( ) . field ( field, field_ty) )
914
- } ) . collect ( ) ;
915
- ( vec ! [ ] , args)
916
- } ;
882
+ let args = adt. variants [ 0 ] . fields . iter ( ) . enumerate ( ) . map ( |( i, f) | {
883
+ let field = Field :: new ( i) ;
884
+ let field_ty = f. ty ( self . tcx ( ) , substs) ;
885
+ Operand :: Move ( self . place . clone ( ) . field ( field, field_ty) )
886
+ } ) . collect ( ) ;
917
887
918
- let free_block = BasicBlockData {
919
- statements : stmts,
920
- terminator : Some ( Terminator {
921
- kind : TerminatorKind :: Call {
922
- func : Operand :: function_handle ( tcx, free_func, substs, self . source_info . span ) ,
923
- args : args,
924
- destination : Some ( ( unit_temp, target) ) ,
925
- cleanup : None
926
- } , // FIXME(#43234)
927
- source_info : self . source_info ,
928
- } ) ,
929
- is_cleanup : unwind. is_cleanup ( )
930
- } ;
931
- let free_block = self . elaborator . patch ( ) . new_block ( free_block) ;
888
+ let call = TerminatorKind :: Call {
889
+ func : Operand :: function_handle ( tcx, free_func, substs, self . source_info . span ) ,
890
+ args : args,
891
+ destination : Some ( ( unit_temp, target) ) ,
892
+ cleanup : None
893
+ } ; // FIXME(#43234)
894
+ let free_block = self . new_block ( unwind, call) ;
932
895
933
896
let block_start = Location { block : free_block, statement_index : 0 } ;
934
897
self . elaborator . clear_drop_flag ( block_start, self . path , DropFlagMode :: Shallow ) ;
0 commit comments