Skip to content

Commit 753e682

Browse files
committed
parse pinned local variable declarations
1 parent f44efbf commit 753e682

File tree

50 files changed

+450
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+450
-93
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -720,18 +720,22 @@ impl ByRef {
720720
/// Used for both the explicit binding annotations given in the HIR for a binding
721721
/// and the final binding mode that we infer after type inference/match ergonomics.
722722
/// `.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.
724725
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
725726
#[derive(Encodable, Decodable, HashStable_Generic)]
726-
pub struct BindingMode(pub ByRef, pub Mutability);
727+
pub struct BindingMode(pub ByRef, pub Pinnedness, pub Mutability);
727728

728729
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);
735739

736740
pub fn prefix_str(self) -> &'static str {
737741
match self {
@@ -741,6 +745,9 @@ impl BindingMode {
741745
Self::REF_MUT => "ref mut ",
742746
Self::MUT_REF => "mut ref ",
743747
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"),
744751
}
745752
}
746753
}
@@ -2604,7 +2611,9 @@ pub type ExplicitSelf = Spanned<SelfKind>;
26042611
impl Param {
26052612
/// Attempts to cast parameter to `ExplicitSelf`.
26062613
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+
{
26082617
if ident.name == kw::SelfLower {
26092618
return match self.ty.kind {
26102619
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
@@ -2659,7 +2668,11 @@ impl Param {
26592668
attrs,
26602669
pat: P(Pat {
26612670
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+
),
26632676
span,
26642677
tokens: None,
26652678
}),

compiler/rustc_ast_ir/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,12 @@ pub enum Pinnedness {
8686
Not,
8787
Pinned,
8888
}
89+
90+
impl Pinnedness {
91+
pub fn is_pin(self) -> bool {
92+
matches!(self, Self::Pinned)
93+
}
94+
pub fn is_not(self) -> bool {
95+
matches!(self, Self::Not)
96+
}
97+
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
12781278
// Check if this is a binding pattern, if so, we can optimize and avoid adding a
12791279
// `let <pat> = __argN;` statement. In this case, we do not rename the parameter.
12801280
let (ident, is_simple_parameter) = match parameter.pat.kind {
1281-
hir::PatKind::Binding(hir::BindingMode(ByRef::No, _), _, ident, _) => (ident, true),
1281+
hir::PatKind::Binding(hir::BindingMode(ByRef::No, _, _), _, ident, _) => {
1282+
(ident, true)
1283+
}
12821284
// For `ref mut` or wildcard arguments, we can't reuse the binding, but
12831285
// we can keep the same name for the parameter.
12841286
// This lets rustdoc render it correctly in documentation.

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16291629
implicit_self: decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
16301630
let is_mutable_pat = matches!(
16311631
arg.pat.kind,
1632-
PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..)
1632+
PatKind::Ident(hir::BindingMode(_, _, Mutability::Mut), ..)
16331633
);
16341634

16351635
match &arg.ty.kind {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,10 @@ impl<'a> State<'a> {
16161616
match &pat.kind {
16171617
PatKind::Wild => self.word("_"),
16181618
PatKind::Never => self.word("!"),
1619-
PatKind::Ident(BindingMode(by_ref, mutbl), ident, sub) => {
1619+
PatKind::Ident(BindingMode(by_ref, pin, mutbl), ident, sub) => {
1620+
if pin.is_pin() {
1621+
self.word_nbsp("pin");
1622+
}
16201623
if mutbl.is_mut() {
16211624
self.word_nbsp("mut");
16221625
}

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
305305
{
306306
match *decl.local_info() {
307307
LocalInfo::User(BindingForm::Var(mir::VarBindingForm {
308-
binding_mode: BindingMode(ByRef::No, Mutability::Not),
308+
binding_mode: BindingMode(ByRef::No, _, Mutability::Not),
309309
opt_ty_info: Some(sp),
310310
opt_match_place: _,
311311
pat_span: _,
@@ -732,7 +732,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
732732
debug!("local_decl: {:?}", local_decl);
733733
let pat_span = match *local_decl.local_info() {
734734
LocalInfo::User(BindingForm::Var(mir::VarBindingForm {
735-
binding_mode: BindingMode(ByRef::No, Mutability::Not),
735+
binding_mode: BindingMode(ByRef::No, _, Mutability::Not),
736736
opt_ty_info: _,
737737
opt_match_place: _,
738738
pat_span,
@@ -1145,7 +1145,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11451145
}
11461146

11471147
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
1148-
binding_mode: BindingMode(ByRef::No, _),
1148+
binding_mode: BindingMode(ByRef::No, _, _),
11491149
opt_ty_info,
11501150
..
11511151
})) => {
@@ -1224,7 +1224,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
12241224
}
12251225

12261226
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
1227-
binding_mode: BindingMode(ByRef::Yes(_), _),
1227+
binding_mode: BindingMode(ByRef::Yes(_), _, _),
12281228
..
12291229
})) => {
12301230
let pattern_span: Span = local_decl.source_info.span;
@@ -1439,7 +1439,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symb
14391439
match *local_decl.local_info() {
14401440
// Check if mutably borrowing a mutable reference.
14411441
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
1442-
binding_mode: BindingMode(ByRef::No, Mutability::Not),
1442+
binding_mode: BindingMode(ByRef::No, _, Mutability::Not),
14431443
..
14441444
})) => matches!(local_decl.ty.kind(), ty::Ref(_, _, hir::Mutability::Mut)),
14451445
LocalInfo::User(mir::BindingForm::ImplicitSelf(kind)) => {

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub(crate) use SubstructureFields::*;
183183
use rustc_ast::ptr::P;
184184
use rustc_ast::{
185185
self as ast, AnonConst, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind,
186-
Generics, Mutability, PatKind, VariantData,
186+
Generics, Mutability, PatKind, Pinnedness, VariantData,
187187
};
188188
use rustc_attr_parsing as attr;
189189
use rustc_expand::base::{Annotatable, ExtCtxt};
@@ -1470,7 +1470,11 @@ impl<'a> TraitDef<'a> {
14701470
struct_field.ident,
14711471
cx.pat(
14721472
path.span,
1473-
PatKind::Ident(BindingMode(by_ref, Mutability::Not), path, None),
1473+
PatKind::Ident(
1474+
BindingMode(by_ref, Pinnedness::Not, Mutability::Not),
1475+
path,
1476+
None,
1477+
),
14741478
),
14751479
)
14761480
});

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::{
1111
};
1212
pub use rustc_ast::{
1313
BinOp, BinOpKind, BindingMode, BorrowKind, BoundConstness, BoundPolarity, ByRef, CaptureBy,
14-
ImplPolarity, IsAuto, Movability, Mutability, UnOp, UnsafeBinderCastKind,
14+
ImplPolarity, IsAuto, Movability, Mutability, Pinnedness, UnOp, UnsafeBinderCastKind,
1515
};
1616
use rustc_data_structures::fingerprint::Fingerprint;
1717
use rustc_data_structures::sorted_map::SortedMap;

compiler/rustc_hir/src/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl hir::Pat<'_> {
9595

9696
pub fn simple_ident(&self) -> Option<Ident> {
9797
match self.kind {
98-
PatKind::Binding(BindingMode(ByRef::No, _), _, ident, None) => Some(ident),
98+
PatKind::Binding(BindingMode(ByRef::No, _, _), _, ident, None) => Some(ident),
9999
_ => None,
100100
}
101101
}

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ fn resolve_local<'tcx>(
681681
// & expression, and its lifetime would be extended to the end of the block (due
682682
// to a different rule, not the below code).
683683
match pat.kind {
684-
PatKind::Binding(hir::BindingMode(hir::ByRef::Yes(_), _), ..) => true,
684+
PatKind::Binding(hir::BindingMode(hir::ByRef::Yes(_), _, _), ..) => true,
685685

686686
PatKind::Struct(_, field_pats, _) => field_pats.iter().any(|fp| is_binding_pat(fp.pat)),
687687

@@ -700,7 +700,7 @@ fn resolve_local<'tcx>(
700700
}
701701

702702
PatKind::Ref(_, _)
703-
| PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), ..)
703+
| PatKind::Binding(hir::BindingMode(hir::ByRef::No, _, _), ..)
704704
| PatKind::Wild
705705
| PatKind::Never
706706
| PatKind::Expr(_)

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,10 @@ impl<'a> State<'a> {
19131913
match pat.kind {
19141914
PatKind::Wild => self.word("_"),
19151915
PatKind::Never => self.word("!"),
1916-
PatKind::Binding(BindingMode(by_ref, mutbl), _, ident, sub) => {
1916+
PatKind::Binding(BindingMode(by_ref, pin, mutbl), _, ident, sub) => {
1917+
if pin.is_pin() {
1918+
self.word_nbsp("pin");
1919+
}
19171920
if mutbl.is_mut() {
19181921
self.word_nbsp("mut");
19191922
}

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
1212
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1313
use rustc_hir::{
1414
self as hir, BindingMode, ByRef, ExprKind, HirId, LangItem, Mutability, Pat, PatExpr,
15-
PatExprKind, PatKind, expr_needs_parens,
15+
PatExprKind, PatKind, Pinnedness, expr_needs_parens,
1616
};
1717
use rustc_infer::infer;
1818
use rustc_middle::traits::PatternOriginExpr;
@@ -812,7 +812,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
812812

813813
// Determine the binding mode...
814814
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+
{
816818
// Only mention the experimental `mut_ref` feature if if we're in edition 2024 and
817819
// using other experimental matching features compatible with it.
818820
if pat.span.at_least_rust_2024()
@@ -829,7 +831,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
829831
.emit();
830832
}
831833

832-
BindingMode(def_br, Mutability::Mut)
834+
BindingMode(def_br, pin, Mutability::Mut)
833835
} else {
834836
// `mut` resets the binding mode on edition <= 2021
835837
self.add_rust_2024_migration_desugared_pat(
@@ -838,11 +840,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
838840
ident.span,
839841
def_br_mutbl,
840842
);
841-
BindingMode(ByRef::No, Mutability::Mut)
843+
BindingMode(ByRef::No, pin, Mutability::Mut)
842844
}
843845
}
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(_), _, _) => {
846848
if let ByRef::Yes(def_br_mutbl) = def_br {
847849
// `ref`/`ref mut` overrides the binding mode on edition <= 2021
848850
self.add_rust_2024_migration_desugared_pat(
@@ -1064,7 +1066,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10641066
if let PatKind::Ref(the_ref, _) = i.kind
10651067
&& let PatKind::Binding(mt, _, ident, _) = the_ref.kind
10661068
{
1067-
let BindingMode(_, mtblty) = mt;
1069+
let BindingMode(_, _, mtblty) = mt;
10681070
err.span_suggestion_verbose(
10691071
i.span,
10701072
format!("consider removing `&{mutability}` from the pattern"),
@@ -2811,8 +2813,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28112813
// If the user-provided binding modifier doesn't match the default binding mode, we'll
28122814
// need to suggest reference patterns, which can affect other bindings.
28132815
// For simplicity, we opt to suggest making the pattern fully explicit.
2814-
info.suggest_eliding_modes &=
2815-
user_bind_annot == BindingMode(ByRef::Yes(def_br_mutbl), Mutability::Not);
2816+
info.suggest_eliding_modes &= user_bind_annot
2817+
== BindingMode(ByRef::Yes(def_br_mutbl), Pinnedness::Not, Mutability::Not);
28162818
"binding modifier"
28172819
} else {
28182820
info.bad_ref_pats = true;

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
276276
else {
277277
bug!();
278278
};
279-
let hir::PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), _, _, _) = pat.kind
279+
let hir::PatKind::Binding(hir::BindingMode(hir::ByRef::No, _, _), _, _, _) =
280+
pat.kind
280281
else {
281282
// Complex pattern, skip the non-upvar local.
282283
continue;
@@ -1802,7 +1803,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18021803

18031804
let bm = *typeck_results.pat_binding_modes().get(var_hir_id).expect("missing binding mode");
18041805

1805-
let mut is_mutbl = bm.1;
1806+
let mut is_mutbl = bm.2;
18061807

18071808
for pointer_ty in place.deref_tys() {
18081809
match self.structurally_resolve_type(self.tcx.hir().span(var_hir_id), pointer_ty).kind()

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ impl<'tcx> LocalDecl<'tcx> {
11211121
self.local_info(),
11221122
LocalInfo::User(
11231123
BindingForm::Var(VarBindingForm {
1124-
binding_mode: BindingMode(ByRef::No, _),
1124+
binding_mode: BindingMode(ByRef::No, _, _),
11251125
opt_ty_info: _,
11261126
opt_match_place: _,
11271127
pat_span: _,
@@ -1138,7 +1138,7 @@ impl<'tcx> LocalDecl<'tcx> {
11381138
self.local_info(),
11391139
LocalInfo::User(
11401140
BindingForm::Var(VarBindingForm {
1141-
binding_mode: BindingMode(ByRef::No, _),
1141+
binding_mode: BindingMode(ByRef::No, _, _),
11421142
opt_ty_info: _,
11431143
opt_match_place: _,
11441144
pat_span: _,

compiler/rustc_middle/src/thir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ impl<'tcx> Pat<'tcx> {
633633
pub fn simple_ident(&self) -> Option<Symbol> {
634634
match self.kind {
635635
PatKind::Binding {
636-
name, mode: BindingMode(ByRef::No, _), subpattern: None, ..
636+
name, mode: BindingMode(ByRef::No, _, _), subpattern: None, ..
637637
} => Some(name),
638638
_ => None,
639639
}

compiler/rustc_middle/src/ty/typeck_results.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<'tcx> TypeckResults<'tcx> {
454454
let mut has_ref_mut = false;
455455
pat.walk(|pat| {
456456
if let hir::PatKind::Binding(_, id, _, _) = pat.kind
457-
&& let Some(BindingMode(ByRef::Yes(Mutability::Mut), _)) =
457+
&& let Some(BindingMode(ByRef::Yes(Mutability::Mut), _, _)) =
458458
self.pat_binding_modes().get(id)
459459
{
460460
has_ref_mut = true;

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
594594
) -> BlockAnd<()> {
595595
match irrefutable_pat.kind {
596596
// Optimize the case of `let x = ...` to write directly into `x`
597-
PatKind::Binding { mode: BindingMode(ByRef::No, _), var, subpattern: None, .. } => {
597+
PatKind::Binding {
598+
mode: BindingMode(ByRef::No, _, _), var, subpattern: None, ..
599+
} => {
598600
let place = self.storage_live_binding(
599601
block,
600602
var,
@@ -618,7 +620,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
618620
ref subpattern,
619621
ascription: thir::Ascription { ref annotation, variance: _ },
620622
} if let PatKind::Binding {
621-
mode: BindingMode(ByRef::No, _),
623+
mode: BindingMode(ByRef::No, _, _),
622624
var,
623625
subpattern: None,
624626
..
@@ -2776,7 +2778,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
27762778
let tcx = self.tcx;
27772779
let debug_source_info = SourceInfo { span: source_info.span, scope: visibility_scope };
27782780
let local = LocalDecl {
2779-
mutability: mode.1,
2781+
mutability: mode.2,
27802782
ty: var_ty,
27812783
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
27822784
source_info,

compiler/rustc_mir_build/src/builder/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
961961
// Don't introduce extra copies for simple bindings
962962
PatKind::Binding {
963963
var,
964-
mode: BindingMode(ByRef::No, mutability),
964+
mode: BindingMode(ByRef::No, pin, mutability),
965965
subpattern: None,
966966
..
967967
} => {
@@ -971,7 +971,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
971971
if let Some(kind) = param.self_kind {
972972
LocalInfo::User(BindingForm::ImplicitSelf(kind))
973973
} else {
974-
let binding_mode = BindingMode(ByRef::No, mutability);
974+
let binding_mode = BindingMode(ByRef::No, pin, mutability);
975975
LocalInfo::User(BindingForm::Var(VarBindingForm {
976976
binding_mode,
977977
opt_ty_info: param.ty_span,

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
373373
}
374374
visit::walk_pat(self, pat);
375375
}
376-
PatKind::Binding { mode: BindingMode(ByRef::Yes(rm), _), ty, .. } => {
376+
PatKind::Binding { mode: BindingMode(ByRef::Yes(rm), _, _), ty, .. } => {
377377
if self.inside_adt {
378378
let ty::Ref(_, ty, _) = ty.kind() else {
379379
span_bug!(

0 commit comments

Comments
 (0)