Struct rustc_middle::mir::Body [−][src]
pub struct Body<'tcx> {Show fields
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
pub phase: MirPhase,
pub source: MirSource<'tcx>,
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
pub generator: Option<Box<GeneratorInfo<'tcx>>>,
pub local_decls: LocalDecls<'tcx>,
pub user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
pub arg_count: usize,
pub spread_arg: Option<Local>,
pub var_debug_info: Vec<VarDebugInfo<'tcx>>,
pub span: Span,
pub required_consts: Vec<Constant<'tcx>>,
pub is_polymorphic: bool,
predecessor_cache: PredecessorCache,
is_cyclic: GraphIsCyclicCache,
}Expand description
The lowered representation of a single function.
Fields
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>Expand description
A list of basic blocks. References to basic block use a newtyped index type BasicBlock
that indexes into this vector.
phase: MirPhaseExpand description
Records how far through the “desugaring and optimization” process this particular MIR has traversed. This is particularly useful when inlining, since in that context we instantiate the promoted constants and add them to our promoted vector – but those promoted items have already been optimized, whereas ours have not. This field allows us to see the difference and forego optimization on the inlined promoted items.
source: MirSource<'tcx>source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>Expand description
A list of source scopes; these are referenced by statements
and used for debuginfo. Indexed by a SourceScope.
generator: Option<Box<GeneratorInfo<'tcx>>>local_decls: LocalDecls<'tcx>Expand description
Declarations of locals.
The first local is the return value pointer, followed by arg_count
locals for the function arguments, followed by any user-declared
variables and temporaries.
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>Expand description
User type annotations.
arg_count: usizeExpand description
The number of arguments this function takes.
Starting at local 1, arg_count locals will be provided by the caller
and can be assumed to be initialized.
If this MIR was built for a constant, this will be 0.
spread_arg: Option<Local>Expand description
Mark an argument local (which must be a tuple) as getting passed as its individual components at the LLVM level.
This is used for the “rust-call” ABI.
var_debug_info: Vec<VarDebugInfo<'tcx>>Expand description
Debug information pertaining to user variables, including captures.
span: SpanExpand description
A span representing this MIR, for error reporting.
required_consts: Vec<Constant<'tcx>>Expand description
Constants that are required to evaluate successfully for this MIR to be well-formed. We hold in this field all the constants we are not able to evaluate yet.
is_polymorphic: boolExpand description
Does this body use generic parameters. This is used for the ConstEvaluatable check.
Note that this does not actually mean that this body is not computable right now.
The repeat count in the following example is polymorphic, but can still be evaluated
without knowing anything about the type parameter T.
fn test<T>() { let _ = [0; std::mem::size_of::<*mut T>()]; }
WARNING: Do not change this flags after the MIR was originally created, even if an optimization
removed the last mention of all generic params. We do not want to rely on optimizations and
potentially allow things like [u8; std::mem::size_of::<T>() * 0] due to this.
predecessor_cache: PredecessorCacheis_cyclic: GraphIsCyclicCacheImplementations
impl<'tcx> Body<'tcx>[src]
impl<'tcx> Body<'tcx>[src]pub fn new(
source: MirSource<'tcx>,
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
local_decls: LocalDecls<'tcx>,
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
arg_count: usize,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span,
generator_kind: Option<GeneratorKind>
) -> Self[src]
source: MirSource<'tcx>,
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
local_decls: LocalDecls<'tcx>,
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
arg_count: usize,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span,
generator_kind: Option<GeneratorKind>
) -> Self
pub fn new_cfg_only(
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>
) -> Self[src]
pub fn new_cfg_only(
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>
) -> Self[src]Returns a partially initialized MIR body containing only a list of basic blocks.
The returned MIR contains no LocalDecls (even for the return place) or source scopes. It
is only useful for testing but cannot be #[cfg(test)] because it is used in a different
crate.
pub fn basic_blocks(&self) -> &IndexVec<BasicBlock, BasicBlockData<'tcx>>[src]
pub fn basic_blocks_mut(
&mut self
) -> &mut IndexVec<BasicBlock, BasicBlockData<'tcx>>[src]
&mut self
) -> &mut IndexVec<BasicBlock, BasicBlockData<'tcx>>
pub fn basic_blocks_and_local_decls_mut(
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>)[src]
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>)
pub fn basic_blocks_local_decls_mut_and_var_debug_info(
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>, &mut Vec<VarDebugInfo<'tcx>>)[src]
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>, &mut Vec<VarDebugInfo<'tcx>>)
pub fn is_cfg_cyclic(&self) -> bool[src]
pub fn is_cfg_cyclic(&self) -> bool[src]Returns true if a cycle exists in the control-flow graph that is reachable from the
START_BLOCK.
pub fn local_kind(&self, local: Local) -> LocalKind[src]
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]
pub fn mut_vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]Returns an iterator over all user-declared mutable locals.
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]
pub fn mut_vars_and_args_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]Returns an iterator over all user-declared mutable arguments and locals.
pub fn args_iter(&self) -> impl Iterator<Item = Local> + ExactSizeIterator[src]
pub fn args_iter(&self) -> impl Iterator<Item = Local> + ExactSizeIterator[src]Returns an iterator over all function arguments.
pub fn vars_and_temps_iter(
&self
) -> impl DoubleEndedIterator<Item = Local> + ExactSizeIterator[src]
pub fn vars_and_temps_iter(
&self
) -> impl DoubleEndedIterator<Item = Local> + ExactSizeIterator[src]Returns an iterator over all user-defined variables and compiler-generated temporaries (all locals that are neither arguments nor the return place).
pub fn make_statement_nop(&mut self, location: Location)[src]
pub fn make_statement_nop(&mut self, location: Location)[src]Changes a statement to a nop. This is both faster than deleting instructions and avoids
invalidating statement indices in Locations.
pub fn source_info(&self, location: Location) -> &SourceInfo[src]
pub fn source_info(&self, location: Location) -> &SourceInfo[src]Returns the source info associated with location.
pub fn return_ty(&self) -> Ty<'tcx>[src]
pub fn return_ty(&self) -> Ty<'tcx>[src]Returns the return type; it always return first element from local_decls array.
pub fn terminator_loc(&self, bb: BasicBlock) -> Location[src]
pub fn terminator_loc(&self, bb: BasicBlock) -> Location[src]Gets the location of the terminator for the given block.
pub fn predecessors(&self) -> &IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>[src]
pub fn dominators(&self) -> Dominators<BasicBlock>[src]
pub fn yield_ty(&self) -> Option<Ty<'tcx>>[src]
pub fn generator_layout(&self) -> Option<&GeneratorLayout<'tcx>>[src]
pub fn generator_drop(&self) -> Option<&Body<'tcx>>[src]
pub fn generator_kind(&self) -> Option<GeneratorKind>[src]
Trait Implementations
impl<'tcx> ArenaAllocatable<'tcx, Body<'tcx>> for Body<'tcx>[src]
impl<'tcx> ArenaAllocatable<'tcx, Body<'tcx>> for Body<'tcx>[src]fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self[src]
fn allocate_from_iter<'a>(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = Self>
) -> &'a mut [Self]ⓘ[src]
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = Self>
) -> &'a mut [Self]ⓘ
impl<'tcx> DirectedGraph for Body<'tcx>[src]
impl<'tcx> DirectedGraph for Body<'tcx>[src]type Node = BasicBlock
impl<'graph, 'tcx> GraphPredecessors<'graph> for Body<'tcx>[src]
impl<'graph, 'tcx> GraphPredecessors<'graph> for Body<'tcx>[src]impl<'a, 'b> GraphSuccessors<'b> for Body<'a>[src]
impl<'a, 'b> GraphSuccessors<'b> for Body<'a>[src]impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx>[src]
impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx>[src]fn local_decls(&self) -> &LocalDecls<'tcx>[src]
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for Body<'tcx>[src]
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for Body<'tcx>[src]fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)[src]
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
impl<'tcx> Index<BasicBlock> for Body<'tcx>[src]
impl<'tcx> Index<BasicBlock> for Body<'tcx>[src]type Output = BasicBlockData<'tcx>
type Output = BasicBlockData<'tcx>The returned type after indexing.
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx>[src]
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx>[src]Performs the indexing (container[index]) operation. Read more
impl<'tcx> IndexMut<BasicBlock> for Body<'tcx>[src]
impl<'tcx> IndexMut<BasicBlock> for Body<'tcx>[src]fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx>[src]
fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx>[src]Performs the mutable indexing (container[index]) operation. Read more
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for Body<'tcx>[src]
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for Body<'tcx>[src]impl<'tcx> TypeFoldable<'tcx> for Body<'tcx>[src]
impl<'tcx> TypeFoldable<'tcx> for Body<'tcx>[src]fn super_fold_with<__F: TypeFolder<'tcx>>(self, __folder: &mut __F) -> Self[src]
fn super_visit_with<__F: TypeVisitor<'tcx>>(
&self,
__folder: &mut __F
) -> ControlFlow<__F::BreakTy>[src]
&self,
__folder: &mut __F
) -> ControlFlow<__F::BreakTy>
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self[src]
fn visit_with<V: TypeVisitor<'tcx>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>[src]
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool[src]
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool[src]Returns true if self has any late-bound regions that are either
bound by binder or bound by some binder outside of binder.
If binder is ty::INNERMOST, this indicates whether
there are any late-bound regions that appear free. Read more
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool[src]
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool[src]Returns true if this self has any regions that escape binder (and
hence are not bound by it). Read more
fn has_escaping_bound_vars(&self) -> bool[src]
fn has_type_flags(&self, flags: TypeFlags) -> bool[src]
fn has_projections(&self) -> bool[src]
fn has_opaque_types(&self) -> bool[src]
fn references_error(&self) -> bool[src]
fn has_param_types_or_consts(&self) -> bool[src]
fn has_infer_regions(&self) -> bool[src]
fn has_infer_types(&self) -> bool[src]
fn has_infer_types_or_consts(&self) -> bool[src]
fn needs_infer(&self) -> bool[src]
fn has_placeholders(&self) -> bool[src]
fn needs_subst(&self) -> bool[src]
fn has_free_regions(&self) -> bool[src]
fn has_free_regions(&self) -> bool[src]“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
fn has_erased_regions(&self) -> bool[src]
fn has_erasable_regions(&self) -> bool[src]
fn has_erasable_regions(&self) -> bool[src]True if there are any un-erased free regions.
fn is_global(&self) -> bool[src]
fn is_global(&self) -> bool[src]Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
fn has_late_bound_regions(&self) -> bool[src]
fn has_late_bound_regions(&self) -> bool[src]True if there are any late-bound regions
fn still_further_specializable(&self) -> bool[src]
fn still_further_specializable(&self) -> bool[src]Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
impl<'tcx> WithPredecessors for Body<'tcx>[src]
impl<'tcx> WithPredecessors for Body<'tcx>[src]fn predecessors(
&self,
node: Self::Node
) -> <Body<'tcx> as GraphPredecessors<'_>>::Iter[src]
&self,
node: Self::Node
) -> <Body<'tcx> as GraphPredecessors<'_>>::Iter
impl<'tcx> WithStartNode for Body<'tcx>[src]
impl<'tcx> WithStartNode for Body<'tcx>[src]fn start_node(&self) -> Self::Node[src]
impl<'tcx> WithSuccessors for Body<'tcx>[src]
impl<'tcx> WithSuccessors for Body<'tcx>[src]fn successors(
&self,
node: Self::Node
) -> <Body<'tcx> as GraphSuccessors<'_>>::Iter[src]
&self,
node: Self::Node
) -> <Body<'tcx> as GraphSuccessors<'_>>::Iter
fn depth_first_search(&self, from: Self::Node) -> DepthFirstSearch<'_, Self> where
Self: WithNumNodes, [src]
Self: WithNumNodes,
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for Body<'tcx>
impl<'tcx> !Send for Body<'tcx>
impl<'tcx> !Sync for Body<'tcx>
impl<'tcx> Unpin for Body<'tcx>
impl<'tcx> !UnwindSafe for Body<'tcx>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> MaybeResult<T> for T[src]
impl<T> MaybeResult<T> for T[src]impl<'tcx, T> Subst<'tcx> for T where
T: TypeFoldable<'tcx>, [src]
impl<'tcx, T> Subst<'tcx> for T where
T: TypeFoldable<'tcx>, [src]pub fn subst_spanned(Self, TyCtxt<'tcx>, &[GenericArg<'tcx>], Option<Span>) -> T[src]
fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> Self[src]
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,