@@ -648,9 +648,10 @@ impl Pat {
648648 PatKind :: Path ( qself, path) => TyKind :: Path ( qself. clone ( ) , path. clone ( ) ) ,
649649 PatKind :: MacCall ( mac) => TyKind :: MacCall ( mac. clone ( ) ) ,
650650 // `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
651- PatKind :: Ref ( pat, mutbl) => {
652- pat. to_ty ( ) . map ( |ty| TyKind :: Ref ( None , MutTy { ty, mutbl : * mutbl } ) ) ?
653- }
651+ PatKind :: Ref ( pat, pinned, mutbl) => pat. to_ty ( ) . map ( |ty| match pinned {
652+ Pinnedness :: Not => TyKind :: Ref ( None , MutTy { ty, mutbl : * mutbl } ) ,
653+ Pinnedness :: Pinned => TyKind :: PinnedRef ( None , MutTy { ty, mutbl : * mutbl } ) ,
654+ } ) ?,
654655 // A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
655656 // when `P` can be reparsed as a type `T`.
656657 PatKind :: Slice ( pats) if let [ pat] = pats. as_slice ( ) => {
@@ -696,7 +697,7 @@ impl Pat {
696697 // Trivial wrappers over inner patterns.
697698 PatKind :: Box ( s)
698699 | PatKind :: Deref ( s)
699- | PatKind :: Ref ( s, _)
700+ | PatKind :: Ref ( s, _, _ )
700701 | PatKind :: Paren ( s)
701702 | PatKind :: Guard ( s, _) => s. walk ( it) ,
702703
@@ -717,7 +718,7 @@ impl Pat {
717718 /// Strip off all reference patterns (`&`, `&mut`) and return the inner pattern.
718719 pub fn peel_refs ( & self ) -> & Pat {
719720 let mut current = self ;
720- while let PatKind :: Ref ( inner, _) = & current. kind {
721+ while let PatKind :: Ref ( inner, _, _ ) = & current. kind {
721722 current = inner;
722723 }
723724 current
@@ -765,7 +766,9 @@ impl Pat {
765766 PatKind :: Missing => unreachable ! ( ) ,
766767 PatKind :: Wild => Some ( "_" . to_string ( ) ) ,
767768 PatKind :: Ident ( BindingMode :: NONE , ident, None ) => Some ( format ! ( "{ident}" ) ) ,
768- PatKind :: Ref ( pat, mutbl) => pat. descr ( ) . map ( |d| format ! ( "&{}{d}" , mutbl. prefix_str( ) ) ) ,
769+ PatKind :: Ref ( pat, pinned, mutbl) => {
770+ pat. descr ( ) . map ( |d| format ! ( "&{}{d}" , pinned. prefix_str( * mutbl) ) )
771+ }
769772 _ => None ,
770773 }
771774 }
@@ -913,7 +916,7 @@ pub enum PatKind {
913916 Deref ( Box < Pat > ) ,
914917
915918 /// A reference pattern (e.g., `&mut (a, b)`).
916- Ref ( Box < Pat > , Mutability ) ,
919+ Ref ( Box < Pat > , Pinnedness , Mutability ) ,
917920
918921 /// A literal, const block or path.
919922 Expr ( Box < Expr > ) ,
0 commit comments