[−][src]Struct rustc_middle::mir::Body
The lowered representation of a single function.
Fields
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>A list of basic blocks. References to basic block use a newtyped index type BasicBlock
that indexes into this vector.
phase: MirPhaseRecords 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>>A list of source scopes; these are referenced by statements
and used for debuginfo. Indexed by a SourceScope.
yield_ty: Option<Ty<'tcx>>The yield type of the function, if it is a generator.
generator_drop: Option<Box<Body<'tcx>>>Generator drop glue.
generator_layout: Option<GeneratorLayout<'tcx>>The layout of a generator. Produced by the state transformation.
generator_kind: Option<GeneratorKind>If this is a generator then record the type of source expression that caused this generator to be created.
local_decls: IndexVec<Local, LocalDecl<'tcx>>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>User type annotations.
arg_count: usizeThe 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>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>>Debug information pertaining to user variables, including captures.
span: SpanA span representing this MIR, for error reporting.
required_consts: Vec<Constant<'tcx>>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: boolDoes 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: PredecessorCacheImplementations
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: IndexVec<Local, LocalDecl<'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: IndexVec<Local, LocalDecl<'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]
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>
) -> Self
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 IndexVec<Local, LocalDecl<'tcx>>)[src]
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut IndexVec<Local, LocalDecl<'tcx>>)
pub fn basic_blocks_local_decls_mut_and_var_debug_info(
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut IndexVec<Local, LocalDecl<'tcx>>, &mut Vec<VarDebugInfo<'tcx>>)[src]
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut IndexVec<Local, LocalDecl<'tcx>>, &mut Vec<VarDebugInfo<'tcx>>)
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 temps_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]
Returns an iterator over all temporaries.
pub fn vars_iter<'a>(&'a self) -> impl Iterator<Item = Local> + 'a[src]
Returns an iterator over all user-declared locals.
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]
Returns an iterator over all user-declared mutable arguments and locals.
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]
&self
) -> impl DoubleEndedIterator<Item = Local> + ExactSizeIterator
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]
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]
Returns the source info associated with location.
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]
Gets the location of the terminator for the given block.
pub fn predecessors(
&self
) -> impl Deref<Target = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>> + '_[src]
&self
) -> impl Deref<Target = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>> + '_
pub fn dominators(&self) -> Dominators<BasicBlock>[src]
Trait Implementations
impl<'tcx> ArenaAllocatable<'tcx, Body<'tcx>> for Body<'tcx>[src]
pub fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self[src]
pub 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> Clone for Body<'tcx>[src]
impl<'tcx> Debug for Body<'tcx>[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx Body<'tcx>[src]
impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for Body<'tcx>[src]
impl<'tcx> DirectedGraph for Body<'tcx>[src]
type Node = BasicBlock
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for &'tcx Body<'tcx>[src]
impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for Body<'tcx>[src]
impl<'graph, 'tcx> GraphPredecessors<'graph> for Body<'tcx>[src]
type Item = BasicBlock
type Iter = IntoIter<[BasicBlock; 4]>
impl<'a, 'b> GraphSuccessors<'b> for Body<'a>[src]
type Item = BasicBlock
type Iter = Cloned<Successors<'b>>
impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx>[src]
pub fn local_decls(&self) -> &IndexVec<Local, LocalDecl<'tcx>>[src]
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for Body<'tcx>[src]
pub 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]
type Output = BasicBlockData<'tcx>
The returned type after indexing.
pub fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx>[src]
impl<'tcx> IndexMut<BasicBlock> for Body<'tcx>[src]
pub fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx>[src]
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for Body<'tcx>[src]
impl<'tcx> TypeFoldable<'tcx> for Body<'tcx>[src]
pub fn super_fold_with<__F: TypeFolder<'tcx>>(self, __folder: &mut __F) -> Self[src]
pub fn super_visit_with<__F: TypeVisitor<'tcx>>(
&self,
__folder: &mut __F
) -> ControlFlow<__F::BreakTy>[src]
&self,
__folder: &mut __F
) -> ControlFlow<__F::BreakTy>
pub fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self[src]
pub fn visit_with<V: TypeVisitor<'tcx>>(
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>[src]
&self,
visitor: &mut V
) -> ControlFlow<V::BreakTy>
pub fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool[src]
pub fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool[src]
pub fn has_escaping_bound_vars(&self) -> bool[src]
pub fn has_type_flags(&self, flags: TypeFlags) -> bool[src]
pub fn has_projections(&self) -> bool[src]
pub fn has_opaque_types(&self) -> bool[src]
pub fn references_error(&self) -> bool[src]
pub fn has_param_types_or_consts(&self) -> bool[src]
pub fn has_infer_regions(&self) -> bool[src]
pub fn has_infer_types(&self) -> bool[src]
pub fn has_infer_types_or_consts(&self) -> bool[src]
pub fn needs_infer(&self) -> bool[src]
pub fn has_placeholders(&self) -> bool[src]
pub fn needs_subst(&self) -> bool[src]
pub fn has_free_regions(&self) -> bool[src]
pub fn has_erased_regions(&self) -> bool[src]
pub fn has_erasable_regions(&self) -> bool[src]
pub fn is_global(&self) -> bool[src]
pub fn has_late_bound_regions(&self) -> bool[src]
pub fn still_further_specializable(&self) -> bool[src]
impl<'tcx> WithNumNodes for Body<'tcx>[src]
impl<'tcx> WithPredecessors for Body<'tcx>[src]
pub fn predecessors(&self, node: Self::Node) -> Self::Iter[src]
impl<'tcx> WithStartNode for Body<'tcx>[src]
pub fn start_node(&self) -> Self::Node[src]
impl<'tcx> WithSuccessors for Body<'tcx>[src]
pub fn successors(&self, node: Self::Node) -> Self::Iter[src]
pub 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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<'tcx, T> Subst<'tcx> for T where
T: TypeFoldable<'tcx>, [src]
T: TypeFoldable<'tcx>,
pub fn subst_spanned(Self, TyCtxt<'tcx>, &[GenericArg<'tcx>], Option<Span>) -> T[src]
pub fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> Self[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.