@@ -80,7 +80,7 @@ pub(crate) trait BindInsteadOfMap {
8080 fn lint_closure_autofixable (
8181 cx : & LateContext < ' _ > ,
8282 expr : & hir:: Expr < ' _ > ,
83- args : & [ hir:: Expr < ' _ > ] ,
83+ recv : & hir:: Expr < ' _ > ,
8484 closure_expr : & hir:: Expr < ' _ > ,
8585 closure_args_span : Span ,
8686 ) -> bool {
@@ -103,7 +103,7 @@ pub(crate) trait BindInsteadOfMap {
103103 } ;
104104
105105 let closure_args_snip = snippet( cx, closure_args_span, ".." ) ;
106- let option_snip = snippet( cx, args [ 0 ] . span, ".." ) ;
106+ let option_snip = snippet( cx, recv . span, ".." ) ;
107107 let note = format!( "{}.{}({} {})" , option_snip, Self :: GOOD_METHOD_NAME , closure_args_snip, some_inner_snip) ;
108108 span_lint_and_sugg(
109109 cx,
@@ -158,17 +158,17 @@ pub(crate) trait BindInsteadOfMap {
158158 }
159159
160160 /// Lint use of `_.and_then(|x| Some(y))` for `Option`s
161- fn check ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) -> bool {
162- if !match_type ( cx, cx. typeck_results ( ) . expr_ty ( & args [ 0 ] ) , Self :: TYPE_QPATH ) {
161+ fn check ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , recv : & hir:: Expr < ' _ > , arg : & hir :: Expr < ' _ > ) -> bool {
162+ if !match_type ( cx, cx. typeck_results ( ) . expr_ty ( recv ) , Self :: TYPE_QPATH ) {
163163 return false ;
164164 }
165165
166- match args [ 1 ] . kind {
166+ match arg . kind {
167167 hir:: ExprKind :: Closure ( _, _, body_id, closure_args_span, _) => {
168168 let closure_body = cx. tcx . hir ( ) . body ( body_id) ;
169169 let closure_expr = remove_blocks ( & closure_body. value ) ;
170170
171- if Self :: lint_closure_autofixable ( cx, expr, args , closure_expr, closure_args_span) {
171+ if Self :: lint_closure_autofixable ( cx, expr, recv , closure_expr, closure_args_span) {
172172 true
173173 } else {
174174 Self :: lint_closure ( cx, expr, closure_expr)
@@ -182,7 +182,7 @@ pub(crate) trait BindInsteadOfMap {
182182 expr. span ,
183183 Self :: no_op_msg ( ) . as_ref ( ) ,
184184 "use the expression directly" ,
185- snippet ( cx, args [ 0 ] . span , ".." ) . into ( ) ,
185+ snippet ( cx, recv . span , ".." ) . into ( ) ,
186186 Applicability :: MachineApplicable ,
187187 ) ;
188188 true
0 commit comments