Skip to content

Commit 14f39aa

Browse files
committed
Do not allow arbitrary mutable references in static mut, just keep with the existing exceptions
1 parent 00e62fa commit 14f39aa

File tree

1 file changed

+2
-6
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+2
-6
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,8 @@ impl NonConstOp for CellBorrow {
274274
pub struct MutBorrow(pub hir::BorrowKind);
275275

276276
impl NonConstOp for MutBorrow {
277-
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
278-
match ccx.const_kind() {
279-
// Mutable statics can handle mutable references in their final value
280-
hir::ConstContext::Static(hir::Mutability::Mut) => Status::Allowed,
281-
_ => Status::Forbidden,
282-
}
277+
fn status_in_item(&self, _ccx: &ConstCx<'_, '_>) -> Status {
278+
Status::Forbidden
283279
}
284280

285281
fn importance(&self) -> DiagnosticImportance {

0 commit comments

Comments
 (0)