Skip to content

Commit 681bd83

Browse files
committed
Change to_ptr by force_ptr
1 parent 3bd1734 commit 681bd83

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/librustc_mir/interpret/memory.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
627627
if size.bytes() == 0 {
628628
Ok(&[])
629629
} else {
630-
let ptr = ptr.to_ptr()?;
630+
let ptr = self.force_ptr(ptr)?;
631631
self.get(ptr.alloc_id)?.get_bytes(self, ptr, size)
632632
}
633633
}
@@ -714,8 +714,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
714714
// non-NULLness which already happened.
715715
return Ok(());
716716
}
717-
let src = src.to_ptr()?;
718-
let dest = dest.to_ptr()?;
717+
let src = self.force_ptr(src)?;
718+
let dest = self.force_ptr(dest)?;
719719

720720
// first copy the relocations to a temporary buffer, because
721721
// `get_bytes_mut` will clear the relocations, which is correct,

src/librustc_mir/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
232232
}
233233

234234
// check for integer pointers before alignment to report better errors
235-
let ptr = ptr.to_ptr()?;
235+
let ptr = self.force_ptr(ptr)?;
236236
self.memory.check_align(ptr.into(), ptr_align)?;
237237
match mplace.layout.abi {
238238
layout::Abi::Scalar(..) => {

src/librustc_mir/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ where
753753
}
754754

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

src/librustc_mir/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
7979
let (fn_def, abi) = match func.layout.ty.sty {
8080
ty::FnPtr(sig) => {
8181
let caller_abi = sig.abi();
82-
let fn_ptr = self.read_scalar(func)?.to_ptr()?;
82+
let fn_ptr = self.force_ptr(self.read_scalar(func)?.not_undef()?)?;
8383
let instance = self.memory.get_fn(fn_ptr)?;
8484
(instance, caller_abi)
8585
}

src/librustc_mir/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
559559
// This is the size in bytes of the whole array.
560560
let size = ty_size * len;
561561

562-
let ptr = mplace.ptr.to_ptr()?;
562+
let ptr = self.ecx.force_ptr(mplace.ptr)?;
563563

564564
// NOTE: Keep this in sync with the handling of integer and float
565565
// types above, in `visit_primitive`.

0 commit comments

Comments
 (0)