Skip to content

Commit 7b4bc69

Browse files
committed
Improve miri's error reporting in check_in_alloc
1 parent 725199c commit 7b4bc69

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub enum InboundsCheck {
2222
MaybeDead,
2323
}
2424

25-
/// Used by `check_in_alloc` to indicate whether the pointer needs to be just inbounds
26-
/// or also inbounds of a *live* allocation.
25+
/// Used by `check_in_alloc` to indicate context of check
2726
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)]
2827
pub enum CheckInAllocMsg {
2928
ReadCStr,

src/librustc_mir/interpret/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax::ast::Mutability;
2020
use super::{
2121
Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
2222
EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
23-
Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck, CheckInAllocMsg,
23+
Machine, AllocMap, MayLeak, ErrorHandled, CheckInAllocMsg,
2424
};
2525

2626
#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
@@ -440,13 +440,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
440440
Ok((layout.size, layout.align.abi))
441441
}
442442
_ => match msg {
443-
InboundsCheck::MaybeDead => {
443+
CheckInAllocMsg::CheckAlign | CheckInAllocMsg::ReadDiscriminant => {
444444
// Must be a deallocated pointer
445445
Ok(*self.dead_alloc_map.get(&id).expect(
446446
"allocation missing in dead_alloc_map"
447447
))
448448
},
449-
InboundsCheck::Live => err!(DanglingPointerDeref),
449+
_ => err!(DanglingPointerDeref),
450450
},
451451
}
452452
}

0 commit comments

Comments
 (0)