Skip to content

Commit 8f59902

Browse files
Put MIR checks for loops behind the feature flag
1 parent 57959b2 commit 8f59902

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/librustc_mir/transform/check_consts/ops.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ impl NonConstOp for LiveDrop {
170170
#[derive(Debug)]
171171
pub struct Loop;
172172
impl NonConstOp for Loop {
173+
fn feature_gate(tcx: TyCtxt<'_>) -> Option<bool> {
174+
Some(tcx.features().const_loop)
175+
}
176+
173177
fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
174178
// This should be caught by the HIR const-checker.
175179
item.tcx.sess.delay_span_bug(

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ fn check_terminator(
390390
cleanup: _,
391391
} => check_operand(tcx, cond, span, def_id, body),
392392

393-
TerminatorKind::FalseUnwind { .. } => {
393+
TerminatorKind::FalseUnwind { .. } if !tcx.features().const_loop => {
394394
Err((span, "loops are not allowed in const fn".into()))
395395
},
396+
397+
TerminatorKind::FalseUnwind { .. } => Ok(()),
396398
}
397399
}

0 commit comments

Comments
 (0)