about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLooMaclin <loo.maclin@protonmail.com>2019-04-19 02:10:59 +0300
committerLooMaclin <loo.maclin@protonmail.com>2019-04-19 02:10:59 +0300
commit15d50deeb457d5761802dd1066f7bfbeaf71c2cb (patch)
tree03de94cb13d1d1a6589e7268ea58486b2e026447
parent0d97ad383412970b39275226bdfde7393d73867f (diff)
downloadrust-15d50deeb457d5761802dd1066f7bfbeaf71c2cb.tar.gz
rust-15d50deeb457d5761802dd1066f7bfbeaf71c2cb.zip
Improve miri's error reporting in check_in_alloc
-rw-r--r--src/librustc/mir/interpret/allocation.rs14
-rw-r--r--src/librustc/mir/interpret/error.rs2
-rw-r--r--src/librustc_mir/interpret/memory.rs2
-rw-r--r--src/librustc_mir/interpret/operand.rs2
-rw-r--r--src/librustc_mir/interpret/validity.rs2
5 files changed, 11 insertions, 11 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index 35b8a5fda4f..79ef81e81eb 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -25,19 +25,19 @@ pub enum InboundsCheck {
 /// Used by `check_in_alloc` to indicate context of check
 #[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)]
 pub enum CheckInAllocMsg {
-    MemoryAccess,
+    MemoryAccessTest,
     NullPointerTest,
-    PointerArithmetic,
-    OutOfBounds,
+    PointerArithmeticTest,
+    InboundsTest,
 }
 
 impl Display for CheckInAllocMsg {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", match *self {
-            CheckInAllocMsg::MemoryAccess => "memory access",
-            CheckInAllocMsg::NullPointer => "null pointer",
-            CheckInAllocMsg::PointerArithmetic => "pointer arithmetic",
-            CheckInAllocMsg::OutOfBounds => "out of bounds",
+            CheckInAllocMsg::MemoryAccessTest => "Memory access",
+            CheckInAllocMsg::NullPointerTest => "Null pointer",
+            CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic",
+            CheckInAllocMsg::InboundsTest => "Inbounds",
         })
     }
 }
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 23a47fb1a35..2fe6982fdf8 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -461,7 +461,7 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
         use self::InterpError::*;
         match *self {
             PointerOutOfBounds { ptr, msg, allocation_size } => {
-                write!(f, "Pointer must be in-bounds{} at offset {}, but is outside bounds of \
+                write!(f, "{} test failed: pointer must be in-bounds at offset {}, but is outside bounds of \
                            allocation {} which has size {}", msg,
                        ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
             },
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index e8ae7ab579b..b176a0ac61f 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -253,7 +253,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
                 // check this is not NULL -- which we can ensure only if this is in-bounds
                 // of some (potentially dead) allocation.
                 let align = self.check_bounds_ptr(ptr, InboundsCheck::MaybeDead,
-                                                  CheckInAllocMsg::NullPointer)?;
+                                                  CheckInAllocMsg::NullPointerTest)?;
                 (ptr.offset.bytes(), align)
             }
             Scalar::Bits { bits, size } => {
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 38fe1caa41f..8d9550e8f07 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -668,7 +668,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
                         // The niche must be just 0 (which an inbounds pointer value never is)
                         let ptr_valid = niche_start == 0 && variants_start == variants_end &&
                             self.memory.check_bounds_ptr(ptr, InboundsCheck::MaybeDead,
-                                                         CheckInAllocMsg::OutOfBounds).is_ok();
+                                                         CheckInAllocMsg::NullPointerTest).is_ok();
                         if !ptr_valid {
                             return err!(InvalidDiscriminant(raw_discr.erase_tag()));
                         }
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 965b2898cad..ebba704e4f4 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -394,7 +394,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
                         try_validation!(
                             self.ecx.memory
                                 .get(ptr.alloc_id)?
-                                .check_bounds(self.ecx, ptr, size, CheckInAllocMsg::OutOfBounds),
+                                .check_bounds(self.ecx, ptr, size, CheckInAllocMsg::InboundsTest),
                             "dangling (not entirely in bounds) reference", self.path);
                     }
                     // Check if we have encountered this pointer+layout combination