Skip to content

Commit

Permalink
double-check mutability inside Allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jun 28, 2021
1 parent d08a471 commit 719dafc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
range: AllocRange,
val: ScalarMaybeUninit<Tag>,
) -> AllocResult {
assert!(self.mutability == Mutability::Mut);

let val = match val {
ScalarMaybeUninit::Scalar(scalar) => scalar,
ScalarMaybeUninit::Uninit => {
Expand Down Expand Up @@ -463,6 +465,7 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
if range.size.bytes() == 0 {
return;
}
assert!(self.mutability == Mutability::Mut);
self.init_mask.set_range(range.start, range.end(), is_init);
}
}
Expand Down

0 comments on commit 719dafc

Please sign in to comment.