Module rustc_middle::mir::interpret

source ·
Expand description

An interpreter for MIR used in CTFE and by miri.





  • We have our own error type that does not know about the AllocId; that information is added when converting to InterpError.
  • 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 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 🔒
  • 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.


  • 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; 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.


Type Aliases§