Skip to content

Commit 4e329eb

Browse files
authored
fix for latest rustc (#746)
fix for latest rustc
2 parents 5fdcf52 + f10ab19 commit 4e329eb

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d35181ad8785fa958e43580a29a982afe02c728f
1+
1a56ec4dae92538ab6e0ecf993c61f3b50ed77cf

src/operator.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
158158
// Dead allocations in miri cannot overlap with live allocations, but
159159
// on read hardware this can easily happen. Thus for comparisons we require
160160
// both pointers to be live.
161-
self.memory().check_bounds_ptr(left, InboundsCheck::Live)?;
162-
self.memory().check_bounds_ptr(right, InboundsCheck::Live)?;
161+
self.memory().check_bounds_ptr(left, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
162+
self.memory().check_bounds_ptr(right, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
163163
// Two in-bounds pointers, we can compare across allocations.
164164
left == right
165165
}
@@ -183,7 +183,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
183183
if bits < 32 {
184184
// Test if the ptr is in-bounds. Then it cannot be NULL.
185185
// Even dangling pointers cannot be NULL.
186-
if self.memory().check_bounds_ptr(ptr, InboundsCheck::MaybeDead).is_ok() {
186+
if self.memory().check_bounds_ptr(ptr, InboundsCheck::MaybeDead, CheckInAllocMsg::NullPointerTest).is_ok() {
187187
return Ok(false);
188188
}
189189
}
@@ -340,9 +340,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
340340
if let Scalar::Ptr(ptr) = ptr {
341341
// Both old and new pointer must be in-bounds of a *live* allocation.
342342
// (Of the same allocation, but that part is trivial with our representation.)
343-
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
343+
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
344344
let ptr = ptr.signed_offset(offset, self)?;
345-
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
345+
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
346346
Ok(Scalar::Ptr(ptr))
347347
} else {
348348
// An integer pointer. They can only be offset by 0, and we pretend there

src/stacked_borrows.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc::mir::RetagKind;
1010

1111
use crate::{
1212
EvalResult, InterpError, MiriEvalContext, HelpersEvalContextExt, Evaluator, MutValueVisitor,
13-
MemoryKind, MiriMemoryKind, RangeMap, Allocation, AllocationExtra,
13+
MemoryKind, MiriMemoryKind, RangeMap, Allocation, AllocationExtra, CheckInAllocMsg,
1414
Pointer, Immediate, ImmTy, PlaceTy, MPlaceTy,
1515
};
1616

@@ -550,7 +550,7 @@ trait EvalContextPrivExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
550550

551551
// Get the allocation. It might not be mutable, so we cannot use `get_mut`.
552552
let alloc = this.memory().get(ptr.alloc_id)?;
553-
alloc.check_bounds(this, ptr, size)?;
553+
alloc.check_bounds(this, ptr, size, CheckInAllocMsg::InboundsTest)?;
554554
// Update the stacks.
555555
// Make sure that raw pointers and mutable shared references are reborrowed "weak":
556556
// There could be existing unique pointers reborrowed from them that should remain valid!

tests/compile-fail/out_of_bounds_ptr_1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: must be in-bounds and live at offset 5, but is outside bounds of allocation
1+
// error-pattern: must be in-bounds at offset 5, but is outside bounds of allocation
22
fn main() {
33
let v = [0i8; 4];
44
let x = &v as *const i8;

0 commit comments

Comments
 (0)