Skip to content

Commit

Permalink
Allow Unreachable terminators unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Apr 29, 2020
1 parent d7afaa7 commit a1aff18
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ fn check_terminator(
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::Goto { .. }
| TerminatorKind::Return
| TerminatorKind::Resume => Ok(()),
| TerminatorKind::Resume
| TerminatorKind::Unreachable => Ok(()),

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

// FIXME(ecstaticmorse): We probably want to allow `Unreachable` unconditionally.
TerminatorKind::Unreachable if feature_allowed(tcx, def_id, sym::const_if_match) => Ok(()),

TerminatorKind::Abort | TerminatorKind::Unreachable => {
Err((span, "const fn with unreachable code is not stable".into()))
}
TerminatorKind::Abort => Err((span, "abort is not stable in const fn".into())),
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
Err((span, "const fn generators are unstable".into()))
}
Expand Down

0 comments on commit a1aff18

Please sign in to comment.