@@ -705,7 +705,7 @@ pub enum BindingForm<'tcx> {
705705 /// Binding for a `self`/`&self`/`&mut self` binding where the type is implicit.
706706 ImplicitSelf ( ImplicitSelfKind ) ,
707707 /// Reference used in a guard expression to ensure immutability.
708- RefForGuard ,
708+ RefForGuard ( Local ) ,
709709}
710710
711711TrivialTypeTraversalAndLiftImpls ! {
@@ -724,7 +724,7 @@ mod binding_form_impl {
724724 match self {
725725 Var ( binding) => binding. hash_stable ( hcx, hasher) ,
726726 ImplicitSelf ( kind) => kind. hash_stable ( hcx, hasher) ,
727- RefForGuard => ( ) ,
727+ RefForGuard ( local ) => local . hash_stable ( hcx , hasher ) ,
728728 }
729729 }
730730 }
@@ -955,7 +955,7 @@ impl<'tcx> LocalDecl<'tcx> {
955955 /// expression that is used to access said variable for the guard of the
956956 /// match arm.
957957 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 ( _ ) ) )
959959 }
960960
961961 /// Returns `Some` if this is a reference to a static item that is used to
@@ -1519,7 +1519,7 @@ impl<'tcx> StatementKind<'tcx> {
15191519impl < V , T > ProjectionElem < V , T > {
15201520 /// Returns `true` if the target of this projection may refer to a different region of memory
15211521 /// than the base.
1522- fn is_indirect ( & self ) -> bool {
1522+ pub fn is_indirect ( & self ) -> bool {
15231523 match self {
15241524 Self :: Deref => true ,
15251525
@@ -1574,7 +1574,7 @@ impl<V, T> ProjectionElem<V, T> {
15741574/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
15751575pub type ProjectionKind = ProjectionElem < ( ) , ( ) > ;
15761576
1577- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
1577+ #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
15781578pub struct PlaceRef < ' tcx > {
15791579 pub local : Local ,
15801580 pub projection : & ' tcx [ PlaceElem < ' tcx > ] ,
@@ -1661,6 +1661,13 @@ impl From<Local> for Place<'_> {
16611661 }
16621662}
16631663
1664+ impl From < Local > for PlaceRef < ' _ > {
1665+ #[ inline]
1666+ fn from ( local : Local ) -> Self {
1667+ PlaceRef { local, projection : List :: empty ( ) }
1668+ }
1669+ }
1670+
16641671impl < ' tcx > PlaceRef < ' tcx > {
16651672 /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
16661673 /// a single deref of a local.
@@ -1746,7 +1753,13 @@ impl<'tcx> PlaceRef<'tcx> {
17461753
17471754impl Debug for Place < ' _ > {
17481755 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 ( ) {
17501763 match elem {
17511764 ProjectionElem :: OpaqueCast ( _)
17521765 | ProjectionElem :: Downcast ( _, _)
@@ -1764,7 +1777,7 @@ impl Debug for Place<'_> {
17641777
17651778 write ! ( fmt, "{:?}" , self . local) ?;
17661779
1767- for elem in self . projection . iter ( ) {
1780+ for & elem in self . projection . iter ( ) {
17681781 match elem {
17691782 ProjectionElem :: OpaqueCast ( ty) => {
17701783 write ! ( fmt, " as {})" , ty) ?;
0 commit comments