Change to_ptr by force_ptr

This commit is contained in:
Christian Poveda 2019-06-12 13:08:09 -05:00 committed by Christian Poveda
parent 3bd1734ea2
commit 681bd83828
5 changed files with 7 additions and 7 deletions

View file

@ -627,7 +627,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
if size.bytes() == 0 {
Ok(&[])
} else {
let ptr = ptr.to_ptr()?;
let ptr = self.force_ptr(ptr)?;
self.get(ptr.alloc_id)?.get_bytes(self, ptr, size)
}
}
@ -714,8 +714,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
// non-NULLness which already happened.
return Ok(());
}
let src = src.to_ptr()?;
let dest = dest.to_ptr()?;
let src = self.force_ptr(src)?;
let dest = self.force_ptr(dest)?;
// first copy the relocations to a temporary buffer, because
// `get_bytes_mut` will clear the relocations, which is correct,

View file

@ -232,7 +232,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
}
// check for integer pointers before alignment to report better errors
let ptr = ptr.to_ptr()?;
let ptr = self.force_ptr(ptr)?;
self.memory.check_align(ptr.into(), ptr_align)?;
match mplace.layout.abi {
layout::Abi::Scalar(..) => {

View file

@ -753,7 +753,7 @@ where
}
// check for integer pointers before alignment to report better errors
let ptr = ptr.to_ptr()?;
let ptr = self.force_ptr(ptr)?;
self.memory.check_align(ptr.into(), ptr_align)?;
let tcx = &*self.tcx;
// FIXME: We should check that there are dest.layout.size many bytes available in

View file

@ -79,7 +79,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
let (fn_def, abi) = match func.layout.ty.sty {
ty::FnPtr(sig) => {
let caller_abi = sig.abi();
let fn_ptr = self.read_scalar(func)?.to_ptr()?;
let fn_ptr = self.force_ptr(self.read_scalar(func)?.not_undef()?)?;
let instance = self.memory.get_fn(fn_ptr)?;
(instance, caller_abi)
}

View file

@ -559,7 +559,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
// This is the size in bytes of the whole array.
let size = ty_size * len;
let ptr = mplace.ptr.to_ptr()?;
let ptr = self.ecx.force_ptr(mplace.ptr)?;
// NOTE: Keep this in sync with the handling of integer and float
// types above, in `visit_primitive`.