/// Autoderefs for overloaded Deref calls in fact reference their receiver. That is, if we have
/// `(*x)` where `x` is of type `Rc<T>`, then this in fact is equivalent to `x.deref()`. Since
/// `deref()` is declared with `&self`, this is an autoref of `x`.
Autoderefs for overloaded Deref calls in fact reference their receiver.
Autoderefs for overloaded Deref calls in fact reference their receiver .
fn walk_autoderefs(&mut self,
                       expr: &hir::Expr,
                       autoderefs: usize) {
        debug!("walk_autoderefs expr={:?} autoderefs={}", expr, autoderefs);
        for i in 0..autoderefs {
            let deref_id = ty::MethodCall::autoderef(expr.id, i as u32);
            match self.typer.node_method_ty(deref_id) {
                None => {}
                Some(method_ty) => {
                    let cmt = return_if_err!(self.mc.cat_expr_autoderefd(expr, i));
                    // the method call infrastructure should have
                    // replaced all late-bound regions with variables:
                    let self_ty = method_ty.fn_sig().input(0);
                    let self_ty = self.tcx().no_late_bound_regions(&self_ty).unwrap();
                    let (m, r) = match self_ty.sty {
                        ty::TyRef(r, ref m) => (m.mutbl, r),
                        _ => self.tcx().sess.span_bug(expr.span,
                                &format!("bad overloaded deref type {:?}",
                                    method_ty))
                    };
                    let bk = ty::BorrowKind::from_mutbl(m);
                    self.delegate.borrow(expr.id, expr.span, cmt,
                                         *r, bk, AutoRef);
                }
            }
        }
    }
fn walk_autoderefs ( & mut self , expr : & hir :: Expr , autoderefs : usize ) { debug ! ( " " expr autoderefs ) ; for i in 0 .. autoderefs { let deref_id = ty :: MethodCall :: autoderef ( expr . id , i as u32 ) ; match self . typer . node_method_ty ( deref_id ) { None => { } Some ( method_ty ) => { let cmt = return_if_err ! ( self mc cat_expr_autoderefd ( expr i ) ) ; // the method call infrastructure should have // replaced all late-bound regions with variables: let self_ty = method_ty . fn_sig ( ) . input ( 0 ) ; let self_ty = self . tcx ( ) . no_late_bound_regions ( & self_ty ) . unwrap ( ) ; let ( m , r ) = match self_ty . sty { ty :: TyRef ( r , ref m ) => ( m . mutbl , r ) , _ => self . tcx ( ) . sess . span_bug ( expr . span , & format ! ( " " method_ty ) ) } ; let bk = ty :: BorrowKind :: from_mutbl ( m ) ; self . delegate . borrow ( expr . id , expr . span , cmt , * r , bk , AutoRef ) ; } } } }
Autoderefs for overloaded Deref calls in fact reference their receiver.
Autoderefs for overloaded Deref calls in fact reference their receiver .
&mut self
expr
&hir::Expr
autoderefs
usize