fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
        match e.node {
            hir::ExprKind::Unary(hir::UnNeg, ref inner) |
            hir::ExprKind::Unary(hir::UnNot, ref inner) => {
                let inner_ty = self.fcx.node_ty(inner.hir_id);
                let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);

                if inner_ty.is_scalar() {
                    let mut tables = self.fcx.tables.borrow_mut();
                    tables.type_dependent_defs_mut().remove(e.hir_id);
                    tables.node_substs_mut().remove(e.hir_id);
                }
            }
            hir::ExprKind::Binary(ref op, ref lhs, ref rhs)
            | hir::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => {
                let lhs_ty = self.fcx.node_ty(lhs.hir_id);
                let lhs_ty = self.fcx.resolve_type_vars_if_possible(&lhs_ty);

                let rhs_ty = self.fcx.node_ty(rhs.hir_id);
                let rhs_ty = self.fcx.resolve_type_vars_if_possible(&rhs_ty);

                if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
                    let mut tables = self.fcx.tables.borrow_mut();
                    tables.type_dependent_defs_mut().remove(e.hir_id);
                    tables.node_substs_mut().remove(e.hir_id);

                    match e.node {
                        hir::ExprKind::Binary(..) => {
                            if !op.node.is_by_value() {
                                let mut adjustments = tables.adjustments_mut();
                                adjustments.get_mut(lhs.hir_id).map(|a| a.pop());
                                adjustments.get_mut(rhs.hir_id).map(|a| a.pop());
                            }
                        }
                        hir::ExprKind::AssignOp(..) => {
                            tables
                                .adjustments_mut()
                                .get_mut(lhs.hir_id)
                                .map(|a| a.pop());
                        }
                        _ => {}
                    }
                }
            }
            _ => {}
        }
    }
// Hacky hack: During type-checking, we treat *all* operators
// as potentially overloaded. But then, during writeback, if
// we observe that something like `a+b` is (known to be)
// operating on scalars, we clear the overload.
Hacky hack: During type-checking, we treat *all* operators
as potentially overloaded. But then, during writeback, if
we observe that something like `a+b` is (known to be)
operating on scalars, we clear the overload.
Hacky hack : During type - checking we treat * all * operators as potentially overloaded . But then during writeback if we observe that something like ` a + b ` is ( known to be ) operating on scalars we clear the overload .
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
        match e.node {
            hir::ExprKind::Unary(hir::UnNeg, ref inner) |
            hir::ExprKind::Unary(hir::UnNot, ref inner) => {
                let inner_ty = self.fcx.node_ty(inner.hir_id);
                let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);
                if inner_ty.is_scalar() {
                    let mut tables = self.fcx.tables.borrow_mut();
                    tables.type_dependent_defs_mut().remove(e.hir_id);
                    tables.node_substs_mut().remove(e.hir_id);
                }
            }
            hir::ExprKind::Binary(ref op, ref lhs, ref rhs)
            | hir::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => {
                let lhs_ty = self.fcx.node_ty(lhs.hir_id);
                let lhs_ty = self.fcx.resolve_type_vars_if_possible(&lhs_ty);
                let rhs_ty = self.fcx.node_ty(rhs.hir_id);
                let rhs_ty = self.fcx.resolve_type_vars_if_possible(&rhs_ty);
                if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
                    let mut tables = self.fcx.tables.borrow_mut();
                    tables.type_dependent_defs_mut().remove(e.hir_id);
                    tables.node_substs_mut().remove(e.hir_id);
                    match e.node {
                        hir::ExprKind::Binary(..) => {
                            if !op.node.is_by_value() {
                                let mut adjustments = tables.adjustments_mut();
                                adjustments.get_mut(lhs.hir_id).map(|a| a.pop());
                                adjustments.get_mut(rhs.hir_id).map(|a| a.pop());
                            }
                        }
                        hir::ExprKind::AssignOp(..) => {
                            tables
                                .adjustments_mut()
                                .get_mut(lhs.hir_id)
                                .map(|a| a.pop());
                        }
                        _ => {}
                    }
                }
            }
            _ => {}
        }
    }
fn fix_scalar_builtin_expr ( & mut self , e : & hir :: Expr ) { match e . node { hir :: ExprKind :: Unary ( hir :: UnNeg , ref inner ) | hir :: ExprKind :: Unary ( hir :: UnNot , ref inner ) => { let inner_ty = self . fcx . node_ty ( inner . hir_id ) ; let inner_ty = self . fcx . resolve_type_vars_if_possible ( & inner_ty ) ; if inner_ty . is_scalar ( ) { let mut tables = self . fcx . tables . borrow_mut ( ) ; tables . type_dependent_defs_mut ( ) . remove ( e . hir_id ) ; tables . node_substs_mut ( ) . remove ( e . hir_id ) ; } } hir :: ExprKind :: Binary ( ref op , ref lhs , ref rhs ) | hir :: ExprKind :: AssignOp ( ref op , ref lhs , ref rhs ) => { let lhs_ty = self . fcx . node_ty ( lhs . hir_id ) ; let lhs_ty = self . fcx . resolve_type_vars_if_possible ( & lhs_ty ) ; let rhs_ty = self . fcx . node_ty ( rhs . hir_id ) ; let rhs_ty = self . fcx . resolve_type_vars_if_possible ( & rhs_ty ) ; if lhs_ty . is_scalar ( ) && rhs_ty . is_scalar ( ) { let mut tables = self . fcx . tables . borrow_mut ( ) ; tables . type_dependent_defs_mut ( ) . remove ( e . hir_id ) ; tables . node_substs_mut ( ) . remove ( e . hir_id ) ; match e . node { hir :: ExprKind :: Binary ( .. ) => { if ! op . node . is_by_value ( ) { let mut adjustments = tables . adjustments_mut ( ) ; adjustments . get_mut ( lhs . hir_id ) . map ( | a | a . pop ( ) ) ; adjustments . get_mut ( rhs . hir_id ) . map ( | a | a . pop ( ) ) ; } } hir :: ExprKind :: AssignOp ( .. ) => { tables . adjustments_mut ( ) . get_mut ( lhs . hir_id ) . map ( | a | a . pop ( ) ) ; } _ => { } } } } _ => { } } }
Hacky hack: During type-checking, we treat *all* operators
as potentially overloaded.
Hacky hack : During type - checking we treat * all * operators as potentially overloaded .
&mut self
e
&hir::Expr