Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #61880

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change to_ptr by force_ptr
  • Loading branch information
pvdrz committed Jun 12, 2019
commit 666bebcdd9180f2e0a9c4c142a5f09f8d5f2cd64
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
@@ -632,7 +632,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, '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)
}
}
@@ -719,8 +719,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, '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,
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
@@ -232,7 +232,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, '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(..) => {
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
@@ -750,7 +750,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
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/terminator.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, '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)
}
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
@@ -559,7 +559,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
// 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`.