@@ -12,7 +12,7 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
12
12
use rustc_hir:: pat_util:: EnumerateAndAdjustIterator ;
13
13
use rustc_hir:: {
14
14
self as hir, BindingMode , ByRef , ExprKind , HirId , LangItem , Mutability , Pat , PatExpr ,
15
- PatExprKind , PatKind , expr_needs_parens,
15
+ PatExprKind , PatKind , Pinnedness , expr_needs_parens,
16
16
} ;
17
17
use rustc_infer:: infer;
18
18
use rustc_middle:: traits:: PatternOriginExpr ;
@@ -812,7 +812,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
812
812
813
813
// Determine the binding mode...
814
814
let bm = match user_bind_annot {
815
- BindingMode ( ByRef :: No , Mutability :: Mut ) if let ByRef :: Yes ( def_br_mutbl) = def_br => {
815
+ BindingMode ( ByRef :: No , pin, Mutability :: Mut )
816
+ if let ByRef :: Yes ( def_br_mutbl) = def_br =>
817
+ {
816
818
// Only mention the experimental `mut_ref` feature if if we're in edition 2024 and
817
819
// using other experimental matching features compatible with it.
818
820
if pat. span . at_least_rust_2024 ( )
@@ -829,7 +831,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
829
831
. emit ( ) ;
830
832
}
831
833
832
- BindingMode ( def_br, Mutability :: Mut )
834
+ BindingMode ( def_br, pin , Mutability :: Mut )
833
835
} else {
834
836
// `mut` resets the binding mode on edition <= 2021
835
837
self . add_rust_2024_migration_desugared_pat (
@@ -838,11 +840,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
838
840
ident. span ,
839
841
def_br_mutbl,
840
842
) ;
841
- BindingMode ( ByRef :: No , Mutability :: Mut )
843
+ BindingMode ( ByRef :: No , pin , Mutability :: Mut )
842
844
}
843
845
}
844
- BindingMode ( ByRef :: No , mutbl) => BindingMode ( def_br, mutbl) ,
845
- BindingMode ( ByRef :: Yes ( _) , _) => {
846
+ BindingMode ( ByRef :: No , pin , mutbl) => BindingMode ( def_br, pin , mutbl) ,
847
+ BindingMode ( ByRef :: Yes ( _) , _, _ ) => {
846
848
if let ByRef :: Yes ( def_br_mutbl) = def_br {
847
849
// `ref`/`ref mut` overrides the binding mode on edition <= 2021
848
850
self . add_rust_2024_migration_desugared_pat (
@@ -1064,7 +1066,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1064
1066
if let PatKind :: Ref ( the_ref, _) = i. kind
1065
1067
&& let PatKind :: Binding ( mt, _, ident, _) = the_ref. kind
1066
1068
{
1067
- let BindingMode ( _, mtblty) = mt;
1069
+ let BindingMode ( _, _ , mtblty) = mt;
1068
1070
err. span_suggestion_verbose (
1069
1071
i. span ,
1070
1072
format ! ( "consider removing `&{mutability}` from the pattern" ) ,
@@ -2820,8 +2822,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2820
2822
// If the user-provided binding modifier doesn't match the default binding mode, we'll
2821
2823
// need to suggest reference patterns, which can affect other bindings.
2822
2824
// For simplicity, we opt to suggest making the pattern fully explicit.
2823
- info. suggest_eliding_modes &=
2824
- user_bind_annot == BindingMode ( ByRef :: Yes ( def_br_mutbl) , Mutability :: Not ) ;
2825
+ info. suggest_eliding_modes &= user_bind_annot
2826
+ == BindingMode ( ByRef :: Yes ( def_br_mutbl) , Pinnedness :: Not , Mutability :: Not ) ;
2825
2827
"binding modifier"
2826
2828
} else {
2827
2829
info. bad_ref_pats |= true ;
0 commit comments