rustc_utils::mir::body

Trait BodyExt

Source
pub trait BodyExt<'tcx> {
    // Required methods
    fn all_returns(&self) -> impl Iterator<Item = Location> + '_;
    fn all_locations(&self) -> impl Iterator<Item = Location> + '_;
    fn locations_in_block(
        &self,
        block: BasicBlock,
    ) -> impl Iterator<Item = Location>;
    fn debug_info_name_map(&self) -> HashMap<String, Local>;
    fn to_string(&self, tcx: TyCtxt<'tcx>) -> Result<String>;
    fn location_to_hir_id(&self, location: Location) -> HirId;
    fn source_info_to_hir_id(&self, info: &SourceInfo) -> HirId;
    fn control_dependencies(&self) -> ControlDependencies<BasicBlock>;
    fn async_context(
        &self,
        tcx: TyCtxt<'tcx>,
        def_id: DefId,
    ) -> Option<Ty<'tcx>>;
    fn all_places(
        &self,
        tcx: TyCtxt<'tcx>,
        def_id: DefId,
    ) -> impl Iterator<Item = Place<'tcx>> + '_;
    fn regions_in_args(&self) -> impl Iterator<Item = Region<'tcx>> + '_;
    fn regions_in_return(&self) -> impl Iterator<Item = Region<'tcx>> + '_;
}
Expand description

Extension trait for Body.

Required Methods§

Source

fn all_returns(&self) -> impl Iterator<Item = Location> + '_

Returns an iterator over the locations of TerminatorKind::Return instructions in a body.

Source

fn all_locations(&self) -> impl Iterator<Item = Location> + '_

Returns an iterator over all the locations in a body.

Source

fn locations_in_block( &self, block: BasicBlock, ) -> impl Iterator<Item = Location>

Returns all the locations in a BasicBlock.

Source

fn debug_info_name_map(&self) -> HashMap<String, Local>

Returns a mapping from source-level variable names to Locals.

Source

fn to_string(&self, tcx: TyCtxt<'tcx>) -> Result<String>

Converts a Body to a debug representation.

Source

fn location_to_hir_id(&self, location: Location) -> HirId

Returns the [HirId] corresponding to a MIR Location.

You MUST use the -Zmaximize-hir-to-mir-mapping flag for this function to work.

Source

fn source_info_to_hir_id(&self, info: &SourceInfo) -> HirId

Source

fn control_dependencies(&self) -> ControlDependencies<BasicBlock>

Returns all the control dependencies within the CFG.

See the control_dependencies module documentation for details.

Source

fn async_context(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Ty<'tcx>>

If this body is an async function, then return the type of the context that holds locals across await calls.

Source

fn all_places( &self, tcx: TyCtxt<'tcx>, def_id: DefId, ) -> impl Iterator<Item = Place<'tcx>> + '_

Returns an iterator over all projections of all local variables in the body.

Source

fn regions_in_args(&self) -> impl Iterator<Item = Region<'tcx>> + '_

Returns an iterator over all the regions that appear in argument types to the body.

Source

fn regions_in_return(&self) -> impl Iterator<Item = Region<'tcx>> + '_

Returns an iterator over all the regions that appear in the body’s return type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'tcx> BodyExt<'tcx> for Body<'tcx>

Source§

fn all_returns(&self) -> impl Iterator<Item = Location> + '_

Source§

fn all_locations(&self) -> impl Iterator<Item = Location> + '_

Source§

fn locations_in_block( &self, block: BasicBlock, ) -> impl Iterator<Item = Location>

Source§

fn debug_info_name_map(&self) -> HashMap<String, Local>

Source§

fn to_string(&self, tcx: TyCtxt<'tcx>) -> Result<String>

Source§

fn location_to_hir_id(&self, location: Location) -> HirId

Source§

fn source_info_to_hir_id(&self, info: &SourceInfo) -> HirId

Source§

fn control_dependencies(&self) -> ControlDependencies<BasicBlock>

Source§

fn async_context(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Ty<'tcx>>

Source§

fn regions_in_args(&self) -> impl Iterator<Item = Region<'tcx>> + '_

Source§

fn regions_in_return(&self) -> impl Iterator<Item = Region<'tcx>> + '_

Source§

fn all_places( &self, tcx: TyCtxt<'tcx>, def_id: DefId, ) -> impl Iterator<Item = Place<'tcx>> + '_

Implementors§