Skip to content

Commit 13b7101

Browse files
committed
lower_pattern_unadjusted: remove dead code.
The code is dead because `check_pat_slice` will never have `expected = ty::Ref(...)` due to default-binding-modes (see `is_non_ref_pat`, `peel_off_references`). Moreover, if the type is not `ty::Array(_) | ty::Slice(_)` then `check_pat_slice` enters an error branch.
1 parent 7d99e4e commit 13b7101

File tree

2 files changed

+4
-13
lines changed
  • src

2 files changed

+4
-13
lines changed

src/librustc_mir/hair/pattern/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,15 +545,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
545545

546546
hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => {
547547
match ty.kind {
548-
ty::Ref(_, ty, _) =>
549-
PatKind::Deref {
550-
subpattern: Pat {
551-
ty,
552-
span: pat.span,
553-
kind: Box::new(self.slice_or_array_pattern(
554-
pat.span, ty, prefix, slice, suffix))
555-
},
556-
},
557548
ty::Slice(..) |
558549
ty::Array(..) =>
559550
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix),

src/librustc_typeck/check/pat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11761176
) -> Ty<'tcx> {
11771177
let tcx = self.tcx;
11781178
let expected = self.structurally_resolved_type(span, expected);
1179-
let (inner_ty, slice_ty) = match expected.kind {
1179+
let (inner_ty, slice_ty, expected) = match expected.kind {
11801180
// An array, so we might have something like `let [a, b, c] = [0, 1, 2];`.
11811181
ty::Array(inner_ty, size) => {
11821182
let slice_ty = if let Some(size) = size.try_eval_usize(tcx, self.param_env) {
@@ -1206,15 +1206,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12061206
self.error_scrutinee_unfixed_length(span);
12071207
tcx.types.err
12081208
};
1209-
(inner_ty, slice_ty)
1209+
(inner_ty, slice_ty, expected)
12101210
}
1211-
ty::Slice(inner_ty) => (inner_ty, expected),
1211+
ty::Slice(inner_ty) => (inner_ty, expected, expected),
12121212
// The expected type must be an array or slice, but was neither, so error.
12131213
_ => {
12141214
if !expected.references_error() {
12151215
self.error_expected_array_or_slice(span, expected);
12161216
}
1217-
(tcx.types.err, tcx.types.err)
1217+
(tcx.types.err, tcx.types.err, tcx.types.err)
12181218
}
12191219
};
12201220

0 commit comments

Comments
 (0)