From 5a10430f2c50937b5417881d2a8580becd6100cc Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 22 Nov 2019 16:23:01 -0800 Subject: [PATCH] Remove `Rvalue::Ref` handling from `HasMutInterior` --- .../transform/check_consts/qualifs.rs | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 85e4c8c91f47c..2d5a0a2afcd01 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -5,7 +5,7 @@ use rustc::ty::{self, Ty}; use rustc::hir::def_id::DefId; use syntax_pos::DUMMY_SP; -use super::{ConstKind, Item as ConstCx}; +use super::Item as ConstCx; pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> ConstQualifs { ConstQualifs { @@ -218,34 +218,6 @@ impl Qualif for HasMutInterior { rvalue: &Rvalue<'tcx>, ) -> bool { match *rvalue { - // Returning `true` for `Rvalue::Ref` indicates the borrow isn't - // allowed in constants (and the `Checker` will error), and/or it - // won't be promoted, due to `&mut ...` or interior mutability. - Rvalue::Ref(_, kind, ref place) => { - let ty = place.ty(cx.body, cx.tcx).ty; - - if let BorrowKind::Mut { .. } = kind { - // In theory, any zero-sized value could be borrowed - // mutably without consequences. - match ty.kind { - // Inside a `static mut`, &mut [...] is also allowed. - | ty::Array(..) - | ty::Slice(_) - if cx.const_kind == Some(ConstKind::StaticMut) - => {}, - - // FIXME(eddyb): We only return false for `&mut []` outside a const - // context which seems unnecessary given that this is merely a ZST. - | ty::Array(_, len) - if len.try_eval_usize(cx.tcx, cx.param_env) == Some(0) - && cx.const_kind == None - => {}, - - _ => return true, - } - } - } - Rvalue::Aggregate(ref kind, _) => { if let AggregateKind::Adt(def, ..) = **kind { if Some(def.did) == cx.tcx.lang_items().unsafe_cell_type() {