From fa6bb398553200c0bc6ddba488eec43d5a497aef Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 5 Nov 2019 21:13:17 -0800 Subject: [PATCH] Add caller_location paramter to FnAbi::new_internal. We pass it in `of_instance` when the instance requires caller location. --- src/librustc/ty/layout.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 7f93e8c91e9d..6c921134ab89 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2434,6 +2434,7 @@ where cx: &C, sig: ty::PolyFnSig<'tcx>, extra_args: &[Ty<'tcx>], + caller_location: Option>, mk_arg_type: impl Fn(Ty<'tcx>, Option) -> ArgAbi<'tcx, Ty<'tcx>>, ) -> Self; fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi); @@ -2448,13 +2449,19 @@ where + HasParamEnv<'tcx>, { fn of_fn_ptr(cx: &C, sig: ty::PolyFnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self { - call::FnAbi::new_internal(cx, sig, extra_args, |ty, _| ArgAbi::new(cx.layout_of(ty))) + call::FnAbi::new_internal(cx, sig, extra_args, None, |ty, _| ArgAbi::new(cx.layout_of(ty))) } fn of_instance(cx: &C, instance: ty::Instance<'tcx>, extra_args: &[Ty<'tcx>]) -> Self { let sig = instance.fn_sig_for_fn_abi(cx.tcx()); - call::FnAbi::new_internal(cx, sig, extra_args, |ty, arg_idx| { + let caller_location = if instance.def.requires_caller_location(cx.tcx()) { + Some(cx.tcx().caller_location_ty()) + } else { + None + }; + + call::FnAbi::new_internal(cx, sig, extra_args, caller_location, |ty, arg_idx| { let mut layout = cx.layout_of(ty); // Don't pass the vtable, it's not an argument of the virtual fn. // Instead, pass just the data pointer, but give it the type `*const/mut dyn Trait` @@ -2512,6 +2519,7 @@ where cx: &C, sig: ty::PolyFnSig<'tcx>, extra_args: &[Ty<'tcx>], + caller_location: Option>, mk_arg_type: impl Fn(Ty<'tcx>, Option) -> ArgAbi<'tcx, Ty<'tcx>>, ) -> Self { debug!("FnAbi::new_internal({:?}, {:?})", sig, extra_args); @@ -2684,6 +2692,7 @@ where .iter() .cloned() .chain(extra_args) + .chain(caller_location) .enumerate() .map(|(i, ty)| arg_of(ty, Some(i))) .collect(),