abort in core #442
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
Contexts without access to
std
don't have a canonical way to writefn abort() -> !
. There should be one.Motivating examples or use cases
There are multiple ways of aborting the process without std currently, including:
core::intrinsics::abort
(unstable, illegal instruction)extern "C"
(panic in a function that cannot unwind)We should provide a simple way to abort that doesn't rely on directly causing a runtime error.
Solution sketch
abort_immediate
halts the process as abruptly as possible, usually by executing an illegal instruction. (This is the behavior of the abort intrinsic.)abort
uses a mechanism similar to core panic to raise the more user-friendly std abort when possible, orabort_immediate
otherwise. (This will require some new compiler/lang support.)Alternatives
abort
in core always do the intrinsic abort instead of a separateabort_immediate
.abort_immediate
differently (crash
,halt
, etc).Links and related work
abort_unwind
, and it's been noted twice already that it probably shouldn't be the nicest way to abort from core.What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: