Skip to content

Commit 0383197

Browse files
committed
Don't use thir::PatKind::DerefPattern for implicit pin-patterns
1 parent f794a08 commit 0383197

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ impl<'tcx> MatchPairTree<'tcx> {
287287
None
288288
}
289289

290+
// FIXME: Pin-patterns should probably have their own pattern kind,
291+
// instead of overloading `PatKind::Deref` via the pattern type.
290292
PatKind::Deref { ref subpattern }
291-
| PatKind::DerefPattern { ref subpattern, borrow: ByRef::Yes(Pinnedness::Pinned, _) }
292293
if let Some(ref_ty) = pattern.ty.pinned_ty()
293294
&& ref_ty.is_ref() =>
294295
{

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_abi::{FieldIdx, Integer};
1111
use rustc_errors::codes::*;
1212
use rustc_hir::def::{CtorOf, DefKind, Res};
1313
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
14-
use rustc_hir::{self as hir, ByRef, LangItem, Mutability, Pinnedness, RangeEnd};
14+
use rustc_hir::{self as hir, LangItem, RangeEnd};
1515
use rustc_index::Idx;
1616
use rustc_infer::infer::TyCtxtInferExt;
1717
use rustc_middle::mir::interpret::LitToConstInput;
@@ -114,16 +114,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
114114
let borrow = self.typeck_results.deref_pat_borrow_mode(adjust.source, pat);
115115
PatKind::DerefPattern { subpattern: thir_pat, borrow }
116116
}
117-
PatAdjust::PinDeref => {
118-
let mutable = self.typeck_results.pat_has_ref_mut_binding(pat);
119-
PatKind::DerefPattern {
120-
subpattern: thir_pat,
121-
borrow: ByRef::Yes(
122-
Pinnedness::Pinned,
123-
if mutable { Mutability::Mut } else { Mutability::Not },
124-
),
125-
}
126-
}
117+
PatAdjust::PinDeref => PatKind::Deref { subpattern: thir_pat },
127118
};
128119
Box::new(Pat { span, ty: adjust.source, kind })
129120
});

0 commit comments

Comments
 (0)