@@ -718,18 +718,22 @@ impl ByRef {
718718/// Used for both the explicit binding annotations given in the HIR for a binding
719719/// and the final binding mode that we infer after type inference/match ergonomics.
720720/// `.0` is the by-reference mode (`ref`, `ref mut`, or by value),
721- /// `.1` is the mutability of the binding.
721+ /// `.1` is the pinnedness of the binding,
722+ /// `.2` is the mutability of the binding.
722723#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
723724#[ derive( Encodable , Decodable , HashStable_Generic ) ]
724- pub struct BindingMode ( pub ByRef , pub Mutability ) ;
725+ pub struct BindingMode ( pub ByRef , pub Pinnedness , pub Mutability ) ;
725726
726727impl BindingMode {
727- pub const NONE : Self = Self ( ByRef :: No , Mutability :: Not ) ;
728- pub const REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Mutability :: Not ) ;
729- pub const MUT : Self = Self ( ByRef :: No , Mutability :: Mut ) ;
730- pub const REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Mutability :: Not ) ;
731- pub const MUT_REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Mutability :: Mut ) ;
732- pub const MUT_REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Mutability :: Mut ) ;
728+ pub const NONE : Self = Self ( ByRef :: No , Pinnedness :: Not , Mutability :: Not ) ;
729+ pub const REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Pinnedness :: Not , Mutability :: Not ) ;
730+ pub const MUT : Self = Self ( ByRef :: No , Pinnedness :: Not , Mutability :: Mut ) ;
731+ pub const REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Pinnedness :: Not , Mutability :: Not ) ;
732+ pub const MUT_REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Pinnedness :: Not , Mutability :: Mut ) ;
733+ pub const MUT_REF_MUT : Self =
734+ Self ( ByRef :: Yes ( Mutability :: Mut ) , Pinnedness :: Not , Mutability :: Mut ) ;
735+ pub const PIN_CONST : Self = Self ( ByRef :: No , Pinnedness :: Pinned , Mutability :: Not ) ;
736+ pub const PIN_MUT : Self = Self ( ByRef :: No , Pinnedness :: Pinned , Mutability :: Mut ) ;
733737
734738 pub fn prefix_str ( self ) -> & ' static str {
735739 match self {
@@ -739,6 +743,9 @@ impl BindingMode {
739743 Self :: REF_MUT => "ref mut " ,
740744 Self :: MUT_REF => "mut ref " ,
741745 Self :: MUT_REF_MUT => "mut ref mut " ,
746+ Self :: PIN_CONST => "pin const " ,
747+ Self :: PIN_MUT => "pin mut " ,
748+ Self ( _, Pinnedness :: Pinned , _) => panic ! ( "unsupported pinned binding mode" ) ,
742749 }
743750 }
744751}
@@ -2551,7 +2558,9 @@ pub type ExplicitSelf = Spanned<SelfKind>;
25512558impl Param {
25522559 /// Attempts to cast parameter to `ExplicitSelf`.
25532560 pub fn to_self ( & self ) -> Option < ExplicitSelf > {
2554- if let PatKind :: Ident ( BindingMode ( ByRef :: No , mutbl) , ident, _) = self . pat . kind {
2561+ if let PatKind :: Ident ( BindingMode ( ByRef :: No , Pinnedness :: Not , mutbl) , ident, _) =
2562+ self . pat . kind
2563+ {
25552564 if ident. name == kw:: SelfLower {
25562565 return match self . ty . kind {
25572566 TyKind :: ImplicitSelf => Some ( respan ( self . pat . span , SelfKind :: Value ( mutbl) ) ) ,
@@ -2606,7 +2615,11 @@ impl Param {
26062615 attrs,
26072616 pat : P ( Pat {
26082617 id : DUMMY_NODE_ID ,
2609- kind : PatKind :: Ident ( BindingMode ( ByRef :: No , mutbl) , eself_ident, None ) ,
2618+ kind : PatKind :: Ident (
2619+ BindingMode ( ByRef :: No , Pinnedness :: Not , mutbl) ,
2620+ eself_ident,
2621+ None ,
2622+ ) ,
26102623 span,
26112624 tokens : None ,
26122625 } ) ,
0 commit comments