From 14f39aa81a8e0861c5cc8227c08b60f037a87947 Mon Sep 17 00:00:00 2001 From: oli Date: Sat, 16 Jan 2021 18:06:12 +0000 Subject: [PATCH] Do not allow arbitrary mutable references in `static mut`, just keep with the existing exceptions --- compiler/rustc_mir/src/transform/check_consts/ops.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs index 6e726215177..6f98760a7b0 100644 --- a/compiler/rustc_mir/src/transform/check_consts/ops.rs +++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs @@ -274,12 +274,8 @@ impl NonConstOp for CellBorrow { pub struct MutBorrow(pub hir::BorrowKind); impl NonConstOp for MutBorrow { - fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status { - match ccx.const_kind() { - // Mutable statics can handle mutable references in their final value - hir::ConstContext::Static(hir::Mutability::Mut) => Status::Allowed, - _ => Status::Forbidden, - } + fn status_in_item(&self, _ccx: &ConstCx<'_, '_>) -> Status { + Status::Forbidden } fn importance(&self) -> DiagnosticImportance {