]> git.lizzy.rs Git - rust.git/commitdiff
Improve miri's error reporting in check_in_alloc
authorLooMaclin <loo.maclin@protonmail.com>
Tue, 2 Apr 2019 03:16:11 +0000 (06:16 +0300)
committerLooMaclin <loo.maclin@protonmail.com>
Tue, 2 Apr 2019 03:16:11 +0000 (06:16 +0300)
src/librustc/mir/interpret/allocation.rs
src/librustc_mir/interpret/memory.rs

index f00da804e9535b23c923d99b95fcff7d5c51aa18..a04316b719e83cc336164e47a68ed43c6e70ef0b 100644 (file)
@@ -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,
index 302bc84e65c4ab2ccb46daf8c0639cc9fde5160c..80efafa655036c291f1dda4a77ac670c7a27683b 100644 (file)
@@ -20,7 +20,7 @@
 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 @@ pub fn get_size_and_align(
                 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),
             },
         }
     }