@@ -581,7 +581,7 @@ fn try_parse_ref_op<'tcx>(
581
581
expr : & ' tcx Expr < ' _ > ,
582
582
) -> Option < ( RefOp , & ' tcx Expr < ' tcx > ) > {
583
583
let ( def_id, arg) = match expr. kind {
584
- ExprKind :: MethodCall ( _, [ arg] , _) => ( typeck. type_dependent_def_id ( expr. hir_id ) ?, arg) ,
584
+ ExprKind :: MethodCall ( _, arg, [ ] , _) => ( typeck. type_dependent_def_id ( expr. hir_id ) ?, arg) ,
585
585
ExprKind :: Call (
586
586
Expr {
587
587
kind : ExprKind :: Path ( path) ,
@@ -796,16 +796,19 @@ fn walk_parents<'tcx>(
796
796
} ,
797
797
} )
798
798
} ) ,
799
- ExprKind :: MethodCall ( _, args, _) => {
799
+ ExprKind :: MethodCall ( _, receiver , args, _) => {
800
800
let id = cx. typeck_results ( ) . type_dependent_def_id ( parent. hir_id ) . unwrap ( ) ;
801
- args. iter ( ) . position ( |arg| arg. hir_id == child_id) . map ( |i| {
802
- if i == 0 {
803
- // Check for calls to trait methods where the trait is implemented on a reference.
804
- // Two cases need to be handled:
805
- // * `self` methods on `&T` will never have auto-borrow
806
- // * `&self` methods on `&T` can have auto-borrow, but `&self` methods on `T` will take
807
- // priority.
808
- if e. hir_id != child_id {
801
+ std:: iter:: once ( receiver)
802
+ . chain ( args. iter ( ) )
803
+ . position ( |arg| arg. hir_id == child_id)
804
+ . map ( |i| {
805
+ if i == 0 {
806
+ // Check for calls to trait methods where the trait is implemented on a reference.
807
+ // Two cases need to be handled:
808
+ // * `self` methods on `&T` will never have auto-borrow
809
+ // * `&self` methods on `&T` can have auto-borrow, but `&self` methods on `T` will take
810
+ // priority.
811
+ if e. hir_id != child_id {
809
812
Position :: ReborrowStable ( precedence)
810
813
} else if let Some ( trait_id) = cx. tcx . trait_of_item ( id)
811
814
&& let arg_ty = cx. tcx . erase_regions ( cx. typeck_results ( ) . expr_ty_adjusted ( e) )
@@ -834,20 +837,20 @@ fn walk_parents<'tcx>(
834
837
} else {
835
838
Position :: MethodReceiver
836
839
}
837
- } else {
838
- let ty = cx. tcx . fn_sig ( id) . skip_binder ( ) . inputs ( ) [ i] ;
839
- if let ty:: Param ( param_ty) = ty. kind ( ) {
840
- needless_borrow_impl_arg_position ( cx, parent, i, * param_ty, e, precedence, msrv)
841
840
} else {
842
- ty_auto_deref_stability (
843
- cx,
844
- cx. tcx . erase_late_bound_regions ( cx. tcx . fn_sig ( id) . input ( i) ) ,
845
- precedence,
846
- )
847
- . position_for_arg ( )
841
+ let ty = cx. tcx . fn_sig ( id) . skip_binder ( ) . inputs ( ) [ i] ;
842
+ if let ty:: Param ( param_ty) = ty. kind ( ) {
843
+ needless_borrow_impl_arg_position ( cx, parent, i, * param_ty, e, precedence, msrv)
844
+ } else {
845
+ ty_auto_deref_stability (
846
+ cx,
847
+ cx. tcx . erase_late_bound_regions ( cx. tcx . fn_sig ( id) . input ( i) ) ,
848
+ precedence,
849
+ )
850
+ . position_for_arg ( )
851
+ }
848
852
}
849
- }
850
- } )
853
+ } )
851
854
} ,
852
855
ExprKind :: Field ( child, name) if child. hir_id == e. hir_id => Some ( Position :: FieldAccess ( name. name ) ) ,
853
856
ExprKind :: Unary ( UnOp :: Deref , child) if child. hir_id == e. hir_id => Some ( Position :: Deref ) ,
0 commit comments