Skip to content

Commit 7c46e42

Browse files
Stop checking for while and loop in a const context
1 parent 5bed94c commit 7c46e42

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

src/librustc_mir/transform/check_consts/ops.rs

-13
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,6 @@ impl NonConstOp for LiveDrop {
164164
}
165165
}
166166

167-
#[derive(Debug)]
168-
pub struct Loop;
169-
impl NonConstOp for Loop {
170-
fn feature_gate() -> Option<Symbol> {
171-
Some(sym::const_loop)
172-
}
173-
174-
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
175-
// This should be caught by the HIR const-checker.
176-
ccx.tcx.sess.delay_span_bug(span, "complex control flow is forbidden in a const context");
177-
}
178-
}
179-
180167
#[derive(Debug)]
181168
pub struct CellBorrow;
182169
impl NonConstOp for CellBorrow {

src/librustc_mir/transform/check_consts/validation.rs

-6
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@ impl Validator<'mir, 'tcx> {
207207
}
208208
}
209209

210-
if body.is_cfg_cyclic() {
211-
// We can't provide a good span for the error here, but this should be caught by the
212-
// HIR const-checker anyways.
213-
self.check_op_spanned(ops::Loop, body.span);
214-
}
215-
216210
self.visit_body(&body);
217211

218212
// Ensure that the end result is `Sync` in a non-thread local `static`.

src/librustc_passes/check_const.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ impl NonConstExpr {
4040

4141
let gates: &[_] = match self {
4242
// A `for` loop's desugaring contains a call to `IntoIterator::into_iter`,
43-
// so they are not yet allowed with `#![feature(const_loop)]`.
43+
// so they are not yet allowed.
4444
// Likewise, `?` desugars to a call to `Try::into_result`.
4545
Self::Loop(ForLoop) | Self::Match(ForLoopDesugar | TryDesugar | AwaitDesugar) => {
4646
return None;
4747
}
4848

49-
Self::Loop(Loop | While | WhileLet) | Self::Match(WhileDesugar | WhileLetDesugar) => {
50-
&[sym::const_loop]
51-
}
52-
53-
// All other matches are allowed.
54-
Self::Match(Normal | IfDesugar { .. } | IfLetDesugar { .. }) => &[],
49+
// All other expressions are allowed.
50+
Self::Loop(Loop | While | WhileLet)
51+
| Self::Match(
52+
WhileDesugar | WhileLetDesugar | Normal | IfDesugar { .. } | IfLetDesugar { .. },
53+
) => &[],
5554
};
5655

5756
Some(gates)

0 commit comments

Comments
 (0)