Skip to content

Commit

Permalink
Auto merge of #1114 - rust-lang:to_ptr_considered_harmful, r=oli-obk
Browse files Browse the repository at this point in the history
Remove all uses of `to_ptr`

Also only works on top of rust-lang/rust#67192
  • Loading branch information
bors committed Dec 27, 2019
2 parents 0f1dec0 + 4aef81e commit 34d8ec8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ae6cedb8d1e37469be1434642a3e403fce50a03
8f5f8f916f00f7989a4ebf7b7dbfe1afd605f828
2 changes: 1 addition & 1 deletion src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
)?;
}
"__rust_realloc" => {
let ptr = this.read_scalar(args[0])?.to_ptr()?;
let old_size = this.read_scalar(args[1])?.to_machine_usize(this)?;
let align = this.read_scalar(args[2])?.to_machine_usize(this)?;
let new_size = this.read_scalar(args[3])?.to_machine_usize(this)?;
Expand All @@ -281,6 +280,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
if !align.is_power_of_two() {
throw_unsup!(HeapAllocNonPowerOfTwoAlignment(align));
}
let ptr = this.force_ptr(this.read_scalar(args[0])?.not_undef()?)?;
let align = Align::from_bytes(align).unwrap();
let new_ptr = this.memory.reallocate(
ptr,
Expand Down
2 changes: 1 addition & 1 deletion src/shims/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// Do it in memory
let mplace = this.force_allocation(dest)?;
mplace.meta.unwrap_none();
let ptr = mplace.ptr.to_ptr()?;
let ptr = mplace.ptr.assert_ptr();
// We know the return place is in-bounds
this.memory.get_raw_mut(ptr.alloc_id)?.mark_definedness(
ptr,
Expand Down
2 changes: 1 addition & 1 deletion src/stacked_borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let protector = if protect { Some(this.frame().extra.call_id) } else { None };
let ptr = place.ptr.to_ptr().expect("we should have a proper pointer");
let ptr = place.ptr.assert_ptr();
trace!(
"reborrow: {} reference {:?} derived from {:?} (pointee {}): {:?}, size {}",
kind,
Expand Down

0 comments on commit 34d8ec8

Please sign in to comment.