Type Alias AssertMessage

Source
pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
Expand description

Type for MIR Assert terminator error messages.

Aliased Type§

enum AssertMessage<'tcx> {
    BoundsCheck {
        len: Operand<'tcx>,
        index: Operand<'tcx>,
    },
    Overflow(BinOp, Operand<'tcx>, Operand<'tcx>),
    OverflowNeg(Operand<'tcx>),
    DivisionByZero(Operand<'tcx>),
    RemainderByZero(Operand<'tcx>),
    ResumedAfterReturn(CoroutineKind),
    ResumedAfterPanic(CoroutineKind),
    MisalignedPointerDereference {
        required: Operand<'tcx>,
        found: Operand<'tcx>,
    },
    NullPointerDereference,
}

Variants§

§

BoundsCheck

Fields

§len: Operand<'tcx>
§index: Operand<'tcx>
§

Overflow(BinOp, Operand<'tcx>, Operand<'tcx>)

§

OverflowNeg(Operand<'tcx>)

§

DivisionByZero(Operand<'tcx>)

§

RemainderByZero(Operand<'tcx>)

§

ResumedAfterReturn(CoroutineKind)

§

ResumedAfterPanic(CoroutineKind)

§

MisalignedPointerDereference

Fields

§required: Operand<'tcx>
§found: Operand<'tcx>
§

NullPointerDereference

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 56 bytes

Size for each variant:

  • BoundsCheck: 56 bytes
  • Overflow: 56 bytes
  • OverflowNeg: 32 bytes
  • DivisionByZero: 32 bytes
  • RemainderByZero: 32 bytes
  • ResumedAfterReturn: 10 bytes
  • ResumedAfterPanic: 10 bytes
  • MisalignedPointerDereference: 56 bytes
  • NullPointerDereference: 0 bytes

Implementations

Source§

impl<O> AssertKind<O>

Source

pub fn is_optional_overflow_check(&self) -> bool

Returns true if this an overflow checking assertion controlled by -C overflow-checks.

Source

pub fn panic_function(&self) -> LangItem

Get the lang item that is invoked to print a static message when this assert fires.

The caller is expected to handle BoundsCheck and MisalignedPointerDereference by invoking the appropriate lang item (panic_bounds_check/panic_misaligned_pointer_dereference) instead of printing a static message. Those have dynamic arguments that aren’t present for the rest of the messages here.

Source

pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> Result
where O: Debug,

Format the message arguments for the assert(cond, msg..) terminator in MIR printing.

Needs to be kept in sync with the run-time behavior (which is defined by AssertKind::panic_function and the lang items mentioned in its docs). Note that we deliberately show more details here than we do at runtime, such as the actual numbers that overflowed – it is much easier to do so here than at runtime.

Source

pub fn diagnostic_message(&self) -> DiagMessage

Format the diagnostic message for use in a lint (e.g. when the assertion fails during const-eval).

Needs to be kept in sync with the run-time behavior (which is defined by AssertKind::panic_function and the lang items mentioned in its docs). Note that we deliberately show more details here than we do at runtime, such as the actual numbers that overflowed – it is much easier to do so here than at runtime.

Source

pub fn add_args(self, adder: &mut dyn FnMut(DiagArgName, DiagArgValue))
where O: Debug,

Trait Implementations

Source§

impl<O: Clone> Clone for AssertKind<O>

Source§

fn clone(&self) -> AssertKind<O>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<O: Debug> Debug for AssertKind<O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<O, __D: TyDecoder> Decodable<__D> for AssertKind<O>
where O: Decodable<__D>,

Source§

fn decode(__decoder: &mut __D) -> Self

Source§

impl<O, __E: TyEncoder> Encodable<__E> for AssertKind<O>
where O: Encodable<__E>,

Source§

fn encode(&self, __encoder: &mut __E)

Source§

impl<O: Hash> Hash for AssertKind<O>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'__ctx, O> HashStable<StableHashingContext<'__ctx>> for AssertKind<O>
where O: HashStable<StableHashingContext<'__ctx>>,

Source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher, )

Source§

impl<O: PartialEq> PartialEq for AssertKind<O>

Source§

fn eq(&self, other: &AssertKind<O>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'tcx, O> TypeFoldable<TyCtxt<'tcx>> for AssertKind<O>
where O: TypeFoldable<TyCtxt<'tcx>>,

Source§

fn try_fold_with<__F: FallibleTypeFolder<TyCtxt<'tcx>>>( self, __folder: &mut __F, ) -> Result<Self, __F::Error>

The entry point for folding. To fold a value t with a folder f call: t.try_fold_with(f). Read more
Source§

fn fold_with<F>(self, folder: &mut F) -> Self
where F: TypeFolder<I>,

A convenient alternative to try_fold_with for use with infallible folders. Do not override this method, to ensure coherence with try_fold_with.
Source§

impl<'tcx, O> TypeVisitable<TyCtxt<'tcx>> for AssertKind<O>
where O: TypeVisitable<TyCtxt<'tcx>>,

Source§

fn visit_with<__V: TypeVisitor<TyCtxt<'tcx>>>( &self, __visitor: &mut __V, ) -> __V::Result

The entry point for visiting. To visit a value t with a visitor v call: t.visit_with(v). Read more
Source§

impl<O> StructuralPartialEq for AssertKind<O>