Skip to content

Commit dd6a838

Browse files
authored
Rollup merge of #68314 - oli-obk:true_unwind, r=eddyb
Stop treating `FalseEdges` and `FalseUnwind` as having semantic value for const eval This change does not expose loops or conditions to stable const fns because we check those at the HIR level and in the regular const validity checks. cc @ecstatic-morse r? @eddyb
2 parents 9d9c8c6 + cdc828e commit dd6a838

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,22 @@ fn check_terminator(
309309
) -> McfResult {
310310
let span = terminator.source_info.span;
311311
match &terminator.kind {
312-
TerminatorKind::Goto { .. } | TerminatorKind::Return | TerminatorKind::Resume => Ok(()),
312+
TerminatorKind::FalseEdges { .. }
313+
| TerminatorKind::FalseUnwind { .. }
314+
| TerminatorKind::Goto { .. }
315+
| TerminatorKind::Return
316+
| TerminatorKind::Resume => Ok(()),
313317

314318
TerminatorKind::Drop { location, .. } => check_place(tcx, location, span, def_id, body),
315319
TerminatorKind::DropAndReplace { location, value, .. } => {
316320
check_place(tcx, location, span, def_id, body)?;
317321
check_operand(tcx, value, span, def_id, body)
318322
}
319323

320-
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. }
321-
if !feature_allowed(tcx, def_id, sym::const_if_match) =>
322-
{
324+
TerminatorKind::SwitchInt { .. } if !feature_allowed(tcx, def_id, sym::const_if_match) => {
323325
Err((span, "loops and conditional expressions are not stable in const fn".into()))
324326
}
325327

326-
TerminatorKind::FalseEdges { .. } => Ok(()),
327328
TerminatorKind::SwitchInt { discr, switch_ty: _, values: _, targets: _ } => {
328329
check_operand(tcx, discr, span, def_id, body)
329330
}
@@ -367,13 +368,5 @@ fn check_terminator(
367368
TerminatorKind::Assert { cond, expected: _, msg: _, target: _, cleanup: _ } => {
368369
check_operand(tcx, cond, span, def_id, body)
369370
}
370-
371-
TerminatorKind::FalseUnwind { .. } if feature_allowed(tcx, def_id, sym::const_loop) => {
372-
Ok(())
373-
}
374-
375-
TerminatorKind::FalseUnwind { .. } => {
376-
Err((span, "loops are not allowed in const fn".into()))
377-
}
378371
}
379372
}

0 commit comments

Comments
 (0)