提交 09b15e98 编写于 作者: R Ralf Jung

fix dropping with vtables

上级 e860ab2d
......@@ -30,24 +30,29 @@ fn drop(
) -> EvalResult<'tcx> {
trace!("drop: {:?},\n {:?}, {:?}", arg, ty.sty, instance.def);
let instance = match ty.sty {
let (instance, arg) = match ty.sty {
ty::TyDynamic(..) => {
if let Value::ScalarPair(_, vtable) = arg {
self.read_drop_type_from_vtable(vtable.to_ptr()?)?
if let Value::ScalarPair(ptr, vtable) = arg {
// Figure out the specific drop function to call, and just pass along
// the thin part of the pointer.
let instance = self.read_drop_type_from_vtable(vtable.to_ptr()?)?;
trace!("Dropping via vtable: {:?}", instance.def);
(instance, Value::Scalar(ptr))
} else {
bug!("expected fat ptr, got {:?}", arg);
}
}
_ => instance,
_ => (instance, arg),
};
// the drop function expects a reference to the value
let fn_sig = self.tcx.fn_sig(instance.def_id()).skip_binder().clone();
let arg = OpTy {
op: Operand::Immediate(arg),
layout: self.layout_of(self.tcx.mk_mut_ptr(ty))?,
layout: self.layout_of(fn_sig.output())?,
};
trace!("Dropped type: {:?}", fn_sig.output());
let fn_sig = self.tcx.fn_sig(instance.def_id()).skip_binder().clone();
// This should always be (), but getting it from the sig seems
// easier than creating a layout of ().
let dest = PlaceTy::null(&self, self.layout_of(fn_sig.output())?);
......
......@@ -257,6 +257,9 @@ fn eval_fn_call(
sig: ty::FnSig<'tcx>,
) -> EvalResult<'tcx> {
trace!("eval_fn_call: {:#?}", instance);
if let Some((place, _)) = destination {
assert_eq!(place.layout.ty, sig.output());
}
match instance.def {
ty::InstanceDef::Intrinsic(..) => {
let (ret, target) = match destination {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册