@@ -705,7 +705,7 @@ pub enum BindingForm<'tcx> {
705
705
/// Binding for a `self`/`&self`/`&mut self` binding where the type is implicit.
706
706
ImplicitSelf ( ImplicitSelfKind ) ,
707
707
/// Reference used in a guard expression to ensure immutability.
708
- RefForGuard ,
708
+ RefForGuard ( Local ) ,
709
709
}
710
710
711
711
TrivialTypeTraversalAndLiftImpls ! {
@@ -724,7 +724,7 @@ mod binding_form_impl {
724
724
match self {
725
725
Var ( binding) => binding. hash_stable ( hcx, hasher) ,
726
726
ImplicitSelf ( kind) => kind. hash_stable ( hcx, hasher) ,
727
- RefForGuard => ( ) ,
727
+ RefForGuard ( local ) => local . hash_stable ( hcx , hasher ) ,
728
728
}
729
729
}
730
730
}
@@ -955,7 +955,7 @@ impl<'tcx> LocalDecl<'tcx> {
955
955
/// expression that is used to access said variable for the guard of the
956
956
/// match arm.
957
957
pub fn is_ref_for_guard ( & self ) -> bool {
958
- matches ! ( self . local_info( ) , LocalInfo :: User ( BindingForm :: RefForGuard ) )
958
+ matches ! ( self . local_info( ) , LocalInfo :: User ( BindingForm :: RefForGuard ( _ ) ) )
959
959
}
960
960
961
961
/// Returns `Some` if this is a reference to a static item that is used to
@@ -1519,7 +1519,7 @@ impl<'tcx> StatementKind<'tcx> {
1519
1519
impl < V , T > ProjectionElem < V , T > {
1520
1520
/// Returns `true` if the target of this projection may refer to a different region of memory
1521
1521
/// than the base.
1522
- fn is_indirect ( & self ) -> bool {
1522
+ pub fn is_indirect ( & self ) -> bool {
1523
1523
match self {
1524
1524
Self :: Deref => true ,
1525
1525
@@ -1574,7 +1574,7 @@ impl<V, T> ProjectionElem<V, T> {
1574
1574
/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
1575
1575
pub type ProjectionKind = ProjectionElem < ( ) , ( ) > ;
1576
1576
1577
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
1577
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
1578
1578
pub struct PlaceRef < ' tcx > {
1579
1579
pub local : Local ,
1580
1580
pub projection : & ' tcx [ PlaceElem < ' tcx > ] ,
@@ -1661,6 +1661,13 @@ impl From<Local> for Place<'_> {
1661
1661
}
1662
1662
}
1663
1663
1664
+ impl From < Local > for PlaceRef < ' _ > {
1665
+ #[ inline]
1666
+ fn from ( local : Local ) -> Self {
1667
+ PlaceRef { local, projection : List :: empty ( ) }
1668
+ }
1669
+ }
1670
+
1664
1671
impl < ' tcx > PlaceRef < ' tcx > {
1665
1672
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
1666
1673
/// a single deref of a local.
@@ -1746,7 +1753,13 @@ impl<'tcx> PlaceRef<'tcx> {
1746
1753
1747
1754
impl Debug for Place < ' _ > {
1748
1755
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1749
- for elem in self . projection . iter ( ) . rev ( ) {
1756
+ Debug :: fmt ( & self . as_ref ( ) , fmt)
1757
+ }
1758
+ }
1759
+
1760
+ impl Debug for PlaceRef < ' _ > {
1761
+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1762
+ for & elem in self . projection . iter ( ) . rev ( ) {
1750
1763
match elem {
1751
1764
ProjectionElem :: OpaqueCast ( _)
1752
1765
| ProjectionElem :: Downcast ( _, _)
@@ -1764,7 +1777,7 @@ impl Debug for Place<'_> {
1764
1777
1765
1778
write ! ( fmt, "{:?}" , self . local) ?;
1766
1779
1767
- for elem in self . projection . iter ( ) {
1780
+ for & elem in self . projection . iter ( ) {
1768
1781
match elem {
1769
1782
ProjectionElem :: OpaqueCast ( ty) => {
1770
1783
write ! ( fmt, " as {})" , ty) ?;
0 commit comments