]> 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:33:54 +0000 (06:33 +0300)
committerLooMaclin <loo.maclin@protonmail.com>
Tue, 2 Apr 2019 03:33:54 +0000 (06:33 +0300)
src/librustc/mir/interpret/allocation.rs
src/librustc_mir/hair/pattern/_match.rs
src/librustc_mir/interpret/operand.rs

index a04316b719e83cc336164e47a68ed43c6e70ef0b..50f5da77c0fb619b1aa1b5f66972c86ce2927336 100644 (file)
@@ -353,7 +353,8 @@ pub fn write_bytes<MemoryExtra>(
         // FIXME: Working around https://github.com/rust-lang/rust/issues/56209
         where Extra: AllocationExtra<Tag, MemoryExtra>
     {
-        let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64), CheckInAllocMsg::WriteBytes)?;
+        let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64),
+                                       CheckInAllocMsg::WriteBytes)?;
         bytes.clone_from_slice(src);
         Ok(())
     }
index 014c5ced37b25e110be7179a8615d2c49ec0db5d..561ac207b6bcba53569835c637dd6781392a1289 100644 (file)
@@ -1418,7 +1418,8 @@ fn slice_pat_covered_by_const<'tcx>(
                 return Ok(false);
             }
             let n = n.assert_usize(tcx).unwrap();
-            alloc.get_bytes(&tcx, ptr, Size::from_bytes(n), CheckInAllocMsg::SlicePatCoveredByConst).unwrap()
+            alloc.get_bytes(&tcx, ptr, Size::from_bytes(n),
+                            CheckInAllocMsg::SlicePatCoveredByConst).unwrap()
         },
         // a slice fat pointer to a zero length slice
         (ConstValue::Slice(Scalar::Bits { .. }, 0), ty::Slice(t)) => {
index b90ec42de7ef0bd8a00f2630d10d16836ba533be..7529ec0aee59c9ca966e42f7b38f93e4ce4b358d 100644 (file)
@@ -667,7 +667,8 @@ pub fn read_discriminant(
                     ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) => {
                         // 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, CheckInAllocMsg::ReadDiscriminant).is_ok();
+                            self.memory.check_bounds_ptr(ptr,
+                                                         CheckInAllocMsg::ReadDiscriminant).is_ok();
                         if !ptr_valid {
                             return err!(InvalidDiscriminant(raw_discr.erase_tag()));
                         }