@@ -1592,14 +1592,13 @@ impl<'tcx> Place<'tcx> {
15921592 self . projection . iter ( ) . any ( |elem| elem. is_indirect ( ) )
15931593 }
15941594
1595- /// If MirPhase >= Derefered and if projection contains Deref,
1596- /// It's guaranteed to be in the first place
1597- pub fn has_deref ( & self ) -> bool {
1598- // To make sure this is not accidentally used in wrong mir phase
1599- debug_assert ! (
1600- self . projection. is_empty( ) || !self . projection[ 1 ..] . contains( & PlaceElem :: Deref )
1601- ) ;
1602- self . projection . first ( ) == Some ( & PlaceElem :: Deref )
1595+ /// Returns `true` if this `Place`'s first projection is `Deref`.
1596+ ///
1597+ /// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
1598+ /// `Deref` projections can only occur as the first projection. In that case this method
1599+ /// is equivalent to `is_indirect`, but faster.
1600+ pub fn is_indirect_first_projection ( & self ) -> bool {
1601+ self . as_ref ( ) . is_indirect_first_projection ( )
16031602 }
16041603
16051604 /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
@@ -1672,9 +1671,16 @@ impl<'tcx> PlaceRef<'tcx> {
16721671 self . projection . iter ( ) . any ( |elem| elem. is_indirect ( ) )
16731672 }
16741673
1675- /// If MirPhase >= Derefered and if projection contains Deref,
1676- /// It's guaranteed to be in the first place
1677- pub fn has_deref ( & self ) -> bool {
1674+ /// Returns `true` if this `Place`'s first projection is `Deref`.
1675+ ///
1676+ /// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
1677+ /// `Deref` projections can only occur as the first projection. In that case this method
1678+ /// is equivalent to `is_indirect`, but faster.
1679+ pub fn is_indirect_first_projection ( & self ) -> bool {
1680+ // To make sure this is not accidentally used in wrong mir phase
1681+ debug_assert ! (
1682+ self . projection. is_empty( ) || !self . projection[ 1 ..] . contains( & PlaceElem :: Deref )
1683+ ) ;
16781684 self . projection . first ( ) == Some ( & PlaceElem :: Deref )
16791685 }
16801686
0 commit comments