Skip to content

Commit 25122d0

Browse files
Const-check the discriminant of a SwitchInt
1 parent 5c377f3 commit 25122d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,11 @@ fn check_terminator(
333333
span,
334334
"loops and conditional expressions are not stable in const fn".into(),
335335
)),
336-
| TerminatorKind::FalseEdges { .. }
337-
| TerminatorKind::SwitchInt { .. }
338-
=> Ok(()),
336+
337+
TerminatorKind::FalseEdges { .. } => Ok(()),
338+
TerminatorKind::SwitchInt { discr, switch_ty: _, values: _, targets: _ } => {
339+
check_operand(tcx, discr, span, def_id, body)
340+
}
339341

340342
| TerminatorKind::Abort | TerminatorKind::Unreachable => {
341343
Err((span, "const fn with unreachable code is not stable".into()))

0 commit comments

Comments
 (0)