From 06ad8fe261aae7b58b70be58f6a3ac6d5d9d2328 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Thu, 18 Aug 2016 17:16:42 +0800 Subject: [PATCH] Factor write_ty out of check_binop* --- src/librustc_typeck/check/mod.rs | 6 ++++-- src/librustc_typeck/check/op.rs | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index df789897bf1..7a5b2bdeb16 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3332,10 +3332,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.write_ty(id, typ) } hir::ExprBinary(op, ref lhs, ref rhs) => { - self.check_binop(expr, op, lhs, rhs) + let ty = self.check_binop(expr, op, lhs, rhs); + self.write_ty(id, ty) } hir::ExprAssignOp(op, ref lhs, ref rhs) => { - self.check_binop_assign(expr, op, lhs, rhs) + let ty = self.check_binop_assign(expr, op, lhs, rhs); + self.write_ty(id, ty) } hir::ExprUnary(unop, ref oprnd) => { let expected_inner = match unop { diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 5462826ef90..af7e12bd48d 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -38,7 +38,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else { return_ty }; - let ty = self.write_ty(expr.id, ty); let tcx = self.tcx; if !tcx.expr_is_lval(lhs_expr) { @@ -72,7 +71,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let lhs_ty = self.check_expr(lhs_expr); let lhs_ty = self.resolve_type_vars_with_obligations(lhs_ty); - let ty = match BinOpCategory::from(op) { + match BinOpCategory::from(op) { BinOpCategory::Shortcircuit => { // && and || are a simple case. self.demand_suptype(lhs_expr.span, tcx.mk_bool(), lhs_ty); @@ -111,8 +110,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { return_ty } - }; - self.write_ty(expr.id, ty) + } } fn enforce_builtin_binop_types(&self,