@@ -655,19 +655,18 @@ pub(crate) fn codegen_drop<'tcx>(
655
655
// we don't actually need to drop anything
656
656
} else {
657
657
let drop_fn_ty = drop_fn. monomorphic_ty ( fx. tcx ) ;
658
+ let fn_sig = fx. tcx . normalize_erasing_late_bound_regions (
659
+ ParamEnv :: reveal_all ( ) ,
660
+ & drop_fn_ty. fn_sig ( fx. tcx ) ,
661
+ ) ;
662
+ assert_eq ! ( fn_sig. output( ) , fx. tcx. mk_unit( ) ) ;
663
+
658
664
match ty. kind {
659
665
ty:: Dynamic ( ..) => {
660
666
let ( ptr, vtable) = drop_place. to_ptr_maybe_unsized ( ) ;
661
667
let ptr = ptr. get_addr ( fx) ;
662
668
let drop_fn = crate :: vtable:: drop_fn_of_obj ( fx, vtable. unwrap ( ) ) ;
663
669
664
- let fn_sig = fx. tcx . normalize_erasing_late_bound_regions (
665
- ParamEnv :: reveal_all ( ) ,
666
- & drop_fn_ty. fn_sig ( fx. tcx ) ,
667
- ) ;
668
-
669
- assert_eq ! ( fn_sig. output( ) , fx. tcx. mk_unit( ) ) ;
670
-
671
670
let sig = clif_sig_from_fn_sig (
672
671
fx. tcx ,
673
672
fx. triple ( ) ,
@@ -679,6 +678,15 @@ pub(crate) fn codegen_drop<'tcx>(
679
678
fx. bcx . ins ( ) . call_indirect ( sig, drop_fn, & [ ptr] ) ;
680
679
}
681
680
_ => {
681
+ let instance = match drop_fn_ty. kind {
682
+ ty:: FnDef ( def_id, substs) => {
683
+ Instance :: resolve ( fx. tcx , ParamEnv :: reveal_all ( ) , def_id, substs) . unwrap ( )
684
+ }
685
+ _ => unreachable ! ( "{:?}" , drop_fn_ty) ,
686
+ } ;
687
+
688
+ assert ! ( !matches!( instance. def, InstanceDef :: Virtual ( _, _) ) ) ;
689
+
682
690
let arg_place = CPlace :: new_stack_slot (
683
691
fx,
684
692
fx. layout_of ( fx. tcx . mk_ref (
@@ -691,7 +699,18 @@ pub(crate) fn codegen_drop<'tcx>(
691
699
) ;
692
700
drop_place. write_place_ref ( fx, arg_place) ;
693
701
let arg_value = arg_place. to_cvalue ( fx) ;
694
- codegen_call_inner ( fx, span, None , drop_fn_ty, vec ! [ arg_value] , None ) ;
702
+ let arg_value = adjust_arg_for_abi ( fx, arg_value) ;
703
+
704
+ let mut call_args: Vec < Value > = arg_value. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
705
+
706
+ if instance. def . requires_caller_location ( fx. tcx ) {
707
+ // Pass the caller location for `#[track_caller]`.
708
+ let caller_location = fx. get_caller_location ( span) ;
709
+ call_args. extend ( adjust_arg_for_abi ( fx, caller_location) . into_iter ( ) ) ;
710
+ }
711
+
712
+ let func_ref = fx. get_function_ref ( instance) ;
713
+ fx. bcx . ins ( ) . call ( func_ref, & call_args) ;
695
714
}
696
715
}
697
716
}
0 commit comments