Enum rustc_middle::mir::interpret::error::UndefinedBehaviorInfo
source · pub enum UndefinedBehaviorInfo {
Show 28 variants
Ub(String),
Unreachable,
BoundsCheckFailed {
len: u64,
index: u64,
},
DivisionByZero,
RemainderByZero,
DivisionOverflow,
RemainderOverflow,
PointerArithOverflow,
InvalidMeta(&'static str),
UnterminatedCString(Pointer),
PointerUseAfterFree(AllocId),
PointerOutOfBounds {
alloc_id: AllocId,
alloc_size: Size,
ptr_offset: i64,
ptr_size: Size,
msg: CheckInAllocMsg,
},
DanglingIntPointer(u64, CheckInAllocMsg),
AlignmentCheckFailed {
required: Align,
has: Align,
},
WriteToReadOnly(AllocId),
DerefFunctionPointer(AllocId),
DerefVTablePointer(AllocId),
ValidationFailure {
path: Option<String>,
msg: String,
},
InvalidBool(u8),
InvalidChar(u32),
InvalidTag(Scalar),
InvalidFunctionPointer(Pointer),
InvalidVTablePointer(Pointer),
InvalidStr(Utf8Error),
InvalidUninitBytes(Option<(AllocId, UninitBytesAccess)>),
DeadLocal,
ScalarSizeMismatch(ScalarSizeMismatch),
UninhabitedEnumVariantWritten,
}
Expand description
Error information for when the program caused Undefined Behavior.
Variants§
Ub(String)
Free-form case. Only for errors that are never caught!
Unreachable
Unreachable code was executed.
BoundsCheckFailed
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).
DivisionOverflow
Signed division overflowed (INT_MIN / -1).
RemainderOverflow
Signed remainder overflowed (INT_MIN % -1).
PointerArithOverflow
Overflowing inbounds pointer arithmetic.
InvalidMeta(&'static str)
Invalid metadata in a wide pointer (using str
to avoid allocations).
UnterminatedCString(Pointer)
Reading a C string that does not end within its allocation.
PointerUseAfterFree(AllocId)
Dereferencing a dangling pointer after it got freed.
PointerOutOfBounds
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(u64, CheckInAllocMsg)
Using an integer as a pointer in the wrong way.
AlignmentCheckFailed
Used a pointer with bad alignment.
WriteToReadOnly(AllocId)
Writing to read-only memory.
DerefFunctionPointer(AllocId)
DerefVTablePointer(AllocId)
ValidationFailure
Fields
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)
Using a non-boolean u8
as bool.
InvalidChar(u32)
Using a non-character u32
as character.
InvalidTag(Scalar)
The tag of an enum does not encode an actual discriminant.
InvalidFunctionPointer(Pointer)
Using a pointer-not-to-a-function as function pointer.
InvalidVTablePointer(Pointer)
Using a pointer-not-to-a-vtable as vtable pointer.
InvalidStr(Utf8Error)
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(ScalarSizeMismatch)
Data size is not equal to target size.
UninhabitedEnumVariantWritten
A discriminant of an uninhabited enum variant is written.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for UndefinedBehaviorInfo
impl Send for UndefinedBehaviorInfo
impl Sync for UndefinedBehaviorInfo
impl Unpin for UndefinedBehaviorInfo
impl UnwindSafe for UndefinedBehaviorInfo
Blanket Implementations§
source§impl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error(tcx: Tcx, _: &[QueryInfo]) -> T
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 bytesUnreachable
: 0 bytesBoundsCheckFailed
: 23 bytesDivisionByZero
: 0 bytesRemainderByZero
: 0 bytesDivisionOverflow
: 0 bytesRemainderOverflow
: 0 bytesPointerArithOverflow
: 0 bytesInvalidMeta
: 23 bytesUnterminatedCString
: 23 bytesPointerUseAfterFree
: 15 bytesPointerOutOfBounds
: 39 bytesDanglingIntPointer
: 15 bytesAlignmentCheckFailed
: 2 bytesWriteToReadOnly
: 15 bytesDerefFunctionPointer
: 15 bytesDerefVTablePointer
: 15 bytesValidationFailure
: 55 bytesInvalidBool
: 1 byteInvalidChar
: 7 bytesInvalidTag
: 31 bytesInvalidFunctionPointer
: 23 bytesInvalidVTablePointer
: 23 bytesInvalidStr
: 23 bytesInvalidUninitBytes
: 47 bytesDeadLocal
: 0 bytesScalarSizeMismatch
: 23 bytesUninhabitedEnumVariantWritten
: 0 bytes