pub trait PlaceExt<'tcx> {
    type RefsInProjectionIter<'a>: Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])>
       where Self: 'a;

    // 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>) -> bool;
    fn refs_in_projection(&self) -> Self::RefsInProjectionIter<'_>;
    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
    ) -> Vec<Place<'tcx>>;
    fn interior_paths(
        &self,
        tcx: TyCtxt<'tcx>,
        body: &Body<'tcx>,
        def_id: DefId
    ) -> Vec<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 Associated Types§

source

type RefsInProjectionIter<'a>: Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])> where Self: 'a

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>) -> bool

Returns true if self could not be resolved further to another place.

This is true of places with no dereferences in the projection, or of dereferences of arguments.

source

fn refs_in_projection(&self) -> Self::RefsInProjectionIter<'_>

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 ) -> Vec<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 ) -> Vec<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.

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>) -> bool

§

type RefsInProjectionIter<'a> = impl Iterator<Item = (PlaceRef<'tcx>, &'tcx [ProjectionElem<Local, Ty<'tcx>>])> + 'a where Self: 'a

source§

fn refs_in_projection(&self) -> Self::RefsInProjectionIter<'_>

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 ) -> Vec<Place<'tcx>>

source§

fn interior_paths( &self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId ) -> Vec<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§