@@ -563,19 +563,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
563563 }
564564 ty:: TyError => { }
565565 _ => {
566- let overloaded_call_type =
567- match self . mc . infcx . node_method_id ( ty:: MethodCall :: expr ( call. id ) ) {
568- Some ( method_id) => {
569- OverloadedCallType :: from_method_id ( self . tcx ( ) , method_id)
570- }
571- None => {
572- span_bug ! (
573- callee. span,
574- "unexpected callee type {}" ,
575- callee_ty)
576- }
577- } ;
578- match overloaded_call_type {
566+ let method = self . mc . infcx . tables . borrow ( ) . method_map [ & call. id ] ;
567+ match OverloadedCallType :: from_method_id ( self . tcx ( ) , method. def_id ) {
579568 FnMutOverloadedCall => {
580569 let call_scope_r = self . tcx ( ) . node_scope_region ( call. id ) ;
581570 self . borrow_expr ( callee,
@@ -717,7 +706,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
717706 fn walk_adjustment ( & mut self , expr : & hir:: Expr ) {
718707 let infcx = self . mc . infcx ;
719708 //NOTE(@jroesch): mixed RefCell borrow causes crash
720- let adj = infcx. tables . borrow ( ) . adjustments . get ( & expr. id ) . map ( |x| x. clone ( ) ) ;
709+ let adj = infcx. tables . borrow ( ) . adjustments . get ( & expr. id ) . cloned ( ) ;
710+ let cmt_unadjusted =
711+ return_if_err ! ( self . mc. cat_expr_unadjusted( expr) ) ;
721712 if let Some ( adjustment) = adj {
722713 match adjustment. kind {
723714 adjustment:: Adjust :: NeverToAny |
@@ -728,17 +719,13 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
728719 // Creating a closure/fn-pointer or unsizing consumes
729720 // the input and stores it into the resulting rvalue.
730721 debug ! ( "walk_adjustment: trivial adjustment" ) ;
731- let cmt_unadjusted =
732- return_if_err ! ( self . mc. cat_expr_unadjusted( expr) ) ;
733722 self . delegate_consume ( expr. id , expr. span , cmt_unadjusted) ;
734723 }
735- adjustment:: Adjust :: DerefRef { autoderefs, autoref, unsize } => {
724+ adjustment:: Adjust :: DerefRef { ref autoderefs, autoref, unsize } => {
736725 debug ! ( "walk_adjustment expr={:?} adj={:?}" , expr, adjustment) ;
737726
738- self . walk_autoderefs ( expr, autoderefs) ;
739-
740727 let cmt_derefd =
741- return_if_err ! ( self . mc . cat_expr_autoderefd ( expr, autoderefs) ) ;
728+ return_if_err ! ( self . walk_autoderefs ( expr, cmt_unadjusted , autoderefs) ) ;
742729
743730 let cmt_refd =
744731 self . walk_autoref ( expr, cmt_derefd, autoref) ;
@@ -757,30 +744,30 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
757744 /// `deref()` is declared with `&self`, this is an autoref of `x`.
758745 fn walk_autoderefs ( & mut self ,
759746 expr : & hir:: Expr ,
760- autoderefs : usize ) {
761- debug ! ( "walk_autoderefs expr={:?} autoderefs={}" , expr, autoderefs) ;
762-
763- for i in 0 ..autoderefs {
764- let deref_id = ty:: MethodCall :: autoderef ( expr. id , i as u32 ) ;
765- if let Some ( method_ty) = self . mc . infcx . node_method_ty ( deref_id) {
766- let cmt = return_if_err ! ( self . mc. cat_expr_autoderefd( expr, i) ) ;
747+ mut cmt : mc:: cmt < ' tcx > ,
748+ autoderefs : & [ Option < ty:: MethodCallee < ' tcx > > ] )
749+ -> mc:: McResult < mc:: cmt < ' tcx > > {
750+ debug ! ( "walk_autoderefs expr={:?} autoderefs={:?}" , expr, autoderefs) ;
767751
752+ for & overloaded in autoderefs {
753+ if let Some ( method) = overloaded {
768754 // the method call infrastructure should have
769755 // replaced all late-bound regions with variables:
770- let self_ty = method_ty. fn_sig ( ) . input ( 0 ) ;
756+ let self_ty = method. ty . fn_sig ( ) . input ( 0 ) ;
757+ let self_ty = self . mc . infcx . resolve_type_vars_if_possible ( & self_ty) ;
771758 let self_ty = self . tcx ( ) . no_late_bound_regions ( & self_ty) . unwrap ( ) ;
772759
773760 let ( m, r) = match self_ty. sty {
774761 ty:: TyRef ( r, ref m) => ( m. mutbl , r) ,
775- _ => span_bug ! ( expr. span,
776- "bad overloaded deref type {:?}" ,
777- method_ty)
762+ _ => span_bug ! ( expr. span, "bad overloaded deref type {:?}" , self_ty)
778763 } ;
779764 let bk = ty:: BorrowKind :: from_mutbl ( m) ;
780- self . delegate . borrow ( expr. id , expr. span , cmt,
765+ self . delegate . borrow ( expr. id , expr. span , cmt. clone ( ) ,
781766 r, bk, AutoRef ) ;
782767 }
768+ cmt = self . mc . cat_deref ( expr, cmt, overloaded) ?;
783769 }
770+ Ok ( cmt)
784771 }
785772
786773 /// Walks the autoref `opt_autoref` applied to the autoderef'd
@@ -863,7 +850,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
863850 pass_args : PassArgs )
864851 -> bool
865852 {
866- if !self . mc . infcx . is_method_call ( expr. id ) {
853+ if !self . mc . infcx . tables . borrow ( ) . is_method_call ( expr. id ) {
867854 return false ;
868855 }
869856
0 commit comments