diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-19 22:58:20 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-19 22:58:20 +0100 |
| commit | eb020bc245bc51093fc8bbced9c0610d6e23195a (patch) | |
| tree | d80db403be464f5fb3a075ea7a4295a7d2f74252 | |
| parent | be6381e9e0d3d883baf3c2557f54af51ca18abb0 (diff) | |
| download | rust-eb020bc245bc51093fc8bbced9c0610d6e23195a.tar.gz rust-eb020bc245bc51093fc8bbced9c0610d6e23195a.zip | |
`lower_pattern_unadjusted`: simplify `Binding(..)` branch.
Avoid calling `.node_type(...)` again.
| -rw-r--r-- | src/librustc_mir/hair/pattern/mod.rs | 4 |
1 files 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, |
