Skip to content

Commit 23a907e

Browse files
MIR const-checking
1 parent 8660621 commit 23a907e

File tree

3 files changed

+1
-33
lines changed

3 files changed

+1
-33
lines changed

src/librustc_mir/transform/check_consts/ops.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,6 @@ impl NonConstOp for HeapAllocation {
142142
}
143143
}
144144

145-
#[derive(Debug)]
146-
pub struct IfOrMatch;
147-
impl NonConstOp for IfOrMatch {
148-
fn feature_gate() -> Option<Symbol> {
149-
Some(sym::const_if_match)
150-
}
151-
152-
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
153-
// This should be caught by the HIR const-checker.
154-
ccx.tcx.sess.delay_span_bug(span, "complex control flow is forbidden in a const context");
155-
}
156-
}
157-
158145
#[derive(Debug)]
159146
pub struct InlineAsm;
160147
impl NonConstOp for InlineAsm {}

src/librustc_mir/transform/check_consts/validation.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,21 +481,12 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
481481
self.super_statement(statement, location);
482482
}
483483

484-
StatementKind::FakeRead(
485-
FakeReadCause::ForMatchedPlace
486-
| FakeReadCause::ForMatchGuard
487-
| FakeReadCause::ForGuardBinding,
488-
_,
489-
) => {
490-
self.super_statement(statement, location);
491-
self.check_op(ops::IfOrMatch);
492-
}
493484
StatementKind::LlvmInlineAsm { .. } => {
494485
self.super_statement(statement, location);
495486
self.check_op(ops::InlineAsm);
496487
}
497488

498-
StatementKind::FakeRead(FakeReadCause::ForLet | FakeReadCause::ForIndex, _)
489+
StatementKind::FakeRead(..)
499490
| StatementKind::StorageLive(_)
500491
| StatementKind::StorageDead(_)
501492
| StatementKind::Retag { .. }

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ fn check_statement(
239239
check_rvalue(tcx, body, def_id, rval, span)
240240
}
241241

242-
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _)
243-
if !feature_allowed(tcx, def_id, sym::const_if_match) =>
244-
{
245-
Err((span, "loops and conditional expressions are not stable in const fn".into()))
246-
}
247-
248242
StatementKind::FakeRead(_, place) => check_place(tcx, **place, span, def_id, body),
249243

250244
// just an assignment
@@ -355,10 +349,6 @@ fn check_terminator(
355349
check_operand(tcx, value, span, def_id, body)
356350
}
357351

358-
TerminatorKind::SwitchInt { .. } if !feature_allowed(tcx, def_id, sym::const_if_match) => {
359-
Err((span, "loops and conditional expressions are not stable in const fn".into()))
360-
}
361-
362352
TerminatorKind::SwitchInt { discr, switch_ty: _, values: _, targets: _ } => {
363353
check_operand(tcx, discr, span, def_id, body)
364354
}

0 commit comments

Comments
 (0)