@@ -1592,14 +1592,13 @@ impl<'tcx> Place<'tcx> {
1592
1592
self . projection . iter ( ) . any ( |elem| elem. is_indirect ( ) )
1593
1593
}
1594
1594
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 ( )
1603
1602
}
1604
1603
1605
1604
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
@@ -1672,9 +1671,16 @@ impl<'tcx> PlaceRef<'tcx> {
1672
1671
self . projection . iter ( ) . any ( |elem| elem. is_indirect ( ) )
1673
1672
}
1674
1673
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
+ ) ;
1678
1684
self . projection . first ( ) == Some ( & PlaceElem :: Deref )
1679
1685
}
1680
1686
0 commit comments