mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
+7
-12
@@ -700,18 +700,13 @@ pub(crate) fn codegen_drop<'tcx>(
|
||||
_ => {
|
||||
assert!(!matches!(drop_fn.def, InstanceDef::Virtual(_, _)));
|
||||
|
||||
let arg_place = CPlace::new_stack_slot(
|
||||
fx,
|
||||
fx.layout_of(fx.tcx.mk_ref(
|
||||
&ty::RegionKind::ReErased,
|
||||
TypeAndMut {
|
||||
ty,
|
||||
mutbl: crate::rustc_hir::Mutability::Mut,
|
||||
},
|
||||
)),
|
||||
);
|
||||
drop_place.write_place_ref(fx, arg_place);
|
||||
let arg_value = arg_place.to_cvalue(fx);
|
||||
let arg_value = drop_place.place_ref(fx, fx.layout_of(fx.tcx.mk_ref(
|
||||
&ty::RegionKind::ReErased,
|
||||
TypeAndMut {
|
||||
ty,
|
||||
mutbl: crate::rustc_hir::Mutability::Mut,
|
||||
},
|
||||
)));
|
||||
let arg_value = adjust_arg_for_abi(fx, arg_value);
|
||||
|
||||
let mut call_args: Vec<Value> = arg_value.into_iter().collect::<Vec<_>>();
|
||||
|
||||
+2
-1
@@ -405,7 +405,8 @@ fn trans_stmt<'tcx>(
|
||||
}
|
||||
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
|
||||
let place = trans_place(fx, *place);
|
||||
place.write_place_ref(fx, lval);
|
||||
let ref_ = place.place_ref(fx, lval.layout());
|
||||
lval.write_cvalue(fx, ref_);
|
||||
}
|
||||
Rvalue::ThreadLocalRef(def_id) => {
|
||||
let val = crate::constant::codegen_tls_ref(fx, *def_id, lval.layout());
|
||||
|
||||
@@ -681,18 +681,20 @@ pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) ->
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) {
|
||||
pub(crate) fn place_ref(
|
||||
self,
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
if has_ptr_meta(fx.tcx, self.layout().ty) {
|
||||
let (ptr, extra) = self.to_ptr_maybe_unsized();
|
||||
let ptr = CValue::by_val_pair(
|
||||
CValue::by_val_pair(
|
||||
ptr.get_addr(fx),
|
||||
extra.expect("unsized type without metadata"),
|
||||
dest.layout(),
|
||||
);
|
||||
dest.write_cvalue(fx, ptr);
|
||||
layout,
|
||||
)
|
||||
} else {
|
||||
let ptr = CValue::by_val(self.to_ptr().get_addr(fx), dest.layout());
|
||||
dest.write_cvalue(fx, ptr);
|
||||
CValue::by_val(self.to_ptr().get_addr(fx), layout)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user