Module interpret

Source
Expand description

An interpreter for MIR used in CTFE and by miri.

Modules§

allocation 🔒
The virtual memory representation of the MIR interpreter.
error 🔒
pointer 🔒
queries 🔒
value 🔒

Macros§

err_exhaust
err_inval
err_machine_stop
err_ub
err_ub_custom
err_ub_format
err_unsup
err_unsup_format
throw_exhaust
throw_inval
throw_machine_stop
throw_ub
throw_ub_custom
throw_ub_format
throw_unsup
throw_unsup_format

Structs§

AllocDecodingSession
AllocDecodingState
AllocId
AllocMap 🔒
AllocRange
The information that makes up a memory access: offset and size.
Allocation
This type represents an Allocation in the Miri/CTFE core engine.
BadBytesAccess
Details of an access to uninitialized bytes / bad pointer bytes where it is not allowed.
ConstAllocation
Interned types generally have an Outer type and an Inner type, where Outer is a newtype around Interned<Inner>, and all the operations are done on Outer, because all occurrences are interned. E.g. Ty is an outer type and TyKind is its inner type.
CtfeProvenance
The type of provenance in the compile-time interpreter. This is a packed representation of:
GlobalId
Uniquely identifies one of the following:
InitChunkIter
Yields InitChunks. See InitMask::range_as_init_chunks.
InterpErrorInfo
Packages the kind of error we got from the const code interpreter up with a Rust-level backtrace of where the error occurred. These should always be constructed by calling .into() on an InterpError. In rustc_mir::interpret, we have throw_err_* macros for this.
LitToConstInput
Input argument for tcx.lit_to_const.
Misalignment
Information about a misaligned pointer.
Pointer
Represents a pointer in the Miri engine.
ReportedErrorInfo
ScalarSizeMismatch
Information about a size mismatch.
ValidationErrorInfo

Enums§

AllocDiscriminant 🔒
AllocError
We have our own error type that does not know about the AllocId; that information is added when converting to InterpError.
AllocInit
Whether a new allocation should be initialized with zero-bytes.
CheckAlignMsg
Details of which pointer is not aligned.
CheckInAllocMsg
Details of why a pointer had to be in-bounds.
ErrorHandled
ExpectedKind
GlobalAlloc
An allocation in the global (tcx-managed) memory can be either a function pointer, a static, or a “real” allocation with some data in it.
InitChunk
A contiguous chunk of initialized or uninitialized memory.
InterpErrorKind
InvalidMetaKind
InvalidProgramInfo
Error information for when the program we executed turned out not to actually be a valid program. This cannot happen in stand-alone Miri (except for layout errors that are only detect during monomorphization), but it can happen during CTFE/ConstProp where we work on generic code or execution does not have all information available.
PointerKind
ResourceExhaustionInfo
Error information for when the program exhausted the resources granted to it by the interpreter.
Scalar
A Scalar represents an immediate, primitive value existing outside of a memory::Allocation. It is in many ways like a small chunk of an Allocation, up to 16 bytes in size. Like a range of bytes in an Allocation, a Scalar can either represent the raw bytes of a simple value or a pointer into another Allocation
State 🔒
UndefinedBehaviorInfo
Error information for when the program caused Undefined Behavior.
UnsupportedOpInfo
Error information for when the program did something that might (or might not) be correct to do according to the Rust spec, but due to limitations in the interpreter, the operation could not be carried out. These limitations can differ between CTFE and the Miri engine, e.g., CTFE does not support dereferencing pointers at integral addresses.
ValidationErrorKind

Constants§

CTFE_ALLOC_SALT

Traits§

AllocBytes
Functionality required for the bytes of an Allocation.
MachineStopType
A trait for machine-specific errors (or other “machine stop” conditions).
PointerArithmetic
Provenance
This trait abstracts over the kind of provenance that is associated with a Pointer. It is mostly opaque; the Machine trait extends it with some more operations that also have access to some global state. The Debug rendering is used to display bare provenance, and for the default impl of fmt.

Functions§

alloc_range
Free-starting constructor for less syntactic overhead.
interp_ok
read_target_uint
specialized_encode_alloc_id
write_target_uint

Type Aliases§

AllocResult
EvalStaticInitializerRawResult
EvalToAllocationRawResult
EvalToConstValueResult
EvalToValTreeResult
Ok(Err(ty)) indicates the constant was fine, but the valtree couldn’t be constructed because the value contains something of type ty that is not valtree-compatible. The caller can then show an appropriate error; the query does not have the necessary context to give good user-facing errors for this case.
InterpResult