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

index 84733f9af6d58303fcd95a223635df94fdf65198..bc2dbfcbf388f1cfc88a339444d0d89c1f8aa956 100644 (file)
@@ -32,8 +32,10 @@ pub enum CheckInAllocMsg {
 }
 
 impl Display for CheckInAllocMsg {
+    /// When this printed as an error the context looks like this
+    /// "{test name} test failed: pointer must be in-bounds at offset..."
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{}", match *self {
+        write!(f, "{} test", match *self {
             CheckInAllocMsg::MemoryAccessTest => "Memory access",
             CheckInAllocMsg::NullPointerTest => "Null pointer",
             CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic",
index cf2d12b59359bc1e21580672c481bd7b07ff39ae..ce281cf0d3400095bdb78bf54125b464b6b0b832 100644 (file)
@@ -461,7 +461,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use self::InterpError::*;
         match *self {
             PointerOutOfBounds { ptr, msg, allocation_size } => {
-                write!(f, "{} test failed: pointer must be in-bounds at offset {}, \
+                write!(f, "{} 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())
             },