Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 5 additions & 0 deletions src/test/ui/consts/min_const_fn/loop_ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fn foo() {
loop {} //~ ERROR loops are not allowed in const fn
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/consts/min_const_fn/loop_ice.stderr
Original file line number Diff line number Diff line change
@@ -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