Enum rustc_middle::mir::interpret::error::UndefinedBehaviorInfo[][src]

pub enum UndefinedBehaviorInfo<'tcx> {
Show 27 variants Ub(String), Unreachable, BoundsCheckFailed { len: u64, index: u64, }, DivisionByZero, RemainderByZero, PointerArithOverflow, InvalidMeta(&'static str), InvalidVtableDropFn(FnSig<'tcx>), InvalidVtableSize, InvalidVtableAlignment(String), UnterminatedCString(Pointer), PointerUseAfterFree(AllocId), PointerOutOfBounds { alloc_id: AllocId, alloc_size: Size, ptr_offset: i64, ptr_size: Size, msg: CheckInAllocMsg, }, DanglingIntPointer(u64CheckInAllocMsg), AlignmentCheckFailed { required: Align, has: Align, }, WriteToReadOnly(AllocId), DerefFunctionPointer(AllocId), ValidationFailure { path: Option<String>, msg: String, }, InvalidBool(u8), InvalidChar(u32), InvalidTag(Scalar), InvalidFunctionPointer(Pointer), InvalidStr(Utf8Error), InvalidUninitBytes(Option<(AllocId, UninitBytesAccess)>), DeadLocal, ScalarSizeMismatch { target_size: u64, data_size: u64, }, UninhabitedEnumVariantWritten,
}
Expand description

Error information for when the program caused Undefined Behavior.

Variants

Ub(String)

Tuple Fields

0: String

Free-form case. Only for errors that are never caught!

Unreachable

Unreachable code was executed.

BoundsCheckFailed

Fields

len: u64
index: u64

A slice/array index projection went out-of-bounds.

DivisionByZero

Something was divided by 0 (x / 0).

RemainderByZero

Something was “remainded” by 0 (x % 0).

PointerArithOverflow

Overflowing inbounds pointer arithmetic.

InvalidMeta(&'static str)

Tuple Fields

0: &'static str

Invalid metadata in a wide pointer (using str to avoid allocations).

InvalidVtableDropFn(FnSig<'tcx>)

Tuple Fields

0: FnSig<'tcx>

Invalid drop function in vtable.

InvalidVtableSize

Invalid size in a vtable: too large.

InvalidVtableAlignment(String)

Tuple Fields

0: String

Invalid alignment in a vtable: too large, or not a power of 2.

UnterminatedCString(Pointer)

Tuple Fields

Reading a C string that does not end within its allocation.

PointerUseAfterFree(AllocId)

Tuple Fields

Dereferencing a dangling pointer after it got freed.

PointerOutOfBounds

Fields

alloc_id: AllocId
alloc_size: Size
ptr_offset: i64
ptr_size: Size

Used a pointer outside the bounds it is valid for. (If ptr_size > 0, determines the size of the memory range that was expected to be in-bounds.)

DanglingIntPointer(u64CheckInAllocMsg)

Tuple Fields

0: u64

Using an integer as a pointer in the wrong way.

AlignmentCheckFailed

Fields

required: Align
has: Align

Used a pointer with bad alignment.

WriteToReadOnly(AllocId)

Tuple Fields

Writing to read-only memory.

DerefFunctionPointer(AllocId)

Tuple Fields

ValidationFailure

Fields

path: Option<String>

The “path” to the value in question, e.g. .0[5].field for a struct field in the 6th element of an array that is the first element of a tuple.

msg: String

The value validity check found a problem. Should only be thrown by validity.rs and always point out which part of the value is the problem.

InvalidBool(u8)

Tuple Fields

0: u8

Using a non-boolean u8 as bool.

InvalidChar(u32)

Tuple Fields

0: u32

Using a non-character u32 as character.

InvalidTag(Scalar)

Tuple Fields

0: Scalar

The tag of an enum does not encode an actual discriminant.

InvalidFunctionPointer(Pointer)

Tuple Fields

Using a pointer-not-to-a-function as function pointer.

InvalidStr(Utf8Error)

Tuple Fields

Using a string that is not valid UTF-8,

InvalidUninitBytes(Option<(AllocId, UninitBytesAccess)>)

Using uninitialized data where it is not allowed.

DeadLocal

Working with a local that is not currently live.

ScalarSizeMismatch

Fields

target_size: u64
data_size: u64

Data size is not equal to target size.

UninhabitedEnumVariantWritten

A discriminant of an uninhabited enum variant is written.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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:

  • Ub: 31 bytes
  • Unreachable: 0 bytes
  • BoundsCheckFailed: 23 bytes
  • DivisionByZero: 0 bytes
  • RemainderByZero: 0 bytes
  • PointerArithOverflow: 0 bytes
  • InvalidMeta: 23 bytes
  • InvalidVtableDropFn: 23 bytes
  • InvalidVtableSize: 0 bytes
  • InvalidVtableAlignment: 31 bytes
  • UnterminatedCString: 23 bytes
  • PointerUseAfterFree: 15 bytes
  • PointerOutOfBounds: 39 bytes
  • DanglingIntPointer: 15 bytes
  • AlignmentCheckFailed: 2 bytes
  • WriteToReadOnly: 15 bytes
  • DerefFunctionPointer: 15 bytes
  • ValidationFailure: 55 bytes
  • InvalidBool: 1 byte
  • InvalidChar: 7 bytes
  • InvalidTag: 31 bytes
  • InvalidFunctionPointer: 23 bytes
  • InvalidStr: 23 bytes
  • InvalidUninitBytes: 47 bytes
  • DeadLocal: 0 bytes
  • ScalarSizeMismatch: 23 bytes
  • UninhabitedEnumVariantWritten: 0 bytes