Skip to content

Commit

Permalink
Change to_ptr by force_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Jun 16, 2019
1 parent 3bd1734 commit 681bd83
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/memory.rs
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/operand.rs
Expand Up @@ -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(..) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/place.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/terminator.rs
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/validity.rs
Expand Up @@ -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`.
Expand Down

0 comments on commit 681bd83

Please sign in to comment.