Skip to main content

Fault

Struct Fault 

Source
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

Source

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.

Source

pub const KIND_SIZE: usize

The width of the kind, in bytes. See Fault::KIND_OFFSET.

Source

pub fn clear() -> Self

A fresh, clear fault record (no fault pending).

Source

pub fn set(&mut self, fault: RaisedFault)

Raise fault.

Takes a RaisedFault rather than a FaultKind so that “raise no fault” has no spelling.

Source

pub fn kind(&self) -> FaultKind

The pending fault kind, or FaultKind::None.

Source

pub fn is_pending(&self) -> bool

True iff a fault is pending.

Trait Implementations§

Source§

impl Default for Fault

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Fault

§

impl RefUnwindSafe for Fault

§

impl Send for Fault

§

impl Sync for Fault

§

impl Unpin for Fault

§

impl UnsafeUnpin for Fault

§

impl UnwindSafe for Fault

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.