pub struct Fault { /* private fields */ }Expand description
The fault record a RuntimeContext points at. pending_fault is non-null
and points at the owning runtime’s slot.
The kind is the whole state. There is no pending: bool mirroring
kind != None beside it: one field cannot contradict itself, and generated
code branches on the kind word directly (ADR-102).
Implementations§
Source§impl Fault
impl Fault
Sourcepub const KIND_OFFSET: usize
pub const KIND_OFFSET: usize
Where the kind sits within the record, and how wide it is.
Generated code reads the kind directly (ADR-102). An
Inst::CheckFault is a load of ctx.pending_fault, a load of the kind
at this offset, and a brif — which works only because
FaultKind::None is 0 and every raisable kind is not, so the loaded
word is Fault::is_pending.
So a repr change to Fault or to FaultKind is a generated-code
change and owes a
RUNTIME_ABI_VERSION bump. The
backend asserts KIND_SIZE at compile time against the width it loads,
so a #[repr(u8)] or a #[repr(C)] that grows the enum fails the build
rather than reading three bytes of something else.
Both are minted here rather than reached for with offset_of! from the
backend because kind is private — the field is private so that
Fault::set is the only way to raise, which is what makes
“raise no fault” unspellable.
Sourcepub const KIND_SIZE: usize
pub const KIND_SIZE: usize
The width of the kind, in bytes. See Fault::KIND_OFFSET.
Sourcepub fn set(&mut self, fault: RaisedFault)
pub fn set(&mut self, fault: RaisedFault)
Raise fault.
Takes a RaisedFault rather than a FaultKind so that “raise no
fault” has no spelling.
Sourcepub fn kind(&self) -> FaultKind
pub fn kind(&self) -> FaultKind
The pending fault kind, or FaultKind::None.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
True iff a fault is pending.