Skip to content

Commit a1aff18

Browse files
Allow Unreachable terminators unconditionally
1 parent d7afaa7 commit a1aff18

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ fn check_terminator(
344344
| TerminatorKind::FalseUnwind { .. }
345345
| TerminatorKind::Goto { .. }
346346
| TerminatorKind::Return
347-
| TerminatorKind::Resume => Ok(()),
347+
| TerminatorKind::Resume
348+
| TerminatorKind::Unreachable => Ok(()),
348349

349350
TerminatorKind::Drop { location, .. } => check_place(tcx, *location, span, def_id, body),
350351
TerminatorKind::DropAndReplace { location, value, .. } => {
@@ -360,12 +361,7 @@ fn check_terminator(
360361
check_operand(tcx, discr, span, def_id, body)
361362
}
362363

363-
// FIXME(ecstaticmorse): We probably want to allow `Unreachable` unconditionally.
364-
TerminatorKind::Unreachable if feature_allowed(tcx, def_id, sym::const_if_match) => Ok(()),
365-
366-
TerminatorKind::Abort | TerminatorKind::Unreachable => {
367-
Err((span, "const fn with unreachable code is not stable".into()))
368-
}
364+
TerminatorKind::Abort => Err((span, "abort is not stable in const fn".into())),
369365
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
370366
Err((span, "const fn generators are unstable".into()))
371367
}

0 commit comments

Comments
 (0)