Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stop treating FalseEdges and FalseUnwind as having semantic value…
… for const eval
  • Loading branch information
oli-obk committed Jan 17, 2020
1 parent 2480c9e commit cdc828e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Expand Up @@ -309,21 +309,22 @@ fn check_terminator(
) -> McfResult {
let span = terminator.source_info.span;
match &terminator.kind {
TerminatorKind::Goto { .. } | TerminatorKind::Return | TerminatorKind::Resume => Ok(()),
TerminatorKind::FalseEdges { .. }
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::Goto { .. }
| TerminatorKind::Return
| TerminatorKind::Resume => Ok(()),

TerminatorKind::Drop { location, .. } => check_place(tcx, location, span, def_id, body),
TerminatorKind::DropAndReplace { location, value, .. } => {
check_place(tcx, location, span, def_id, body)?;
check_operand(tcx, value, span, def_id, body)
}

TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. }
if !feature_allowed(tcx, def_id, sym::const_if_match) =>
{
TerminatorKind::SwitchInt { .. } if !feature_allowed(tcx, def_id, sym::const_if_match) => {
Err((span, "loops and conditional expressions are not stable in const fn".into()))
}

TerminatorKind::FalseEdges { .. } => Ok(()),
TerminatorKind::SwitchInt { discr, switch_ty: _, values: _, targets: _ } => {
check_operand(tcx, discr, span, def_id, body)
}
Expand Down Expand Up @@ -367,13 +368,5 @@ fn check_terminator(
TerminatorKind::Assert { cond, expected: _, msg: _, target: _, cleanup: _ } => {
check_operand(tcx, cond, span, def_id, body)
}

TerminatorKind::FalseUnwind { .. } if feature_allowed(tcx, def_id, sym::const_loop) => {
Ok(())
}

TerminatorKind::FalseUnwind { .. } => {
Err((span, "loops are not allowed in const fn".into()))
}
}
}

0 comments on commit cdc828e

Please sign in to comment.