don't force allocate for UnsafeFnPointer casts

This commit is contained in:
Oliver Schneider 2016-10-21 14:55:49 +02:00
parent eb08a2e646
commit 9af5a0a420
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46

View File

@ -695,13 +695,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
UnsafeFnPointer => match dest_ty.sty {
ty::TyFnPtr(unsafe_fn_ty) => {
// FIXME(solson)
let dest = self.force_allocation(dest)?.to_ptr();
let src = self.eval_operand(operand)?;
let ptr = src.read_ptr(&self.memory)?;
let (def_id, substs, _) = self.memory.get_fn(ptr.alloc_id)?;
let fn_ptr = self.memory.create_fn_ptr(def_id, substs, unsafe_fn_ty);
self.memory.write_ptr(dest, fn_ptr)?;
self.write_value(Value::ByVal(PrimVal::from_fn_ptr(fn_ptr)), dest, dest_ty)?;
},
ref other => bug!("fn to unsafe fn cast on {:?}", other),
},