mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 22:16:53 +00:00
Replace the ICEing on const fn loops with an error
This commit is contained in:
parent
7e82eda000
commit
8ee9711a6c
@ -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()))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
5
src/test/ui/consts/min_const_fn/loop_ice.rs
Normal file
5
src/test/ui/consts/min_const_fn/loop_ice.rs
Normal file
@ -0,0 +1,5 @@
|
||||
const fn foo() {
|
||||
loop {} //~ ERROR loops are not allowed in const fn
|
||||
}
|
||||
|
||||
fn main() {}
|
8
src/test/ui/consts/min_const_fn/loop_ice.stderr
Normal file
8
src/test/ui/consts/min_const_fn/loop_ice.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user