Improve miri's error reporting in check_in_alloc
This commit is contained in:
parent
725199ce65
commit
7b4bc6974a
2 changed files with 4 additions and 5 deletions
|
|
@ -22,8 +22,7 @@ pub enum InboundsCheck {
|
|||
MaybeDead,
|
||||
}
|
||||
|
||||
/// Used by `check_in_alloc` to indicate whether the pointer needs to be just inbounds
|
||||
/// or also inbounds of a *live* allocation.
|
||||
/// Used by `check_in_alloc` to indicate context of check
|
||||
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub enum CheckInAllocMsg {
|
||||
ReadCStr,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use syntax::ast::Mutability;
|
|||
use super::{
|
||||
Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
|
||||
EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
|
||||
Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck, CheckInAllocMsg,
|
||||
Machine, AllocMap, MayLeak, ErrorHandled, CheckInAllocMsg,
|
||||
};
|
||||
|
||||
#[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> {
|
|||
Ok((layout.size, layout.align.abi))
|
||||
}
|
||||
_ => match msg {
|
||||
InboundsCheck::MaybeDead => {
|
||||
CheckInAllocMsg::CheckAlign | CheckInAllocMsg::ReadDiscriminant => {
|
||||
// Must be a deallocated pointer
|
||||
Ok(*self.dead_alloc_map.get(&id).expect(
|
||||
"allocation missing in dead_alloc_map"
|
||||
))
|
||||
},
|
||||
InboundsCheck::Live => err!(DanglingPointerDeref),
|
||||
_ => err!(DanglingPointerDeref),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue