File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1640,6 +1640,14 @@ impl<'tcx> PlaceRef<'tcx> {
16401640 }
16411641 }
16421642
1643+ /// Returns `true` if this `Place` contains a `Deref` projection.
1644+ ///
1645+ /// If `Place::is_indirect` returns false, the caller knows that the `Place` refers to the
1646+ /// same region of memory as its base.
1647+ pub fn is_indirect ( & self ) -> bool {
1648+ self . projection . iter ( ) . any ( |elem| elem. is_indirect ( ) )
1649+ }
1650+
16431651 /// If MirPhase >= Derefered and if projection contains Deref,
16441652 /// It's guaranteed to be in the first place
16451653 pub fn has_deref ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -780,6 +780,10 @@ impl Map {
780780 tail_elem : Option < TrackElem > ,
781781 f : & mut impl FnMut ( PlaceIndex ) ,
782782 ) {
783+ if place. is_indirect ( ) {
784+ // We do not track indirect places.
785+ return ;
786+ }
783787 let Some ( & Some ( mut index) ) = self . locals . get ( place. local ) else {
784788 // The local is not tracked at all, so it does not alias anything.
785789 return ;
@@ -790,6 +794,9 @@ impl Map {
790794 . map ( |& elem| elem. try_into ( ) )
791795 . chain ( tail_elem. map ( Ok ) . into_iter ( ) ) ;
792796 for elem in elems {
797+ // A field aliases the parent place.
798+ f ( index) ;
799+
793800 let Ok ( elem) = elem else { return } ;
794801 let sub = self . apply ( index, elem) ;
795802 if let TrackElem :: Variant ( ..) | TrackElem :: Discriminant = elem {
You can’t perform that action at this time.
0 commit comments