Factor write_ty out of check_binop*
This commit is contained in:
parent
c7ea3e8d13
commit
06ad8fe261
2 changed files with 6 additions and 6 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue