about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-05-21 12:46:49 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-06-28 10:08:09 -0700
commit4c2383810bb783095e285ba56c5ecb3efe139dda (patch)
tree0cad23f50ae960f6facbe3b984377b4680ec37ad
parent48ebd2cdb8f9a9010a345349304edaa757d3e4cc (diff)
downloadrust-4c2383810bb783095e285ba56c5ecb3efe139dda.tar.gz
rust-4c2383810bb783095e285ba56c5ecb3efe139dda.zip
MIR const-checking
-rw-r--r--src/librustc_mir/transform/check_consts/ops.rs13
-rw-r--r--src/librustc_mir/transform/check_consts/validation.rs11
-rw-r--r--src/librustc_mir/transform/qualify_min_const_fn.rs10
3 files changed, 1 insertions, 33 deletions
diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs
index 676688daf1c..814437faa58 100644
--- a/src/librustc_mir/transform/check_consts/ops.rs
+++ b/src/librustc_mir/transform/check_consts/ops.rs
@@ -143,19 +143,6 @@ impl NonConstOp for HeapAllocation {
 }
 
 #[derive(Debug)]
-pub struct IfOrMatch;
-impl NonConstOp for IfOrMatch {
-    fn feature_gate() -> Option<Symbol> {
-        Some(sym::const_if_match)
-    }
-
-    fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
-        // This should be caught by the HIR const-checker.
-        ccx.tcx.sess.delay_span_bug(span, "complex control flow is forbidden in a const context");
-    }
-}
-
-#[derive(Debug)]
 pub struct InlineAsm;
 impl NonConstOp for InlineAsm {}
 
diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs
index 238ad703fb0..a10e3ee9372 100644
--- a/src/librustc_mir/transform/check_consts/validation.rs
+++ b/src/librustc_mir/transform/check_consts/validation.rs
@@ -481,21 +481,12 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
                 self.super_statement(statement, location);
             }
 
-            StatementKind::FakeRead(
-                FakeReadCause::ForMatchedPlace
-                | FakeReadCause::ForMatchGuard
-                | FakeReadCause::ForGuardBinding,
-                _,
-            ) => {
-                self.super_statement(statement, location);
-                self.check_op(ops::IfOrMatch);
-            }
             StatementKind::LlvmInlineAsm { .. } => {
                 self.super_statement(statement, location);
                 self.check_op(ops::InlineAsm);
             }
 
-            StatementKind::FakeRead(FakeReadCause::ForLet | FakeReadCause::ForIndex, _)
+            StatementKind::FakeRead(..)
             | StatementKind::StorageLive(_)
             | StatementKind::StorageDead(_)
             | StatementKind::Retag { .. }
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs
index caf6c7715a9..5a3663384fb 100644
--- a/src/librustc_mir/transform/qualify_min_const_fn.rs
+++ b/src/librustc_mir/transform/qualify_min_const_fn.rs
@@ -239,12 +239,6 @@ fn check_statement(
             check_rvalue(tcx, body, def_id, rval, span)
         }
 
-        StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _)
-            if !feature_allowed(tcx, def_id, sym::const_if_match) =>
-        {
-            Err((span, "loops and conditional expressions are not stable in const fn".into()))
-        }
-
         StatementKind::FakeRead(_, place) => check_place(tcx, **place, span, def_id, body),
 
         // just an assignment
@@ -355,10 +349,6 @@ fn check_terminator(
             check_operand(tcx, value, span, def_id, body)
         }
 
-        TerminatorKind::SwitchInt { .. } if !feature_allowed(tcx, def_id, sym::const_if_match) => {
-            Err((span, "loops and conditional expressions are not stable in const fn".into()))
-        }
-
         TerminatorKind::SwitchInt { discr, switch_ty: _, values: _, targets: _ } => {
             check_operand(tcx, discr, span, def_id, body)
         }