@@ -80,7 +80,7 @@ pub(crate) trait BindInsteadOfMap {
80
80
fn lint_closure_autofixable (
81
81
cx : & LateContext < ' _ > ,
82
82
expr : & hir:: Expr < ' _ > ,
83
- args : & [ hir:: Expr < ' _ > ] ,
83
+ recv : & hir:: Expr < ' _ > ,
84
84
closure_expr : & hir:: Expr < ' _ > ,
85
85
closure_args_span : Span ,
86
86
) -> bool {
@@ -103,7 +103,7 @@ pub(crate) trait BindInsteadOfMap {
103
103
} ;
104
104
105
105
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, ".." ) ;
107
107
let note = format!( "{}.{}({} {})" , option_snip, Self :: GOOD_METHOD_NAME , closure_args_snip, some_inner_snip) ;
108
108
span_lint_and_sugg(
109
109
cx,
@@ -158,17 +158,17 @@ pub(crate) trait BindInsteadOfMap {
158
158
}
159
159
160
160
/// 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 ) {
163
163
return false ;
164
164
}
165
165
166
- match args [ 1 ] . kind {
166
+ match arg . kind {
167
167
hir:: ExprKind :: Closure ( _, _, body_id, closure_args_span, _) => {
168
168
let closure_body = cx. tcx . hir ( ) . body ( body_id) ;
169
169
let closure_expr = remove_blocks ( & closure_body. value ) ;
170
170
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) {
172
172
true
173
173
} else {
174
174
Self :: lint_closure ( cx, expr, closure_expr)
@@ -182,7 +182,7 @@ pub(crate) trait BindInsteadOfMap {
182
182
expr. span ,
183
183
Self :: no_op_msg ( ) . as_ref ( ) ,
184
184
"use the expression directly" ,
185
- snippet ( cx, args [ 0 ] . span , ".." ) . into ( ) ,
185
+ snippet ( cx, recv . span , ".." ) . into ( ) ,
186
186
Applicability :: MachineApplicable ,
187
187
) ;
188
188
true
0 commit comments