don't force allocate for UnsafeFnPointer casts
This commit is contained in:
parent
eb08a2e646
commit
9af5a0a420
1 changed files with 1 additions and 3 deletions
|
@ -695,13 +695,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||||
|
|
||||||
UnsafeFnPointer => match dest_ty.sty {
|
UnsafeFnPointer => match dest_ty.sty {
|
||||||
ty::TyFnPtr(unsafe_fn_ty) => {
|
ty::TyFnPtr(unsafe_fn_ty) => {
|
||||||
// FIXME(solson)
|
|
||||||
let dest = self.force_allocation(dest)?.to_ptr();
|
|
||||||
let src = self.eval_operand(operand)?;
|
let src = self.eval_operand(operand)?;
|
||||||
let ptr = src.read_ptr(&self.memory)?;
|
let ptr = src.read_ptr(&self.memory)?;
|
||||||
let (def_id, substs, _) = self.memory.get_fn(ptr.alloc_id)?;
|
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);
|
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),
|
ref other => bug!("fn to unsafe fn cast on {:?}", other),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue