Skip to content

Commit

Permalink
mark_definedness cannot fail
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 19, 2019
1 parent 9cb052a commit 4399299
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/librustc/mir/interpret/allocation.rs
Expand Up @@ -247,7 +247,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccessTest)?;

self.mark_definedness(ptr, size, true)?;
self.mark_definedness(ptr, size, true);
self.clear_relocations(cx, ptr, size)?;

AllocationExtra::memory_written(self, ptr, size)?;
Expand Down Expand Up @@ -406,7 +406,10 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
{
let val = match val {
ScalarMaybeUndef::Scalar(scalar) => scalar,
ScalarMaybeUndef::Undef => return self.mark_definedness(ptr, type_size, false),
ScalarMaybeUndef::Undef => {
self.mark_definedness(ptr, type_size, false);
return Ok(());
},
};

let bytes = match val.to_bits_or_ptr(type_size, cx) {
Expand Down Expand Up @@ -550,16 +553,15 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
ptr: Pointer<Tag>,
size: Size,
new_state: bool,
) -> InterpResult<'tcx> {
) {
if size.bytes() == 0 {
return Ok(());
return;
}
self.undef_mask.set_range(
ptr.offset,
ptr.offset + size,
new_state,
);
Ok(())
}
}

Expand Down

0 comments on commit 4399299

Please sign in to comment.