Complete for_each_aliasing_place.
This commit is contained in:
parent
9af191f86f
commit
67a8c16fe2
@ -1640,6 +1640,14 @@ pub fn local_or_deref_local(&self) -> Option<Local> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this `Place` contains a `Deref` projection.
|
||||
///
|
||||
/// If `Place::is_indirect` returns false, the caller knows that the `Place` refers to the
|
||||
/// same region of memory as its base.
|
||||
pub fn is_indirect(&self) -> bool {
|
||||
self.projection.iter().any(|elem| elem.is_indirect())
|
||||
}
|
||||
|
||||
/// If MirPhase >= Derefered and if projection contains Deref,
|
||||
/// It's guaranteed to be in the first place
|
||||
pub fn has_deref(&self) -> bool {
|
||||
|
@ -780,6 +780,10 @@ pub fn for_each_aliasing_place(
|
||||
tail_elem: Option<TrackElem>,
|
||||
f: &mut impl FnMut(PlaceIndex),
|
||||
) {
|
||||
if place.is_indirect() {
|
||||
// We do not track indirect places.
|
||||
return;
|
||||
}
|
||||
let Some(&Some(mut index)) = self.locals.get(place.local) else {
|
||||
// The local is not tracked at all, so it does not alias anything.
|
||||
return;
|
||||
@ -790,6 +794,9 @@ pub fn for_each_aliasing_place(
|
||||
.map(|&elem| elem.try_into())
|
||||
.chain(tail_elem.map(Ok).into_iter());
|
||||
for elem in elems {
|
||||
// A field aliases the parent place.
|
||||
f(index);
|
||||
|
||||
let Ok(elem) = elem else { return };
|
||||
let sub = self.apply(index, elem);
|
||||
if let TrackElem::Variant(..) | TrackElem::Discriminant = elem {
|
||||
|
Loading…
Reference in New Issue
Block a user