From eb020bc245bc51093fc8bbced9c0610d6e23195a Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 19 Dec 2019 22:58:20 +0100 Subject: [PATCH] `lower_pattern_unadjusted`: simplify `Binding(..)` branch. Avoid calling `.node_type(...)` again. --- src/librustc_mir/hair/pattern/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 888f4b8e115..7ebef2d9833 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -573,7 +573,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { } hir::PatKind::Binding(_, id, ident, ref sub) => { - let var_ty = self.tables.node_type(pat.hir_id); let bm = *self.tables.pat_binding_modes().get(pat.hir_id) .expect("missing binding mode"); let (mutability, mode) = match bm { @@ -591,13 +590,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // A ref x pattern is the same node used for x, and as such it has // x's type, which is &T, where we want T (the type being matched). + let var_ty = ty; if let ty::BindByReference(_) = bm { if let ty::Ref(_, rty, _) = ty.kind { ty = rty; } else { bug!("`ref {}` has wrong type {}", ident, ty); } - } + }; PatKind::Binding { mutability,