mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
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:
commit
6612100de5
@ -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