@@ -648,10 +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- }
654- // A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array ,
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+ } ) ? ,
655655 // when `P` can be reparsed as a type `T`.
656656 PatKind :: Slice ( pats) if let [ pat] = pats. as_slice ( ) => {
657657 pat. to_ty ( ) . map ( TyKind :: Slice ) ?
@@ -696,7 +696,7 @@ impl Pat {
696696 // Trivial wrappers over inner patterns.
697697 PatKind :: Box ( s)
698698 | PatKind :: Deref ( s)
699- | PatKind :: Ref ( s, _)
699+ | PatKind :: Ref ( s, _, _ )
700700 | PatKind :: Paren ( s)
701701 | PatKind :: Guard ( s, _) => s. walk ( it) ,
702702
@@ -756,7 +756,9 @@ impl Pat {
756756 PatKind :: Missing => unreachable ! ( ) ,
757757 PatKind :: Wild => Some ( "_" . to_string ( ) ) ,
758758 PatKind :: Ident ( BindingMode :: NONE , ident, None ) => Some ( format ! ( "{ident}" ) ) ,
759- PatKind :: Ref ( pat, mutbl) => pat. descr ( ) . map ( |d| format ! ( "&{}{d}" , mutbl. prefix_str( ) ) ) ,
759+ PatKind :: Ref ( pat, pinned, mutbl) => {
760+ pat. descr ( ) . map ( |d| format ! ( "&{}{d}" , pinned. prefix_str( * mutbl) ) )
761+ }
760762 _ => None ,
761763 }
762764 }
@@ -904,7 +906,7 @@ pub enum PatKind {
904906 Deref ( Box < Pat > ) ,
905907
906908 /// A reference pattern (e.g., `&mut (a, b)`).
907- Ref ( Box < Pat > , Mutability ) ,
909+ Ref ( Box < Pat > , Pinnedness , Mutability ) ,
908910
909911 /// A literal, const block or path.
910912 Expr ( Box < Expr > ) ,
0 commit comments