Skip to content

Commit 6612100

Browse files
committed
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
2 parents 0b9f19d + 8ee9711 commit 6612100

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,8 @@ fn check_terminator(
365365
cleanup: _,
366366
} => check_operand(tcx, mir, cond, span),
367367

368-
| TerminatorKind::FalseUnwind { .. } => span_bug!(
369-
terminator.source_info.span,
370-
"min_const_fn encountered `{:#?}`",
371-
terminator
372-
),
368+
TerminatorKind::FalseUnwind { .. } => {
369+
Err((span, "loops are not allowed in const fn".into()))
370+
},
373371
}
374372
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const fn foo() {
2+
loop {} //~ ERROR loops are not allowed in const fn
3+
}
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: loops are not allowed in const fn
2+
--> $DIR/loop_ice.rs:2:5
3+
|
4+
LL | loop {} //~ ERROR loops are not allowed in const fn
5+
| ^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)