From 719dafc48b3a076e9f6341be97bad0cef316f24b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 28 Jun 2021 09:19:36 +0200 Subject: [PATCH] double-check mutability inside Allocation --- compiler/rustc_middle/src/mir/interpret/allocation.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index ee3902991e911..c0cfc7b1ba4ec 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -340,6 +340,8 @@ impl Allocation { range: AllocRange, val: ScalarMaybeUninit, ) -> AllocResult { + assert!(self.mutability == Mutability::Mut); + let val = match val { ScalarMaybeUninit::Scalar(scalar) => scalar, ScalarMaybeUninit::Uninit => { @@ -463,6 +465,7 @@ impl Allocation { if range.size.bytes() == 0 { return; } + assert!(self.mutability == Mutability::Mut); self.init_mask.set_range(range.start, range.end(), is_init); } }