Skip to content

Commit 98a2292

Browse files
Allow Abort terminators in a const-context
These appear along the cleanup path inside functions with `#[unwind(aborts)]`. We don't const-check the cleanup path anyways, since const-eval already has "abort-on-panic" semantics and there's often drops that would otherwise be forbidden, so the check wasn't really preventing anything anyways.
1 parent 8876ffc commit 98a2292

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ pub trait NonConstOp: std::fmt::Debug {
4141
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
4242
}
4343

44-
#[derive(Debug)]
45-
pub struct Abort;
46-
impl NonConstOp for Abort {
47-
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
48-
mcf_status_in_item(ccx)
49-
}
50-
51-
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
52-
mcf_build_error(ccx, span, "abort is not stable in const fn")
53-
}
54-
}
55-
5644
#[derive(Debug)]
5745
pub struct FloatingPointOp;
5846
impl NonConstOp for FloatingPointOp {

compiler/rustc_mir/src/transform/check_consts/validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,13 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
874874
}
875875

876876
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
877-
TerminatorKind::Abort => self.check_op(ops::Abort),
878877

879878
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
880879
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
881880
}
882881

883-
TerminatorKind::Assert { .. }
882+
TerminatorKind::Abort
883+
| TerminatorKind::Assert { .. }
884884
| TerminatorKind::FalseEdge { .. }
885885
| TerminatorKind::FalseUnwind { .. }
886886
| TerminatorKind::Goto { .. }

0 commit comments

Comments
 (0)