@@ -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 ;
@@ -824,7 +824,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
824
824
825
825
// Determine the binding mode...
826
826
let bm = match user_bind_annot {
827
- BindingMode ( ByRef :: No , Mutability :: Mut ) if let ByRef :: Yes ( def_br_mutbl) = def_br => {
827
+ BindingMode ( ByRef :: No , pin, Mutability :: Mut )
828
+ if let ByRef :: Yes ( def_br_mutbl) = def_br =>
829
+ {
828
830
// Only mention the experimental `mut_ref` feature if if we're in edition 2024 and
829
831
// using other experimental matching features compatible with it.
830
832
if pat. span . at_least_rust_2024 ( )
@@ -841,7 +843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
841
843
. emit ( ) ;
842
844
}
843
845
844
- BindingMode ( def_br, Mutability :: Mut )
846
+ BindingMode ( def_br, pin , Mutability :: Mut )
845
847
} else {
846
848
// `mut` resets the binding mode on edition <= 2021
847
849
self . add_rust_2024_migration_desugared_pat (
@@ -850,11 +852,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
850
852
't' , // last char of `mut`
851
853
def_br_mutbl,
852
854
) ;
853
- BindingMode ( ByRef :: No , Mutability :: Mut )
855
+ BindingMode ( ByRef :: No , pin , Mutability :: Mut )
854
856
}
855
857
}
856
- BindingMode ( ByRef :: No , mutbl) => BindingMode ( def_br, mutbl) ,
857
- BindingMode ( ByRef :: Yes ( user_br_mutbl) , _) => {
858
+ BindingMode ( ByRef :: No , pin , mutbl) => BindingMode ( def_br, pin , mutbl) ,
859
+ BindingMode ( ByRef :: Yes ( user_br_mutbl) , _, _ ) => {
858
860
if let ByRef :: Yes ( def_br_mutbl) = def_br {
859
861
// `ref`/`ref mut` overrides the binding mode on edition <= 2021
860
862
self . add_rust_2024_migration_desugared_pat (
@@ -1079,7 +1081,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1079
1081
if let PatKind :: Ref ( the_ref, _) = i. kind
1080
1082
&& let PatKind :: Binding ( mt, _, ident, _) = the_ref. kind
1081
1083
{
1082
- let BindingMode ( _, mtblty) = mt;
1084
+ let BindingMode ( _, _ , mtblty) = mt;
1083
1085
err. span_suggestion_verbose (
1084
1086
i. span ,
1085
1087
format ! ( "consider removing `&{mutability}` from the pattern" ) ,
@@ -2872,8 +2874,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2872
2874
// If the user-provided binding modifier doesn't match the default binding mode, we'll
2873
2875
// need to suggest reference patterns, which can affect other bindings.
2874
2876
// For simplicity, we opt to suggest making the pattern fully explicit.
2875
- info. suggest_eliding_modes &=
2876
- user_bind_annot == BindingMode ( ByRef :: Yes ( def_br_mutbl) , Mutability :: Not ) ;
2877
+ info. suggest_eliding_modes &= user_bind_annot
2878
+ == BindingMode ( ByRef :: Yes ( def_br_mutbl) , Pinnedness :: Not , Mutability :: Not ) ;
2877
2879
"binding modifier"
2878
2880
} else {
2879
2881
info. bad_ref_pats = true ;
0 commit comments