rustc_utils::mir::place

Trait PlaceExt

Source
pub trait PlaceExt<'tcx> {
    // Required methods
    fn make(
        local: Local,
        projection: &[PlaceElem<'tcx>],
        tcx: TyCtxt<'tcx>,
    ) -> Self;
    fn from_ref(place: PlaceRef<'tcx>, tcx: TyCtxt<'tcx>) -> Self;
    fn from_local(local: Local, tcx: TyCtxt<'tcx>) -> Self;
    fn is_arg(&self, body: &Body<'tcx>) -> bool;
    fn is_direct(&self, body: &Body<'tcx>, tcx: TyCtxt<'tcx>) -> bool;
    fn refs_in_projection(
        self,
        body: &Body<'tcx>,
        tcx: TyCtxt<'tcx>,
    ) -> impl Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])>;
    fn interior_pointers(
        &self,
        tcx: TyCtxt<'tcx>,
        body: &Body<'tcx>,
        def_id: DefId,
    ) -> HashMap<RegionVid, Vec<(Place<'tcx>, Mutability)>>;
    fn interior_places(
        &self,
        tcx: TyCtxt<'tcx>,
        body: &Body<'tcx>,
        def_id: DefId,
    ) -> HashSet<Place<'tcx>>;
    fn interior_paths(
        &self,
        tcx: TyCtxt<'tcx>,
        body: &Body<'tcx>,
        def_id: DefId,
    ) -> HashSet<Place<'tcx>>;
    fn to_string(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Option<String>;
    fn normalize(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Place<'tcx>;
    fn is_source_visible(&self, tcx: TyCtxt<'_>, body: &Body<'_>) -> bool;
}
Expand description

Extension trait for Place.

Required Methods§

Source

fn make(local: Local, projection: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self

Creates a new Place.

Source

fn from_ref(place: PlaceRef<'tcx>, tcx: TyCtxt<'tcx>) -> Self

Converts a PlaceRef into an owned Place.

Source

fn from_local(local: Local, tcx: TyCtxt<'tcx>) -> Self

Creates a new Place with an empty projection.

Source

fn is_arg(&self, body: &Body<'tcx>) -> bool

Returns true if self is a projection of an argument local.

Source

fn is_direct(&self, body: &Body<'tcx>, tcx: TyCtxt<'tcx>) -> bool

Returns true if self cannot be resolved further to another place.

This is true if one of the following is true:

  • self contains no dereference (*) projections
  • self is the dereference of (a projection of) an argument to body
  • all dereferences in self are dereferences of a Box
Source

fn refs_in_projection( self, body: &Body<'tcx>, tcx: TyCtxt<'tcx>, ) -> impl Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])>

Returns an iterator over all prefixes of self’s projection that are references, along with the suffix of the remaining projection.

Source

fn interior_pointers( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashMap<RegionVid, Vec<(Place<'tcx>, Mutability)>>

Returns all possible projections of self that are references.

The output data structure groups the resultant places based on the region of the references.

Source

fn interior_places( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashSet<Place<'tcx>>

Returns all possible projections of self that do not go through a reference, i.e. the set of fields directly in the structure referred by self.

Source

fn interior_paths( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashSet<Place<'tcx>>

Returns all possible projections of self.

Source

fn to_string(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Option<String>

Returns a pretty representation of a place that uses debug info when available.

Source

fn normalize(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Place<'tcx>

Erases/normalizes information in a place to ensure stable comparisons between places.

Consider a place _1: &'1 <T as SomeTrait>::Foo[2]. We might encounter this type with a different region, e.g. &'2. We might encounter this type with a more specific type for the associated type, e.g. &'1 [i32][0]. To account for this variation, we normalize associated types, erase regions, and normalize projections.

Source

fn is_source_visible(&self, tcx: TyCtxt<'_>, body: &Body<'_>) -> bool

Returns true if this place’s base Local corresponds to code that is visible in the source.

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> PlaceExt<'tcx> for Place<'tcx>

Source§

fn make(local: Local, projection: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self

Source§

fn from_ref(place: PlaceRef<'tcx>, tcx: TyCtxt<'tcx>) -> Self

Source§

fn from_local(local: Local, tcx: TyCtxt<'tcx>) -> Self

Source§

fn is_arg(&self, body: &Body<'tcx>) -> bool

Source§

fn is_direct(&self, body: &Body<'tcx>, tcx: TyCtxt<'tcx>) -> bool

Source§

fn refs_in_projection( self, body: &Body<'tcx>, tcx: TyCtxt<'tcx>, ) -> impl Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])>

Source§

fn interior_pointers( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashMap<RegionVid, Vec<(Place<'tcx>, Mutability)>>

Source§

fn interior_places( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashSet<Place<'tcx>>

Source§

fn interior_paths( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> HashSet<Place<'tcx>>

Source§

fn to_string(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Option<String>

Source§

fn normalize(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Place<'tcx>

Source§

fn is_source_visible(&self, _tcx: TyCtxt<'_>, body: &Body<'_>) -> bool

Implementors§