fx: &mut FunctionCx<'_, '_, 'tcx>,
arg: CValue<'tcx>,
idx: usize,
-) -> (Value, Value) {
- let (ptr, vtable) = if let Abi::ScalarPair(_, _) = arg.layout().abi {
- arg.load_scalar_pair(fx)
- } else {
- let (ptr, vtable) = arg.try_to_ptr().unwrap();
- (ptr.get_addr(fx), vtable.unwrap())
+) -> (Pointer, Value) {
+ let (ptr, vtable) = 'block: {
+ if let ty::Ref(_, ty, _) = arg.layout().ty.kind() {
+ if ty.is_dyn_star() {
+ let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
+ let dyn_star = CPlace::for_ptr(Pointer::new(arg.load_scalar(fx)), inner_layout);
+ let ptr = dyn_star.place_field(fx, mir::Field::new(0)).to_ptr();
+ let vtable =
+ dyn_star.place_field(fx, mir::Field::new(1)).to_cvalue(fx).load_scalar(fx);
+ break 'block (ptr, vtable);
+ }
+ }
+
+ if let Abi::ScalarPair(_, _) = arg.layout().abi {
+ let (ptr, vtable) = arg.load_scalar_pair(fx);
+ (Pointer::new(ptr), vtable)
+ } else {
+ let (ptr, vtable) = arg.try_to_ptr().unwrap();
+ (ptr, vtable.unwrap())
+ }
};
let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes();