Fix clippy build · rust-lang/rust@9aa142b (original) (raw)
`@@ -6,7 +6,7 @@ use if_chain::if_chain;
`
6
6
`use rustc_errors::Applicability;
`
7
7
`use rustc_hir as hir;
`
8
8
`use rustc_hir::def::Res;
`
9
``
`-
use rustc_hir::{Expr, ExprKind, PatKind, PathSegment, QPath, UnOp};
`
``
9
`+
use rustc_hir::{Closure, Expr, ExprKind, PatKind, PathSegment, QPath, UnOp};
`
10
10
`use rustc_lint::LateContext;
`
11
11
`use rustc_span::source_map::Span;
`
12
12
`use rustc_span::symbol::{sym, Symbol};
`
`@@ -22,8 +22,8 @@ fn is_method<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, method_name: Sy
`
22
22
` hir::ExprKind::Path(QPath::Resolved(_, segments)) => {
`
23
23
` segments.segments.last().unwrap().ident.name == method_name
`
24
24
`},
`
25
``
`-
hir::ExprKind::Closure { body, .. } => {
`
26
``
`-
let body = cx.tcx.hir().body(*body);
`
``
25
`+
hir::ExprKind::Closure(&hir::Closure { body, .. }) => {
`
``
26
`+
let body = cx.tcx.hir().body(body);
`
27
27
`let closure_expr = peel_blocks(&body.value);
`
28
28
`let arg_id = body.params[0].pat.hir_id;
`
29
29
`match closure_expr.kind {
`
`@@ -106,7 +106,7 @@ pub(super) fn check<'tcx>(
`
106
106
`if is_trait_method(cx, map_recv, sym::Iterator);
`
107
107
``
108
108
`// filter(|x| ...is_some())...
`
109
``
`-
if let ExprKind::Closure { body: filter_body_id, .. } = filter_arg.kind;
`
``
109
`+
if let ExprKind::Closure(&Closure { body: filter_body_id, .. }) = filter_arg.kind;
`
110
110
`let filter_body = cx.tcx.hir().body(filter_body_id);
`
111
111
`if let [filter_param] = filter_body.params;
`
112
112
`` // optional ref pattern: filter(|&x| ..)
``
`@@ -129,7 +129,7 @@ pub(super) fn check<'tcx>(
`
129
129
`if path.ident.name.as_str() == if is_result { "is_ok" } else { "is_some" };
`
130
130
``
131
131
`// ...map(|x| ...unwrap())
`
132
``
`-
if let ExprKind::Closure { body: map_body_id, .. } = map_arg.kind;
`
``
132
`+
if let ExprKind::Closure(&Closure { body: map_body_id, .. }) = map_arg.kind;
`
133
133
`let map_body = cx.tcx.hir().body(map_body_id);
`
134
134
`if let [map_param] = map_body.params;
`
135
135
`if let PatKind::Binding(_, map_param_id, map_param_ident, None) = map_param.pat.kind;
`