@@ -679,7 +679,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>(
679
679
}
680
680
}
681
681
682
- pub fn codegen_call_inner < ' a , ' tcx : ' a > (
682
+ fn codegen_call_inner < ' a , ' tcx : ' a > (
683
683
fx : & mut FunctionCx < ' a , ' tcx , impl Backend > ,
684
684
func : Option < & Operand < ' tcx > > ,
685
685
fn_ty : Ty < ' tcx > ,
@@ -811,22 +811,51 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>(
811
811
pub fn codegen_drop < ' a , ' tcx : ' a > (
812
812
fx : & mut FunctionCx < ' a , ' tcx , impl Backend > ,
813
813
drop_place : CPlace < ' tcx > ,
814
- drop_fn_ty : Ty < ' tcx > ,
815
814
) {
816
- let ( ptr , vtable ) = drop_place. to_addr_maybe_unsized ( fx ) ;
817
- let drop_fn = crate :: vtable :: drop_fn_of_obj ( fx, vtable . unwrap ( ) ) ;
815
+ let ty = drop_place. layout ( ) . ty ;
816
+ let drop_fn = Instance :: resolve_drop_in_place ( fx. tcx , ty ) ;
818
817
819
- let fn_sig = fx. tcx . normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , & drop_fn_ty. fn_sig ( fx. tcx ) ) ;
818
+ if let ty:: InstanceDef :: DropGlue ( _, None ) = drop_fn. def {
819
+ // we don't actually need to drop anything
820
+ } else {
821
+ let drop_fn_ty = drop_fn. ty ( fx. tcx ) ;
822
+ match ty. sty {
823
+ ty:: Dynamic ( ..) => {
824
+ let ( ptr, vtable) = drop_place. to_addr_maybe_unsized ( fx) ;
825
+ let drop_fn = crate :: vtable:: drop_fn_of_obj ( fx, vtable. unwrap ( ) ) ;
820
826
821
- match get_pass_mode ( fx. tcx , fx. layout_of ( fn_sig. output ( ) ) ) {
822
- PassMode :: NoPass => { }
823
- _ => unreachable ! ( ) ,
824
- } ;
827
+ let fn_sig = fx. tcx . normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , & drop_fn_ty. fn_sig ( fx. tcx ) ) ;
825
828
826
- let sig = fx
827
- . bcx
828
- . import_signature ( clif_sig_from_fn_sig ( fx. tcx , fn_sig, true ) ) ;
829
- fx. bcx . ins ( ) . call_indirect ( sig, drop_fn, & [ ptr] ) ;
829
+ assert_eq ! ( fn_sig. output( ) , fx. tcx. mk_unit( ) ) ;
830
+
831
+ let sig = fx
832
+ . bcx
833
+ . import_signature ( clif_sig_from_fn_sig ( fx. tcx , fn_sig, true ) ) ;
834
+ fx. bcx . ins ( ) . call_indirect ( sig, drop_fn, & [ ptr] ) ;
835
+ }
836
+ _ => {
837
+ let arg_place = CPlace :: new_stack_slot (
838
+ fx,
839
+ fx. tcx . mk_ref (
840
+ & ty:: RegionKind :: ReErased ,
841
+ TypeAndMut {
842
+ ty,
843
+ mutbl : crate :: rustc:: hir:: Mutability :: MutMutable ,
844
+ } ,
845
+ ) ,
846
+ ) ;
847
+ drop_place. write_place_ref ( fx, arg_place) ;
848
+ let arg_value = arg_place. to_cvalue ( fx) ;
849
+ crate :: abi:: codegen_call_inner (
850
+ fx,
851
+ None ,
852
+ drop_fn_ty,
853
+ vec ! [ arg_value] ,
854
+ None ,
855
+ ) ;
856
+ }
857
+ }
858
+ }
830
859
}
831
860
832
861
pub fn codegen_return ( fx : & mut FunctionCx < impl Backend > ) {
0 commit comments