Auto merge of #56065 - oli-obk:min_const_fn_loop_ice, r=davidtwco

Replace the ICEing on const fn loops with an error

fixes #56035
This commit is contained in:
bors 2018-11-21 23:24:15 +00:00
commit 6612100de5
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