Skip to content

Commit 5644c25

Browse files
committed
Simplify hoisting of ref patterns (& and &mut)
1 parent b8390ae commit 5644c25

File tree

1 file changed

+1
-6
lines changed
  • compiler/rustc_pattern_analysis/src

1 file changed

+1
-6
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
828828
use print::{FieldPat, Pat, PatKind};
829829
let cx = self;
830830
let hoist = |p| Box::new(cx.hoist_witness_pat(p));
831-
let mut subpatterns = pat.iter_fields().map(hoist);
832831
let kind = match pat.ctor() {
833832
Bool(b) => PatKind::Constant { value: mir::Const::from_bool(cx.tcx, *b) },
834833
IntRange(range) => return self.hoist_pat_range(range, *pat.ty()),
@@ -855,11 +854,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
855854

856855
PatKind::StructLike { enum_info, subpatterns }
857856
}
858-
// Note: given the expansion of `&str` patterns done in `expand_pattern`, we should
859-
// be careful to reconstruct the correct constant pattern here. However a string
860-
// literal pattern will never be reported as a non-exhaustiveness witness, so we
861-
// ignore this issue.
862-
Ref => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
857+
Ref => PatKind::Deref { subpattern: hoist(&pat.fields[0]) },
863858
Slice(slice) => {
864859
let (prefix_len, has_dot_dot) = match slice.kind {
865860
SliceKind::FixedLen(len) => (len, false),

0 commit comments

Comments
 (0)