@@ -720,18 +720,22 @@ impl ByRef {
720
720
/// Used for both the explicit binding annotations given in the HIR for a binding
721
721
/// and the final binding mode that we infer after type inference/match ergonomics.
722
722
/// `.0` is the by-reference mode (`ref`, `ref mut`, or by value),
723
- /// `.1` is the mutability of the binding.
723
+ /// `.1` is the pinnedness of the binding,
724
+ /// `.2` is the mutability of the binding.
724
725
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
725
726
#[ derive( Encodable , Decodable , HashStable_Generic ) ]
726
- pub struct BindingMode ( pub ByRef , pub Mutability ) ;
727
+ pub struct BindingMode ( pub ByRef , pub Pinnedness , pub Mutability ) ;
727
728
728
729
impl BindingMode {
729
- pub const NONE : Self = Self ( ByRef :: No , Mutability :: Not ) ;
730
- pub const REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Mutability :: Not ) ;
731
- pub const MUT : Self = Self ( ByRef :: No , Mutability :: Mut ) ;
732
- pub const REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Mutability :: Not ) ;
733
- pub const MUT_REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Mutability :: Mut ) ;
734
- pub const MUT_REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Mutability :: Mut ) ;
730
+ pub const NONE : Self = Self ( ByRef :: No , Pinnedness :: Not , Mutability :: Not ) ;
731
+ pub const REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Pinnedness :: Not , Mutability :: Not ) ;
732
+ pub const MUT : Self = Self ( ByRef :: No , Pinnedness :: Not , Mutability :: Mut ) ;
733
+ pub const REF_MUT : Self = Self ( ByRef :: Yes ( Mutability :: Mut ) , Pinnedness :: Not , Mutability :: Not ) ;
734
+ pub const MUT_REF : Self = Self ( ByRef :: Yes ( Mutability :: Not ) , Pinnedness :: Not , Mutability :: Mut ) ;
735
+ pub const MUT_REF_MUT : Self =
736
+ Self ( ByRef :: Yes ( Mutability :: Mut ) , Pinnedness :: Not , Mutability :: Mut ) ;
737
+ pub const PIN_CONST : Self = Self ( ByRef :: No , Pinnedness :: Pinned , Mutability :: Not ) ;
738
+ pub const PIN_MUT : Self = Self ( ByRef :: No , Pinnedness :: Pinned , Mutability :: Mut ) ;
735
739
736
740
pub fn prefix_str ( self ) -> & ' static str {
737
741
match self {
@@ -741,6 +745,9 @@ impl BindingMode {
741
745
Self :: REF_MUT => "ref mut " ,
742
746
Self :: MUT_REF => "mut ref " ,
743
747
Self :: MUT_REF_MUT => "mut ref mut " ,
748
+ Self :: PIN_CONST => "pin const " ,
749
+ Self :: PIN_MUT => "pin mut " ,
750
+ Self ( _, Pinnedness :: Pinned , _) => panic ! ( "unsupported pinned binding mode" ) ,
744
751
}
745
752
}
746
753
}
@@ -2604,7 +2611,9 @@ pub type ExplicitSelf = Spanned<SelfKind>;
2604
2611
impl Param {
2605
2612
/// Attempts to cast parameter to `ExplicitSelf`.
2606
2613
pub fn to_self ( & self ) -> Option < ExplicitSelf > {
2607
- if let PatKind :: Ident ( BindingMode ( ByRef :: No , mutbl) , ident, _) = self . pat . kind {
2614
+ if let PatKind :: Ident ( BindingMode ( ByRef :: No , Pinnedness :: Not , mutbl) , ident, _) =
2615
+ self . pat . kind
2616
+ {
2608
2617
if ident. name == kw:: SelfLower {
2609
2618
return match self . ty . kind {
2610
2619
TyKind :: ImplicitSelf => Some ( respan ( self . pat . span , SelfKind :: Value ( mutbl) ) ) ,
@@ -2659,7 +2668,11 @@ impl Param {
2659
2668
attrs,
2660
2669
pat : P ( Pat {
2661
2670
id : DUMMY_NODE_ID ,
2662
- kind : PatKind :: Ident ( BindingMode ( ByRef :: No , mutbl) , eself_ident, None ) ,
2671
+ kind : PatKind :: Ident (
2672
+ BindingMode ( ByRef :: No , Pinnedness :: Not , mutbl) ,
2673
+ eself_ident,
2674
+ None ,
2675
+ ) ,
2663
2676
span,
2664
2677
tokens : None ,
2665
2678
} ) ,
0 commit comments