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§
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>, tcx: TyCtxt<'tcx>) -> bool
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 (*
) projectionsself
is the dereference of (a projection of) an argument tobody
- all dereferences in
self
are dereferences of aBox
Sourcefn refs_in_projection(
self,
body: &Body<'tcx>,
tcx: TyCtxt<'tcx>,
) -> impl Iterator<Item = (PlaceRef<'tcx>, &'tcx [PlaceElem<'tcx>])>
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.
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,
) -> HashSet<Place<'tcx>>
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
.
Sourcefn interior_paths(
&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>>
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.
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.