Skip to content

Commit 7d99e4e

Browse files
committed
check_pat_slice: shadow 'expected' to make sure it's not used again
1 parent 3a93a0e commit 7d99e4e

File tree

1 file changed

+6
-6
lines changed
  • src/librustc_typeck/check

1 file changed

+6
-6
lines changed

src/librustc_typeck/check/pat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11751175
discrim_span: Option<Span>,
11761176
) -> Ty<'tcx> {
11771177
let tcx = self.tcx;
1178-
let expected_ty = self.structurally_resolved_type(span, expected);
1179-
let (inner_ty, slice_ty) = match expected_ty.kind {
1178+
let expected = self.structurally_resolved_type(span, expected);
1179+
let (inner_ty, slice_ty) = 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) {
@@ -1208,11 +1208,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12081208
};
12091209
(inner_ty, slice_ty)
12101210
}
1211-
ty::Slice(inner_ty) => (inner_ty, expected_ty),
1211+
ty::Slice(inner_ty) => (inner_ty, expected),
12121212
// The expected type must be an array or slice, but was neither, so error.
12131213
_ => {
1214-
if !expected_ty.references_error() {
1215-
self.error_expected_array_or_slice(span, expected_ty);
1214+
if !expected.references_error() {
1215+
self.error_expected_array_or_slice(span, expected);
12161216
}
12171217
(tcx.types.err, tcx.types.err)
12181218
}
@@ -1230,7 +1230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12301230
for elt in after {
12311231
self.check_pat(&elt, inner_ty, def_bm, discrim_span);
12321232
}
1233-
expected_ty
1233+
expected
12341234
}
12351235

12361236
fn error_scrutinee_inconsistent_length(&self, span: Span, min_len: u64, size: u64) {

0 commit comments

Comments
 (0)