Expand description
MIR datatypes and passes. See the rustc dev guide for more info.
Re-exports§
pub use self::graphviz::write_mir_graphviz;
pub use self::pretty::PassWhere;
pub use self::pretty::create_dump_file;
pub use self::pretty::display_allocation;
pub use self::pretty::dump_enabled;
pub use self::pretty::dump_mir;
pub use self::pretty::write_mir_pretty;
Modules§
- basic_
blocks 🔒 - binding_
form_ 🔒impl - consts 🔒
- coverage
- Metadata from source code coverage analysis and instrumentation.
- generic_
graph 🔒 - generic_
graphviz - graphviz
- interpret
- An interpreter for MIR used in CTFE and by miri.
- mono
- pretty
- query 🔒
- Values computed by queries that use MIR.
- size_
asserts 🔒 - statement 🔒
- Functionality for statements, operands, places, and things that appear in them.
- syntax 🔒
- This defines the syntax of MIR, i.e., the set of available MIR operations, and other definitions closely related to MIR semantics. This is in a dedicated file so that changes to this file can be reviewed more carefully. The intention is that this file only contains datatype declarations, no code.
- tcx
- Methods for the various MIR types. These are intended for use after building is complete.
- terminator 🔒
- Functionality for terminators and helper types that appear in terminators.
- traversal
- visit
- The MIR Visitor
Structs§
- Basic
Block - A node in the MIR control-flow graph.
- Basic
Block Data - Data for a basic block, including a list of its statements.
- Basic
Blocks - Block
Tail Info BlockTailInfo
is attached to theLocalDecl
for temporaries created during evaluation of expressions in a block tail expression; that is, a block like{ STMT_1; STMT_2; EXPR }
.- Body
- The lowered representation of a single function.
- Borrow
Check Result - Closure
Outlives Requirement - Indicates an outlives-constraint between a type or between two free regions declared on the closure.
- Closure
Outlives Subject Ty - Represents a
ty::Ty
for use inClosureOutlivesSubject
. - Closure
Region Requirements - After we borrow check a closure, we are left with various requirements that we have inferred between the free regions that appear in the closure’s signature or on its field types. These requirements are then verified and proved by the closure’s creating function. This struct encodes those requirements.
- Const
Alloc - Evaluated Constants
Represents the result of const evaluation via the
eval_to_allocation
query. Not to be confused withConstAllocation
, which directly refers to the underlying data! Here we indirect via anAllocId
. - Const
Operand - Const
Qualifs - The result of the
mir_const_qualif
query. - Copy
NonOverlapping - Coroutine
Info - Additional information carried by a MIR body when it is lowered from a coroutine.
This information is modified as it is lowered during the
StateTransform
MIR pass, so not all fields will be active at a given time. For example, theyield_ty
is taken out of the field after yields are turned into returns, and thecoroutine_drop
body is only populated after the state transform pass. - Coroutine
Layout - The layout of coroutine state.
- Coroutine
Saved Local - Coroutine
Saved Ty - Destructured
Constant - The constituent parts of a mir constant of kind ADT or array.
- Local
- Local
Decl - A MIR local.
- Location
Location
represents the position of the start of the statement; or, ifstatement_index
equals the number of statements, then the start of the terminator.- MirSource
- Where a specific
mir::Body
comes from. - Place
- Places roughly correspond to a “location in memory.” Places in MIR are the same mathematical object as places in Rust. This of course means that what exactly they are is undecided and part of the Rust memory model. However, they will likely contain at least the following pieces of information in some form:
- Place
Ref - Promoted
- Source
Info - Grouped information about the source code origin of a MIR entity. Intended to be inspected by diagnostics and debuginfo. Most passes can work with it as a whole, within a single function.
- Source
Scope - Source
Scope Data - Source
Scope Local Data - Statement
- A statement in a basic block, including information about its source code.
- Switch
Targets - Switch
Targets Iter - Terminator
- Unevaluated
Const - An unevaluated (potentially generic) constant used in MIR.
- User
Type Projection - Encodes the effect of a user-supplied type annotation on the
subcomponents of a pattern. The effect is determined by applying the
given list of projections to some underlying base type. Often,
the projection element list
projs
is empty, in which case this directly encodes a type inbase
. But in the case of complex patterns with subpatterns and bindings, we want to apply only a part of the type to a variable, in which case theprojs
vector is used. - User
Type Projections - A collection of projections into user types.
- VarBinding
Form - VarDebug
Info - Debug information pertaining to a user variable.
- VarDebug
Info Fragment
Enums§
- Aggregate
Kind - Analysis
Phase - See
MirPhase::Analysis
. - Annotation
Source - Assert
Kind - Information about an assertion failure.
- Backward
Incompatible Drop Reason - BinOp
- Binding
Form - Borrow
Kind - Call
Return Places - List of places that are written to after a successful (non-unwind) return
from a
Call
,Yield
orInlineAsm
. - Call
Source - Represents how a
TerminatorKind::Call
was constructed. Used only for diagnostics. - Cast
Kind - Clear
Cross Crate - Closure
Outlives Subject - The subject of a
ClosureOutlivesRequirement
– that is, the thing that must outlive some region. - Coercion
Source - Represents how a
CastKind::PointerCoercion
was constructed. Used only for diagnostics. - Const
- Constants
- Const
Value - Represents a constant value in Rust.
Scalar
andSlice
are optimizations for array length computations, enum discriminants and the pattern matching logic. - Constraint
Category - Outlives-constraints can be categorized to determine whether and why they are interesting (for error reporting). Order of variants indicates sort order of the category, thereby influencing diagnostic output.
- DefLocation
DefLocation
represents the location of a definition - either an argument or an assignment within MIR body.- Fake
Borrow Kind - Fake
Read Cause - The
FakeReadCause
describes the type of pattern why a FakeRead statement exists. - Inline
AsmMacro - The macro that an inline assembly block was created by
- Inline
AsmOperand - Local
Info - Extra information about a some locals that’s used for diagnostics and for classifying variables into local variables, statics, etc, which is needed e.g. for borrow checking.
- Local
Kind - Classifies locals into categories. See
Body::local_kind
. - Mentioned
Item - Some item that needs to monomorphize successfully for a MIR body to be considered well-formed.
- MirPhase
- Represents the “flavors” of MIR.
- MutBorrow
Kind - Mutability
- NonDiverging
Intrinsic - NullOp
- Operand
- An operand in MIR represents a “value” in Rust, the definition of which is undecided and part of the memory model. One proposal for a definition of values can be found on UCG.
- Projection
Elem - RawPtr
Kind - Retag
Kind - Describes what kind of retag is to be performed.
- Return
Constraint - Runtime
Phase - See
MirPhase::Runtime
. - Rvalue
- The various kinds of rvalues that can appear in MIR.
- Statement
Kind - The various kinds of statements that can appear in MIR.
- Terminator
Edges - Terminator
Kind - The various kinds of terminators, representing ways of exiting from a basic block.
- UnOp
- Unwind
Action - Action to be taken when a stack unwind happens.
- Unwind
Terminate Reason - The reason we are terminating the process during unwinding.
- VarDebug
Info Contents
Constants§
- OUTERMOST_
SOURCE_ SCOPE - RETURN_
PLACE - START_
BLOCK - TAG_
CLEAR_ 🔒CROSS_ CRATE_ CLEAR - TAG_
CLEAR_ 🔒CROSS_ CRATE_ SET
Traits§
Functions§
- find_
self_ call - Checks if the specified
local
is used as theself
parameter of a method call in the providedBasicBlock
. If it is, then theDefId
of the called method is returned. - graphviz_
safe_ def_ name
Type Aliases§
- Assert
Message - Type for MIR
Assert
terminator error messages. - Local
Decls - Types for locals
- Place
Elem - Alias for projections as they appear in places, where the base is a place and the index is a local.
- Projection
Kind - Alias for projections as they appear in
UserTypeProjection
, where we need neither theV
parameter forIndex
nor theT
forField
. - Successors
- Successors
Mut