@@ -66,11 +66,11 @@ fn then_some_closure_arg<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Opt
6666 ..
6767 } ) => {
6868 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 , .. } , .. } ] , .. } =
7070 cx. tcx . hir ( ) . body ( * body)
7171 {
7272
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) )
7474 } else {
7575 None
7676 }
@@ -135,8 +135,10 @@ fn is_local_defined_at(cx: &LateContext<'_>, local: &Expr<'_>, arg_hid: HirId) -
135135
136136fn show_sugg ( cx : & LateContext < ' _ > , span : Span , selfarg : & Expr < ' _ > , closure_args : Span , predicate : & Expr < ' _ > ) {
137137 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.
138140 let sugg = format ! (
139- "{}.filter(|& {}| {})" ,
141+ "{}.filter(|{}| {})" ,
140142 snippet_with_applicability( cx, selfarg. span, "<OPTION>" , & mut appl) ,
141143 snippet_with_applicability( cx, closure_args, "<ARGS>" , & mut appl) ,
142144 snippet_with_applicability( cx, predicate. span, "<PREDICATE>" , & mut appl)
0 commit comments