Put MIR checks for loops behind the feature flag
This commit is contained in:
parent
57959b2bdc
commit
8f59902aad
|
@ -170,6 +170,10 @@ impl NonConstOp for LiveDrop {
|
|||
#[derive(Debug)]
|
||||
pub struct Loop;
|
||||
impl NonConstOp for Loop {
|
||||
fn feature_gate(tcx: TyCtxt<'_>) -> Option<bool> {
|
||||
Some(tcx.features().const_loop)
|
||||
}
|
||||
|
||||
fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
|
||||
// This should be caught by the HIR const-checker.
|
||||
item.tcx.sess.delay_span_bug(
|
||||
|
|
|
@ -390,8 +390,10 @@ fn check_terminator(
|
|||
cleanup: _,
|
||||
} => check_operand(tcx, cond, span, def_id, body),
|
||||
|
||||
TerminatorKind::FalseUnwind { .. } => {
|
||||
TerminatorKind::FalseUnwind { .. } if !tcx.features().const_loop => {
|
||||
Err((span, "loops are not allowed in const fn".into()))
|
||||
},
|
||||
|
||||
TerminatorKind::FalseUnwind { .. } => Ok(()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue