Module rustc_middle::mir::interpret
source · Expand description
An interpreter for MIR used in CTFE and by miri.
Modules§
Macros§
Structs§
- Alloc
Map 🔒 - The information that makes up a memory access: offset and size.
- This type represents an Allocation in the Miri/CTFE core engine.
- Details of an access to uninitialized bytes / bad pointer bytes where it is not allowed.
- 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. - The type of provenance in the compile-time interpreter. This is a packed representation of an
AllocId
and animmutable: bool
. - Uniquely identifies one of the following:
- Yields
InitChunk
s. SeeInitMask::range_as_init_chunks
. - 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. - Input argument for
tcx.lit_to_const
. - Information about a misaligned pointer.
- Represents a pointer in the Miri engine.
- Information about a size mismatch.
Enums§
- We have our own error type that does not know about the
AllocId
; that information is added when converting toInterpError
. - Details of which pointer is not aligned.
- Details of why a pointer had to be in-bounds.
- 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.
- A contiguous chunk of initialized or uninitialized memory.
- 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.
- Error type for
tcx.lit_to_const
. - Error information for when the program exhausted the resources granted to it by the interpreter.
- 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 🔒
- Error information for when the program caused Undefined Behavior.
- 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.
Constants§
Traits§
- Functionality required for the bytes of an
Allocation
. - A trait for machine-specific errors (or other “machine stop” conditions).
- 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§
- Free-starting constructor for less syntactic overhead.
Type Aliases§
Ok(Err(ty))
indicates the constant was fine, but the valtree couldn’t be constructed because the value containts something of typety
that is not valtree-compatible. The caller can then show an appropriate error; the query does not have the necssary context to give good user-facing errors for this case.