add function to iterate through all sub-places, and add PlaceRef::ty
This commit is contained in:
parent
af309cc2d9
commit
df1c55a474
2 changed files with 18 additions and 0 deletions
|
@ -1741,6 +1741,15 @@ impl<'tcx> Place<'tcx> {
|
|||
pub fn as_ref(&self) -> PlaceRef<'tcx> {
|
||||
PlaceRef { local: self.local, projection: &self.projection }
|
||||
}
|
||||
|
||||
/// Iterate over the projections in evaluation order, i.e., the first element is the base with
|
||||
/// its projection and then subsequently more projections are added.
|
||||
pub fn iter_projections(self) -> impl Iterator<Item=(PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
|
||||
self.projection.iter().enumerate().map(move |(i, proj)| {
|
||||
let base = PlaceRef { local: self.local, projection: &self.projection[..i] };
|
||||
(base, proj)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Local> for Place<'_> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue