Trait rustc_utils::mir::place::PlaceExt
source · 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§
type RefsInProjectionIter<'a>: Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])> where Self: 'a
Required Methods§
sourcefn make(local: Local, projection: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self
fn make(local: Local, projection: &[PlaceElem<'tcx>], tcx: TyCtxt<'tcx>) -> Self
Creates a new Place
.
sourcefn from_local(local: Local, tcx: TyCtxt<'tcx>) -> Self
fn from_local(local: Local, tcx: TyCtxt<'tcx>) -> Self
Creates a new Place
with an empty projection.
sourcefn is_arg(&self, body: &Body<'tcx>) -> bool
fn is_arg(&self, body: &Body<'tcx>) -> bool
Returns true if self
is a projection of an argument local.
sourcefn is_direct(&self, body: &Body<'tcx>) -> bool
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.
sourcefn refs_in_projection(&self) -> Self::RefsInProjectionIter<'_>
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.
sourcefn interior_pointers(
&self,
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
def_id: DefId
) -> HashMap<RegionVid, Vec<(Place<'tcx>, Mutability)>>
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.
sourcefn interior_places(
&self,
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
def_id: DefId
) -> Vec<Place<'tcx>>
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
.
sourcefn interior_paths(
&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>>
Returns all possible projections of self
.
sourcefn to_string(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Option<String>
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.
sourcefn normalize(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Place<'tcx>
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.