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.
This commit is contained in:
parent
7d99e4e4c2
commit
13b71018c1
@ -545,15 +545,6 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> {
|
||||
|
||||
hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => {
|
||||
match ty.kind {
|
||||
ty::Ref(_, ty, _) =>
|
||||
PatKind::Deref {
|
||||
subpattern: Pat {
|
||||
ty,
|
||||
span: pat.span,
|
||||
kind: Box::new(self.slice_or_array_pattern(
|
||||
pat.span, ty, prefix, slice, suffix))
|
||||
},
|
||||
},
|
||||
ty::Slice(..) |
|
||||
ty::Array(..) =>
|
||||
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix),
|
||||
|
@ -1176,7 +1176,7 @@ fn check_pat_slice(
|
||||
) -> Ty<'tcx> {
|
||||
let tcx = self.tcx;
|
||||
let expected = self.structurally_resolved_type(span, expected);
|
||||
let (inner_ty, slice_ty) = match expected.kind {
|
||||
let (inner_ty, slice_ty, expected) = match expected.kind {
|
||||
// An array, so we might have something like `let [a, b, c] = [0, 1, 2];`.
|
||||
ty::Array(inner_ty, size) => {
|
||||
let slice_ty = if let Some(size) = size.try_eval_usize(tcx, self.param_env) {
|
||||
@ -1206,15 +1206,15 @@ fn check_pat_slice(
|
||||
self.error_scrutinee_unfixed_length(span);
|
||||
tcx.types.err
|
||||
};
|
||||
(inner_ty, slice_ty)
|
||||
(inner_ty, slice_ty, expected)
|
||||
}
|
||||
ty::Slice(inner_ty) => (inner_ty, expected),
|
||||
ty::Slice(inner_ty) => (inner_ty, expected, expected),
|
||||
// The expected type must be an array or slice, but was neither, so error.
|
||||
_ => {
|
||||
if !expected.references_error() {
|
||||
self.error_expected_array_or_slice(span, expected);
|
||||
}
|
||||
(tcx.types.err, tcx.types.err)
|
||||
(tcx.types.err, tcx.types.err, tcx.types.err)
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user