@@ -718,18 +718,22 @@ impl ByRef {
718
718
/// Used for both the explicit binding annotations given in the HIR for a binding
719
719
/// and the final binding mode that we infer after type inference/match ergonomics.
720
720
/// `.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.
722
723
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
723
724
#[ derive( Encodable , Decodable , HashStable_Generic ) ]
724
- pub struct BindingMode ( pub ByRef , pub Mutability ) ;
725
+ pub struct BindingMode ( pub ByRef , pub Pinnedness , pub Mutability ) ;
725
726
726
727
impl 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 ) ;
733
737
734
738
pub fn prefix_str ( self ) -> & ' static str {
735
739
match self {
@@ -739,6 +743,9 @@ impl BindingMode {
739
743
Self :: REF_MUT => "ref mut " ,
740
744
Self :: MUT_REF => "mut ref " ,
741
745
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" ) ,
742
749
}
743
750
}
744
751
}
@@ -2551,7 +2558,9 @@ pub type ExplicitSelf = Spanned<SelfKind>;
2551
2558
impl Param {
2552
2559
/// Attempts to cast parameter to `ExplicitSelf`.
2553
2560
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
+ {
2555
2564
if ident. name == kw:: SelfLower {
2556
2565
return match self . ty . kind {
2557
2566
TyKind :: ImplicitSelf => Some ( respan ( self . pat . span , SelfKind :: Value ( mutbl) ) ) ,
@@ -2606,7 +2615,11 @@ impl Param {
2606
2615
attrs,
2607
2616
pat : P ( Pat {
2608
2617
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
+ ) ,
2610
2623
span,
2611
2624
tokens : None ,
2612
2625
} ) ,
0 commit comments