@@ -66,11 +66,11 @@ fn then_some_closure_arg<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Opt
66
66
..
67
67
} ) => {
68
68
if let Node :: Expr ( expr) = cx. tcx . hir_node ( body. hir_id ) &&
69
- let Body { params : [ Param { hir_id : arg_id, .. } ] , .. } =
69
+ let Body { params : [ Param { hir_id : arg_id, pat : Pat { span , .. } , .. } ] , .. } =
70
70
cx. tcx . hir ( ) . body ( * body)
71
71
{
72
72
73
- ( peel_closure_body ( cx, expr, * arg_id) ) . map ( |body| ( cx . tcx . hir ( ) . span ( * arg_id ) , body) )
73
+ ( peel_closure_body ( cx, expr, * arg_id) ) . map ( |body| ( * span , body) )
74
74
} else {
75
75
None
76
76
}
@@ -135,8 +135,10 @@ fn is_local_defined_at(cx: &LateContext<'_>, local: &Expr<'_>, arg_hid: HirId) -
135
135
136
136
fn show_sugg ( cx : & LateContext < ' _ > , span : Span , selfarg : & Expr < ' _ > , closure_args : Span , predicate : & Expr < ' _ > ) {
137
137
let mut appl = Applicability :: MachineApplicable ;
138
+ // FIXME: this relies on deref coertion, which won't work correctly if the predicate involves something
139
+ // other than a method call.
138
140
let sugg = format ! (
139
- "{}.filter(|& {}| {})" ,
141
+ "{}.filter(|{}| {})" ,
140
142
snippet_with_applicability( cx, selfarg. span, "<OPTION>" , & mut appl) ,
141
143
snippet_with_applicability( cx, closure_args, "<ARGS>" , & mut appl) ,
142
144
snippet_with_applicability( cx, predicate. span, "<PREDICATE>" , & mut appl)
0 commit comments