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§
- Alloc
Decoding Session - Alloc
Decoding State - AllocId
- Alloc
Map 🔒 - Alloc
Range - The information that makes up a memory access: offset and size.
- Allocation
- This type represents an Allocation in the Miri/CTFE core engine.
- BadBytes
Access - Details of an access to uninitialized bytes / bad pointer bytes where it is not allowed.
- Const
Allocation - Interned types generally have an
Outer
type and anInner
type, whereOuter
is a newtype aroundInterned<Inner>
, and all the operations are done onOuter
, because all occurrences are interned. E.g.Ty
is an outer type andTyKind
is its inner type. - Ctfe
Provenance - The type of provenance in the compile-time interpreter. This is a packed representation of:
- Global
Id - Uniquely identifies one of the following:
- Init
Chunk Iter - Yields
InitChunk
s. SeeInitMask::range_as_init_chunks
. - Interp
Error Info - 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 anInterpError
. Inrustc_mir::interpret
, we havethrow_err_*
macros for this. - LitTo
Const Input - Input argument for
tcx.lit_to_const
. - Misalignment
- Information about a misaligned pointer.
- Pointer
- Represents a pointer in the Miri engine.
- Reported
Error Info - Scalar
Size Mismatch - Information about a size mismatch.
- Validation
Error Info
Enums§
- Alloc
Discriminant 🔒 - Alloc
Error - We have our own error type that does not know about the
AllocId
; that information is added when converting toInterpError
. - Alloc
Init - Whether a new allocation should be initialized with zero-bytes.
- Check
Align Msg - Details of which pointer is not aligned.
- Check
InAlloc Msg - Details of why a pointer had to be in-bounds.
- Error
Handled - Expected
Kind - Global
Alloc - 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.
- Init
Chunk - A contiguous chunk of initialized or uninitialized memory.
- Interp
Error Kind - Invalid
Meta Kind - Invalid
Program Info - 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.
- Pointer
Kind - Resource
Exhaustion Info - 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 amemory::Allocation
. It is in many ways like a small chunk of anAllocation
, up to 16 bytes in size. Like a range of bytes in anAllocation
, aScalar
can either represent the raw bytes of a simple value or a pointer into anotherAllocation
- State 🔒
- Undefined
Behavior Info - Error information for when the program caused Undefined Behavior.
- Unsupported
OpInfo - 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.
- Validation
Error Kind
Constants§
Traits§
- Alloc
Bytes - Functionality required for the bytes of an
Allocation
. - Machine
Stop Type - A trait for machine-specific errors (or other “machine stop” conditions).
- Pointer
Arithmetic - Provenance
- This trait abstracts over the kind of provenance that is associated with a
Pointer
. It is mostly opaque; theMachine
trait extends it with some more operations that also have access to some global state. TheDebug
rendering is used to display bare provenance, and for the default impl offmt
.
Functions§
- alloc_
range - Free-starting constructor for less syntactic overhead.
- interp_
ok - read_
target_ uint - specialized_
encode_ alloc_ id - write_
target_ uint
Type Aliases§
- Alloc
Result - Eval
Static Initializer RawResult - Eval
ToAllocation RawResult - Eval
ToConst Value Result - Eval
ToVal Tree Result Ok(Err(ty))
indicates the constant was fine, but the valtree couldn’t be constructed because the value contains something of typety
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.- Interp
Result