From 3758e383a66fb74067d575615f85a5bf14eb0d32 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 17 Sep 2019 16:25:37 -0700 Subject: [PATCH] Remove reference to `Mode::NonConstFn` in qualifs This should have no effect on behavior since the validator is never run in const contexts. --- .../transform/check_consts/qualifs.rs | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 742e5d19628..39a1a2e7d29 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -214,23 +214,19 @@ impl Qualif for HasMutInterior { if let BorrowKind::Mut { .. } = kind { // In theory, any zero-sized value could be borrowed - // mutably without consequences. However, only &mut [] - // is allowed right now, and only in functions. - if cx.mode == Mode::StaticMut { + // mutably without consequences. + match ty.sty { // Inside a `static mut`, &mut [...] is also allowed. - match ty.sty { - ty::Array(..) | ty::Slice(_) => {} - _ => return true, - } - } else if let ty::Array(_, len) = ty.sty { - // FIXME(eddyb) the `cx.mode == Mode::NonConstFn` condition - // seems unnecessary, given that this is merely a ZST. - match len.try_eval_usize(cx.tcx, cx.param_env) { - Some(0) if cx.mode == Mode::NonConstFn => {}, - _ => return true, - } - } else { - return true; + ty::Array(..) | ty::Slice(_) if cx.mode == Mode::StaticMut => {}, + + // FIXME(ecstaticmorse): uncomment the following match arm to stop marking + // `&mut []` as `HasMutInterior`. + /* + ty::Array(_, len) if len.try_eval_usize(cx.tcx, cx.param_env) == Some(0) + => {}, + */ + + _ => return true, } } }