Replace the ICEing on const fn loops with an error

This commit is contained in:
Oliver Scherer 2018-11-19 10:40:09 +01:00
parent 7e82eda000
commit 8ee9711a6c
3 changed files with 16 additions and 5 deletions

View File

@ -365,10 +365,8 @@ fn check_terminator(
cleanup: _,
} => check_operand(tcx, mir, cond, span),
| TerminatorKind::FalseUnwind { .. } => span_bug!(
terminator.source_info.span,
"min_const_fn encountered `{:#?}`",
terminator
),
TerminatorKind::FalseUnwind { .. } => {
Err((span, "loops are not allowed in const fn".into()))
},
}
}

View File

@ -0,0 +1,5 @@
const fn foo() {
loop {} //~ ERROR loops are not allowed in const fn
}
fn main() {}

View File

@ -0,0 +1,8 @@
error: loops are not allowed in const fn
--> $DIR/loop_ice.rs:2:5
|
LL | loop {} //~ ERROR loops are not allowed in const fn
| ^^^^^^^
error: aborting due to previous error