Skip to content

Commit 705d75e

Browse files
committed
Improve miri's error reporting in check_in_alloc
1 parent 7b4bc69 commit 705d75e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
353353
// FIXME: Working around https://github.com/rust-lang/rust/issues/56209
354354
where Extra: AllocationExtra<Tag, MemoryExtra>
355355
{
356-
let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64), CheckInAllocMsg::WriteBytes)?;
356+
let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64),
357+
CheckInAllocMsg::WriteBytes)?;
357358
bytes.clone_from_slice(src);
358359
Ok(())
359360
}

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,8 @@ fn slice_pat_covered_by_const<'tcx>(
14181418
return Ok(false);
14191419
}
14201420
let n = n.assert_usize(tcx).unwrap();
1421-
alloc.get_bytes(&tcx, ptr, Size::from_bytes(n), CheckInAllocMsg::SlicePatCoveredByConst).unwrap()
1421+
alloc.get_bytes(&tcx, ptr, Size::from_bytes(n),
1422+
CheckInAllocMsg::SlicePatCoveredByConst).unwrap()
14221423
},
14231424
// a slice fat pointer to a zero length slice
14241425
(ConstValue::Slice(Scalar::Bits { .. }, 0), ty::Slice(t)) => {

src/librustc_mir/interpret/operand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
667667
ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr)) => {
668668
// The niche must be just 0 (which an inbounds pointer value never is)
669669
let ptr_valid = niche_start == 0 && variants_start == variants_end &&
670-
self.memory.check_bounds_ptr(ptr, CheckInAllocMsg::ReadDiscriminant).is_ok();
670+
self.memory.check_bounds_ptr(ptr,
671+
CheckInAllocMsg::ReadDiscriminant).is_ok();
671672
if !ptr_valid {
672673
return err!(InvalidDiscriminant(raw_discr.erase_tag()));
673674
}

0 commit comments

Comments
 (0)