about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLooMaclin <loo.maclin@protonmail.com>2019-04-02 06:16:11 +0300
committerLooMaclin <loo.maclin@protonmail.com>2019-04-02 06:16:11 +0300
commit7b4bc6974a16df46e5d50a1191c124fc8c1f56ae (patch)
tree62986e8e4df85ab5dc363a5753a4026e39bc9bf0
parent725199ce6512cc946d5b16c4ef3a845a2926cb09 (diff)
downloadrust-7b4bc6974a16df46e5d50a1191c124fc8c1f56ae.tar.gz
rust-7b4bc6974a16df46e5d50a1191c124fc8c1f56ae.zip
Improve miri's error reporting in check_in_alloc
-rw-r--r--src/librustc/mir/interpret/allocation.rs3
-rw-r--r--src/librustc_mir/interpret/memory.rs6
2 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index f00da804e95..a04316b719e 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -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,
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 302bc84e65c..80efafa6550 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -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),
             },
         }
     }