diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 15de78211449..7578b5fffe1a 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -54,7 +54,7 @@ declare_lint_pass!(ApproxConstant => [APPROX_CONSTANT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ApproxConstant { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::Lit(lit) = &e.node { + if let ExprKind::Lit(lit) = &e.kind { check_lit(cx, &lit.node, e); } } diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 35fe0905f7e7..1cca897e7390 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -63,7 +63,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic { return; } } - match &expr.node { + match &expr.kind { hir::ExprKind::Binary(op, l, r) | hir::ExprKind::AssignOp(op, l, r) => { match op.node { hir::BinOpKind::And diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 347c6478b47c..d1be15ba1663 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -32,7 +32,7 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { let lint_assert_cb = |is_debug_assert: bool| { - if let ExprKind::Unary(_, ref lit) = e.node { + if let ExprKind::Unary(_, ref lit) = e.kind { if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables, lit) { if is_true { span_help_and_lint( diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index a56d751b22d2..a16c4575e703 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -59,9 +59,9 @@ declare_lint_pass!(AssignOps => [ASSIGN_OP_PATTERN, MISREFACTORED_ASSIGN_OP]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { #[allow(clippy::too_many_lines)] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { - match &expr.node { + match &expr.kind { hir::ExprKind::AssignOp(op, lhs, rhs) => { - if let hir::ExprKind::Binary(binop, l, r) = &rhs.node { + if let hir::ExprKind::Binary(binop, l, r) = &rhs.kind { if op.node != binop.node { return; } @@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { } }, hir::ExprKind::Assign(assignee, e) => { - if let hir::ExprKind::Binary(op, l, r) = &e.node { + if let hir::ExprKind::Binary(op, l, r) = &e.kind { #[allow(clippy::cognitive_complexity)] let lint = |assignee: &hir::Expr, rhs: &hir::Expr| { let ty = cx.tables.expr_ty(assignee); diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index a4b411d75199..2324693cdc98 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -212,7 +212,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes { for item in items { if_chain! { if let NestedMetaItem::MetaItem(mi) = &item; - if let MetaItemKind::NameValue(lit) = &mi.node; + if let MetaItemKind::NameValue(lit) = &mi.kind; if mi.check_name(sym!(since)); then { check_semver(cx, item.span(), lit); @@ -227,7 +227,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes { if is_relevant_item(cx, item) { check_attrs(cx, item.span, item.ident.name, &item.attrs) } - match item.node { + match item.kind { ItemKind::ExternCrate(..) | ItemKind::Use(..) => { let skip_unused_imports = item.attrs.iter().any(|attr| attr.check_name(sym!(macro_use))); @@ -242,7 +242,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes { // whitelist `unused_imports`, `deprecated` and `unreachable_pub` for `use` items // and `unused_imports` for `extern crate` items with `macro_use` for lint in lint_list { - match item.node { + match item.kind { ItemKind::Use(..) => { if is_word(lint, sym!(unused_imports)) || is_word(lint, sym!(deprecated)) @@ -355,7 +355,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) { } fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item) -> bool { - if let ItemKind::Fn(_, _, _, eid) = item.node { + if let ItemKind::Fn(_, _, _, eid) = item.kind { is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) } else { true @@ -363,14 +363,14 @@ fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item) -> bool { } fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem) -> bool { - match item.node { + match item.kind { ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value), _ => false, } } fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem) -> bool { - match item.node { + match item.kind { TraitItemKind::Method(_, TraitMethod::Required(_)) => true, TraitItemKind::Method(_, TraitMethod::Provided(eid)) => { is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) @@ -381,7 +381,7 @@ fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem) -> bool { fn is_relevant_block(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, block: &Block) -> bool { if let Some(stmt) = block.stmts.first() { - match &stmt.node { + match &stmt.kind { StmtKind::Local(_) => true, StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, tables, expr), _ => false, @@ -392,12 +392,12 @@ fn is_relevant_block(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, bl } fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, expr: &Expr) -> bool { - match &expr.node { + match &expr.kind { ExprKind::Block(block, _) => is_relevant_block(cx, tables, block), ExprKind::Ret(Some(e)) => is_relevant_expr(cx, tables, e), ExprKind::Ret(None) | ExprKind::Break(_, None) => false, ExprKind::Call(path_expr, _) => { - if let ExprKind::Path(qpath) = &path_expr.node { + if let ExprKind::Path(qpath) = &path_expr.kind { if let Some(fun_id) = tables.qpath_res(qpath, path_expr.hir_id).opt_def_id() { !match_def_path(cx, fun_id, &paths::BEGIN_PANIC) } else { @@ -464,7 +464,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib } fn check_semver(cx: &LateContext<'_, '_>, span: Span, lit: &Lit) { - if let LitKind::Str(is, _) = lit.node { + if let LitKind::Str(is, _) = lit.kind { if Version::parse(&is.as_str()).is_ok() { return; } diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 71075500528e..e27b5269ef44 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -111,7 +111,7 @@ impl_lint_pass!(BitMask => [BAD_BIT_MASK, INEFFECTIVE_BIT_MASK, VERBOSE_BIT_MASK impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::Binary(cmp, left, right) = &e.node { + if let ExprKind::Binary(cmp, left, right) = &e.kind { if cmp.node.is_comparison() { if let Some(cmp_opt) = fetch_int_literal(cx, right) { check_compare(cx, left, cmp.node, cmp_opt, e.span) @@ -121,13 +121,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask { } } if_chain! { - if let ExprKind::Binary(op, left, right) = &e.node; + if let ExprKind::Binary(op, left, right) = &e.kind; if BinOpKind::Eq == op.node; - if let ExprKind::Binary(op1, left1, right1) = &left.node; + if let ExprKind::Binary(op1, left1, right1) = &left.kind; if BinOpKind::BitAnd == op1.node; - if let ExprKind::Lit(lit) = &right1.node; + if let ExprKind::Lit(lit) = &right1.kind; if let LitKind::Int(n, _) = lit.node; - if let ExprKind::Lit(lit1) = &right.node; + if let ExprKind::Lit(lit1) = &right.kind; if let LitKind::Int(0, _) = lit1.node; if n.leading_zeros() == n.count_zeros(); if n > u128::from(self.verbose_bit_mask_threshold); @@ -163,7 +163,7 @@ fn invert_cmp(cmp: BinOpKind) -> BinOpKind { } fn check_compare(cx: &LateContext<'_, '_>, bit_op: &Expr, cmp_op: BinOpKind, cmp_value: u128, span: Span) { - if let ExprKind::Binary(op, left, right) = &bit_op.node { + if let ExprKind::Binary(op, left, right) = &bit_op.kind { if op.node != BinOpKind::BitAnd && op.node != BinOpKind::BitOr { return; } diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index 33463df14529..986de32ddaf5 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -37,7 +37,7 @@ impl_lint_pass!(BlacklistedName => [BLACKLISTED_NAME]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlacklistedName { fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) { - if let PatKind::Binding(.., ident, _) = pat.node { + if let PatKind::Binding(.., ident, _) = pat.kind { if self.blacklist.contains(&ident.name.to_string()) { span_lint( cx, diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index f9660ce5efed..4fa7048cdedc 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -51,10 +51,10 @@ struct ExVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr) { - if let ExprKind::Closure(_, _, eid, _, _) = expr.node { + if let ExprKind::Closure(_, _, eid, _, _) = expr.kind { let body = self.cx.tcx.hir().body(eid); let ex = &body.value; - if matches!(ex.node, ExprKind::Block(_, _)) && !body.value.span.from_expansion() { + if matches!(ex.kind, ExprKind::Block(_, _)) && !body.value.span.from_expansion() { self.found_block = Some(ex); return; } @@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition { return; } if let Some((check, then, _)) = higher::if_block(&expr) { - if let ExprKind::Block(block, _) = &check.node { + if let ExprKind::Block(block, _) = &check.kind { if block.rules == DefaultBlock { if block.stmts.is_empty() { if let Some(ex) = &block.expr { diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 461abf86ea55..4309eaa78797 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -81,7 +81,7 @@ struct Hir2Qmm<'a, 'tcx, 'v> { impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { fn extract(&mut self, op: BinOpKind, a: &[&'v Expr], mut v: Vec) -> Result, String> { for a in a { - if let ExprKind::Binary(binop, lhs, rhs) = &a.node { + if let ExprKind::Binary(binop, lhs, rhs) = &a.kind { if binop.node == op { v = self.extract(op, &[lhs, rhs], v)?; continue; @@ -107,7 +107,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { // prevent folding of `cfg!` macros and the like if !e.span.from_expansion() { - match &e.node { + match &e.kind { ExprKind::Unary(UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)), ExprKind::Binary(binop, lhs, rhs) => match &binop.node { BinOpKind::Or => return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)), @@ -129,9 +129,9 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { } if_chain! { - if let ExprKind::Binary(e_binop, e_lhs, e_rhs) = &e.node; + if let ExprKind::Binary(e_binop, e_lhs, e_rhs) = &e.kind; if implements_ord(self.cx, e_lhs); - if let ExprKind::Binary(expr_binop, expr_lhs, expr_rhs) = &expr.node; + if let ExprKind::Binary(expr_binop, expr_lhs, expr_rhs) = &expr.kind; if negate(e_binop.node) == Some(expr_binop.node); if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_lhs, expr_lhs); if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e_rhs, expr_rhs); @@ -222,7 +222,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> { } fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option { - match &expr.node { + match &expr.kind { ExprKind::Binary(binop, lhs, rhs) => { if !implements_ord(cx, lhs) { return None; @@ -437,7 +437,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { if in_macro(e.span) { return; } - match &e.node { + match &e.kind { ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => { self.bool_expr(e) }, @@ -467,7 +467,7 @@ struct NotSimplificationVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr) { - if let ExprKind::Unary(UnNot, inner) = &expr.node { + if let ExprKind::Unary(UnNot, inner) = &expr.kind { if let Some(suggestion) = simplify_not(self.cx, inner) { span_lint_and_sugg( self.cx, diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 845b1e0514f6..540bffa097d7 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -37,19 +37,19 @@ declare_lint_pass!(ByteCount => [NAIVE_BYTECOUNT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount { fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) { if_chain! { - if let ExprKind::MethodCall(ref count, _, ref count_args) = expr.node; + if let ExprKind::MethodCall(ref count, _, ref count_args) = expr.kind; if count.ident.name == sym!(count); if count_args.len() == 1; - if let ExprKind::MethodCall(ref filter, _, ref filter_args) = count_args[0].node; + if let ExprKind::MethodCall(ref filter, _, ref filter_args) = count_args[0].kind; if filter.ident.name == sym!(filter); if filter_args.len() == 2; - if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].node; + if let ExprKind::Closure(_, _, body_id, _, _) = filter_args[1].kind; then { let body = cx.tcx.hir().body(body_id); if_chain! { if body.params.len() == 1; if let Some(argname) = get_pat_name(&body.params[0].pat); - if let ExprKind::Binary(ref op, ref l, ref r) = body.value.node; + if let ExprKind::Binary(ref op, ref l, ref r) = body.value.kind; if op.node == BinOpKind::Eq; if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&filter_args[0])), @@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount { return; } let haystack = if let ExprKind::MethodCall(ref path, _, ref args) = - filter_args[0].node { + filter_args[0].kind { let p = path.ident.name; if (p == sym!(iter) || p == sym!(iter_mut)) && args.len() == 1 { &args[0] @@ -100,7 +100,7 @@ fn check_arg(name: Name, arg: Name, needle: &Expr) -> bool { } fn get_path_name(expr: &Expr) -> Option { - match expr.node { + match expr.kind { ExprKind::Box(ref e) | ExprKind::AddrOf(_, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => get_path_name(e), ExprKind::Block(ref b, _) => { if b.stmts.is_empty() { diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 10ba0b9bf561..d1d725678b7b 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CheckedConversions { fn check_expr(&mut self, cx: &LateContext<'_, '_>, item: &Expr) { let result = if_chain! { if !in_external_macro(cx.sess(), item.span); - if let ExprKind::Binary(op, ref left, ref right) = &item.node; + if let ExprKind::Binary(op, ref left, ref right) = &item.kind; then { match op.node { @@ -180,7 +180,7 @@ impl ConversionType { /// Check for `expr <= (to_type::max_value() as from_type)` fn check_upper_bound(expr: &Expr) -> Option> { if_chain! { - if let ExprKind::Binary(ref op, ref left, ref right) = &expr.node; + if let ExprKind::Binary(ref op, ref left, ref right) = &expr.kind; if let Some((candidate, check)) = normalize_le_ge(op, left, right); if let Some((from, to)) = get_types_from_cast(check, MAX_VALUE, INTS); @@ -199,7 +199,7 @@ fn check_lower_bound(expr: &Expr) -> Option> { } // First of we need a binary containing the expression & the cast - if let ExprKind::Binary(ref op, ref left, ref right) = &expr.node { + if let ExprKind::Binary(ref op, ref left, ref right) = &expr.kind { normalize_le_ge(op, right, left).and_then(|(l, r)| check_function(l, r)) } else { None @@ -209,7 +209,7 @@ fn check_lower_bound(expr: &Expr) -> Option> { /// Check for `expr >= 0` fn check_lower_bound_zero<'a>(candidate: &'a Expr, check: &'a Expr) -> Option> { if_chain! { - if let ExprKind::Lit(ref lit) = &check.node; + if let ExprKind::Lit(ref lit) = &check.kind; if let LitKind::Int(0, _) = &lit.node; then { @@ -234,8 +234,8 @@ fn get_types_from_cast<'a>(expr: &'a Expr, func: &'a str, types: &'a [&str]) -> // `to_type::maxmin_value() as from_type` let call_from_cast: Option<(&Expr, &str)> = if_chain! { // to_type::maxmin_value(), from_type - if let ExprKind::Cast(ref limit, ref from_type) = &expr.node; - if let TyKind::Path(ref from_type_path) = &from_type.node; + if let ExprKind::Cast(ref limit, ref from_type) = &expr.kind; + if let TyKind::Path(ref from_type_path) = &from_type.kind; if let Some(from_sym) = int_ty_to_sym(from_type_path); then { @@ -249,12 +249,12 @@ fn get_types_from_cast<'a>(expr: &'a Expr, func: &'a str, types: &'a [&str]) -> let limit_from: Option<(&Expr, &str)> = call_from_cast.or_else(|| { if_chain! { // `from_type::from, to_type::maxmin_value()` - if let ExprKind::Call(ref from_func, ref args) = &expr.node; + if let ExprKind::Call(ref from_func, ref args) = &expr.kind; // `to_type::maxmin_value()` if args.len() == 1; if let limit = &args[0]; // `from_type::from` - if let ExprKind::Path(ref path) = &from_func.node; + if let ExprKind::Path(ref path) = &from_func.kind; if let Some(from_sym) = get_implementing_type(path, INTS, FROM); then { @@ -267,9 +267,9 @@ fn get_types_from_cast<'a>(expr: &'a Expr, func: &'a str, types: &'a [&str]) -> if let Some((limit, from_type)) = limit_from { if_chain! { - if let ExprKind::Call(ref fun_name, _) = &limit.node; + if let ExprKind::Call(ref fun_name, _) = &limit.kind; // `to_type, maxmin_value` - if let ExprKind::Path(ref path) = &fun_name.node; + if let ExprKind::Path(ref path) = &fun_name.kind; // `to_type` if let Some(to_type) = get_implementing_type(path, types, func); @@ -289,7 +289,7 @@ fn get_implementing_type<'a>(path: &QPath, candidates: &'a [&str], function: &st if_chain! { if let QPath::TypeRelative(ref ty, ref path) = &path; if path.ident.name.as_str() == function; - if let TyKind::Path(QPath::Resolved(None, ref tp)) = &ty.node; + if let TyKind::Path(QPath::Resolved(None, ref tp)) = &ty.kind; if let [int] = &*tp.segments; let name = &int.ident.name.as_str(); diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 33603b27b7a4..d869427467c3 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -110,7 +110,7 @@ struct CCHelper { impl<'tcx> Visitor<'tcx> for CCHelper { fn visit_expr(&mut self, e: &'tcx Expr) { walk_expr(self, e); - match e.node { + match e.kind { ExprKind::Match(_, ref arms, _) => { if arms.len() > 1 { self.cc += 1; diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 6c33f362633c..6a9d6d04650b 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -82,10 +82,10 @@ impl EarlyLintPass for CollapsibleIf { } fn check_if(cx: &EarlyContext<'_>, expr: &ast::Expr) { - if let ast::ExprKind::If(check, then, else_) = &expr.node { + if let ast::ExprKind::If(check, then, else_) = &expr.kind { if let Some(else_) = else_ { check_collapsible_maybe_if_let(cx, else_); - } else if let ast::ExprKind::Let(..) = check.node { + } else if let ast::ExprKind::Let(..) = check.kind { // Prevent triggering on `if let a = b { if c { .. } }`. } else { check_collapsible_no_if_let(cx, expr, check, then); @@ -103,11 +103,11 @@ fn block_starts_with_comment(cx: &EarlyContext<'_>, expr: &ast::Block) -> bool { fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, else_: &ast::Expr) { if_chain! { - if let ast::ExprKind::Block(ref block, _) = else_.node; + if let ast::ExprKind::Block(ref block, _) = else_.kind; if !block_starts_with_comment(cx, block); if let Some(else_) = expr_block(block); if !else_.span.from_expansion(); - if let ast::ExprKind::If(..) = else_.node; + if let ast::ExprKind::If(..) = else_.kind; then { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( @@ -127,9 +127,9 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: & if_chain! { if !block_starts_with_comment(cx, then); if let Some(inner) = expr_block(then); - if let ast::ExprKind::If(ref check_inner, ref content, None) = inner.node; + if let ast::ExprKind::If(ref check_inner, ref content, None) = inner.kind; then { - if let ast::ExprKind::Let(..) = check_inner.node { + if let ast::ExprKind::Let(..) = check_inner.kind { // Prevent triggering on `if c { if let a = b { .. } }`. return; } @@ -160,7 +160,7 @@ fn expr_block(block: &ast::Block) -> Option<&ast::Expr> { let mut it = block.stmts.iter(); if let (Some(stmt), None) = (it.next(), it.next()) { - match stmt.node { + match stmt.kind { ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => Some(expr), _ => None, } diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 6747614e2bcc..6968d8f65599 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ComparisonChain { if let ( &ExprKind::Binary(ref kind1, ref lhs1, ref rhs1), &ExprKind::Binary(ref kind2, ref lhs2, ref rhs2), - ) = (&cond[0].node, &cond[1].node) + ) = (&cond[0].kind, &cond[1].kind) { if !kind_is_cmp(kind1.node) || !kind_is_cmp(kind2.node) { return; diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 401a63698a23..eadadaa1932a 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -222,7 +222,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { if let Some((ref cond, ref then, otherwise)) = higher::if_block(&e) { return self.ifthenelse(cond, then, otherwise); } - match e.node { + match e.kind { ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id), ExprKind::Block(ref block, _) => self.block(block), ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty(e))), @@ -245,7 +245,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { // We only handle a few const functions for now. if_chain! { if args.is_empty(); - if let ExprKind::Path(qpath) = &callee.node; + if let ExprKind::Path(qpath) = &callee.kind; let res = self.tables.qpath_res(qpath, callee.hir_id); if let Some(def_id) = res.opt_def_id(); let get_def_path = self.lcx.get_def_path(def_id, ); diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index b32fe27a0004..f514068fb10e 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -176,7 +176,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) { .all(|(name, l_ty)| rhs.get(name).map_or(false, |r_ty| same_tys(cx, l_ty, r_ty))) } - if let ExprKind::Match(_, ref arms, MatchSource::Normal) = expr.node { + if let ExprKind::Match(_, ref arms, MatchSource::Normal) = expr.kind { let hash = |&(_, arm): &(usize, &Arm)| -> u64 { let mut h = SpanlessHash::new(cx, cx.tables); h.hash_expr(&arm.body); @@ -215,7 +215,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) { let lhs = snippet(cx, i.pat.span, ""); let rhs = snippet(cx, j.pat.span, ""); - if let PatKind::Wild = j.pat.node { + if let PatKind::Wild = j.pat.kind { // if the last arm is _, then i could be integrated into _ // note that i.pat cannot be _, because that would mean that we're // hiding all the subsequent arms, and rust won't compile @@ -238,7 +238,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr) { /// Returns the list of bindings in a pattern. fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> FxHashMap> { fn bindings_impl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat, map: &mut FxHashMap>) { - match pat.node { + match pat.kind { PatKind::Box(ref pat) | PatKind::Ref(ref pat, _) => bindings_impl(cx, pat, map), PatKind::TupleStruct(_, ref pats, _) => { for pat in pats { diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index 3c2a328b9acb..73de8add32d3 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -33,7 +33,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind { let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id)); if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) { diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 73c17c702b61..350e6c677b48 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -33,9 +33,9 @@ declare_lint_pass!(DefaultTraitAccess => [DEFAULT_TRAIT_ACCESS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Call(ref path, ..) = expr.node; + if let ExprKind::Call(ref path, ..) = expr.kind; if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id); - if let ExprKind::Path(ref qpath) = path.node; + if let ExprKind::Path(ref qpath) = path.kind; if let Some(def_id) = cx.tables.qpath_res(qpath, path.hir_id).opt_def_id(); if match_def_path(cx, def_id, &paths::DEFAULT_TRAIT_METHOD); then { @@ -44,8 +44,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess { if_chain! { // Detect and ignore ::default() because these calls do // explicitly name the type. - if let ExprKind::Call(ref method, ref _args) = expr.node; - if let ExprKind::Path(ref p) = method.node; + if let ExprKind::Call(ref method, ref _args) = expr.kind; + if let ExprKind::Path(ref p) = method.kind; if let QPath::Resolved(Some(_ty), _path) = p; then { return; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index ab9568931442..fa981ce78d9a 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -66,7 +66,7 @@ declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind { let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id)); let is_automatically_derived = is_automatically_derived(&*item.attrs); diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 86d83bf9602e..59cb282a9954 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -92,7 +92,7 @@ impl EarlyLintPass for DocMarkdown { return; } // no safety header - if let ast::ItemKind::Fn(_, ref header, ..) = item.node { + if let ast::ItemKind::Fn(_, ref header, ..) = item.kind { if item.vis.node.is_pub() && header.unsafety == ast::Unsafety::Unsafe { span_lint( cx, diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index d48bfea73b39..48d2fd341f81 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -40,7 +40,7 @@ declare_lint_pass!(DoubleComparisons => [DOUBLE_COMPARISONS]); impl<'a, 'tcx> DoubleComparisons { #[allow(clippy::similar_names)] fn check_binop(self, cx: &LateContext<'a, 'tcx>, op: BinOpKind, lhs: &'tcx Expr, rhs: &'tcx Expr, span: Span) { - let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (&lhs.node, &rhs.node) { + let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (&lhs.kind, &rhs.kind) { (ExprKind::Binary(lb, llhs, lrhs), ExprKind::Binary(rb, rlhs, rrhs)) => { (lb.node, llhs, lrhs, rb.node, rlhs, rrhs) }, @@ -88,7 +88,7 @@ impl<'a, 'tcx> DoubleComparisons { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DoubleComparisons { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = expr.node { + if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = expr.kind { self.check_binop(cx, kind.node, lhs, rhs, expr.span); } } diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index 5e1a860ae80f..3bdebbeae492 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -31,8 +31,8 @@ impl EarlyLintPass for DoubleParens { return; } - match expr.node { - ExprKind::Paren(ref in_paren) => match in_paren.node { + match expr.kind { + ExprKind::Paren(ref in_paren) => match in_paren.kind { ExprKind::Paren(_) | ExprKind::Tup(_) => { span_lint( cx, @@ -46,7 +46,7 @@ impl EarlyLintPass for DoubleParens { ExprKind::Call(_, ref params) => { if params.len() == 1 { let param = ¶ms[0]; - if let ExprKind::Paren(_) = param.node { + if let ExprKind::Paren(_) = param.kind { span_lint( cx, DOUBLE_PARENS, @@ -59,7 +59,7 @@ impl EarlyLintPass for DoubleParens { ExprKind::MethodCall(_, ref params) => { if params.len() == 2 { let param = ¶ms[1]; - if let ExprKind::Paren(_) = param.node { + if let ExprKind::Paren(_) = param.kind { span_lint( cx, DOUBLE_PARENS, diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 29a35c05ecaa..13a2be6b3fa5 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -111,8 +111,8 @@ declare_lint_pass!(DropForgetRef => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COP impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropForgetRef { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Call(ref path, ref args) = expr.node; - if let ExprKind::Path(ref qpath) = path.node; + if let ExprKind::Call(ref path, ref args) = expr.kind; + if let ExprKind::Path(ref qpath) = path.kind; if args.len() == 1; if let Some(def_id) = qpath_res(cx, qpath, path.hir_id).opt_def_id(); then { diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 1346aea3ed0a..119328cbaba1 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -35,8 +35,8 @@ declare_lint_pass!(DurationSubsec => [DURATION_SUBSEC]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, ref left, ref right) = expr.node; - if let ExprKind::MethodCall(ref method_path, _ , ref args) = left.node; + if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, ref left, ref right) = expr.kind; + if let ExprKind::MethodCall(ref method_path, _ , ref args) = left.kind; if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION); if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right); then { diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 6daf204a5f18..e6d7fe4841b8 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -53,8 +53,8 @@ impl EarlyLintPass for ElseIfWithoutElse { return; } - while let ExprKind::If(_, _, Some(ref els)) = item.node { - if let ExprKind::If(_, _, None) = els.node { + while let ExprKind::If(_, _, Some(ref els)) = item.kind { + if let ExprKind::If(_, _, None) = els.kind { span_help_and_lint( cx, ELSE_IF_WITHOUT_ELSE, diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index 80a1f9a9dba9..cfb908cf33d5 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -28,7 +28,7 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) { let did = cx.tcx.hir().local_def_id(item.hir_id); - if let ItemKind::Enum(..) = item.node { + if let ItemKind::Enum(..) = item.kind { let ty = cx.tcx.type_of(did); let adt = ty.ty_adt_def().expect("already checked whether this is an enum"); if adt.variants.is_empty() { diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index c0eba516dee0..7acac4dbb686 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -54,13 +54,13 @@ declare_lint_pass!(HashMapPass => [MAP_ENTRY]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapPass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if let Some((ref check, ref then_block, ref else_block)) = higher::if_block(&expr) { - if let ExprKind::Unary(UnOp::UnNot, ref check) = check.node { + if let ExprKind::Unary(UnOp::UnNot, ref check) = check.kind { if let Some((ty, map, key)) = check_cond(cx, check) { // in case of `if !m.contains_key(&k) { m.insert(k, v); }` // we can give a better error message let sole_expr = { else_block.is_none() - && if let ExprKind::Block(ref then_block, _) = then_block.node { + && if let ExprKind::Block(ref then_block, _) = then_block.kind { (then_block.expr.is_some() as usize) + then_block.stmts.len() == 1 } else { true @@ -102,10 +102,10 @@ fn check_cond<'a, 'tcx, 'b>( check: &'b Expr, ) -> Option<(&'static str, &'b Expr, &'b Expr)> { if_chain! { - if let ExprKind::MethodCall(ref path, _, ref params) = check.node; + if let ExprKind::MethodCall(ref path, _, ref params) = check.kind; if params.len() >= 2; if path.ident.name == sym!(contains_key); - if let ExprKind::AddrOf(_, ref key) = params[1].node; + if let ExprKind::AddrOf(_, ref key) = params[1].kind; then { let map = ¶ms[0]; let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(map)); @@ -137,7 +137,7 @@ struct InsertVisitor<'a, 'tcx, 'b> { impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { fn visit_expr(&mut self, expr: &'tcx Expr) { if_chain! { - if let ExprKind::MethodCall(ref path, _, ref params) = expr.node; + if let ExprKind::MethodCall(ref path, _, ref params) = expr.kind; if params.len() == 3; if path.ident.name == sym!(insert); if get_item_name(self.cx, self.map) == get_item_name(self.cx, ¶ms[0]); diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index b74cb9862678..e1e20c904374 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { if cx.tcx.data_layout.pointer_size.bits() != 64 { return; } - if let ItemKind::Enum(def, _) = &item.node { + if let ItemKind::Enum(def, _) = &item.kind { for var in &def.variants { if let Some(anon_const) = &var.disr_expr { let param_env = ty::ParamEnv::empty(); diff --git a/clippy_lints/src/enum_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index 489eb6dade8f..bb71bb54472d 100644 --- a/clippy_lints/src/enum_glob_use.rs +++ b/clippy_lints/src/enum_glob_use.rs @@ -42,7 +42,7 @@ impl EnumGlobUse { if item.vis.node.is_pub() { return; // re-exports are fine } - if let ItemKind::Use(ref path, UseKind::Glob) = item.node { + if let ItemKind::Use(ref path, UseKind::Glob) = item.kind { if let Res::Def(DefKind::Enum, _) = path.res { span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants"); } diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index e24d5d72e73e..e64eed383408 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -249,7 +249,7 @@ impl EarlyLintPass for EnumVariantNames { // constants don't have surrounding modules if !mod_camel.is_empty() { if mod_name == &item.ident.name { - if let ItemKind::Mod(..) = item.node { + if let ItemKind::Mod(..) = item.kind { span_lint( cx, MODULE_INCEPTION, @@ -288,7 +288,7 @@ impl EarlyLintPass for EnumVariantNames { } } } - if let ItemKind::Enum(ref def, _) = item.node { + if let ItemKind::Enum(ref def, _) = item.kind { let lint = match item.vis.node { VisibilityKind::Public => PUB_ENUM_VARIANT_NAMES, _ => ENUM_VARIANT_NAMES, diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index ae372b8d50cf..80e68f04673a 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -49,7 +49,7 @@ declare_lint_pass!(EqOp => [EQ_OP, OP_REF]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { #[allow(clippy::similar_names, clippy::too_many_lines)] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::Binary(op, ref left, ref right) = e.node { + if let ExprKind::Binary(op, ref left, ref right) = e.kind { if e.span.from_expansion() { return; } @@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { }; if let Some(trait_id) = trait_id { #[allow(clippy::match_same_arms)] - match (&left.node, &right.node) { + match (&left.kind, &right.kind) { // do not suggest to dereference literals (&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {}, // &foo == &bar diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 190f4e7b56e8..5fa52d8030c6 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -34,7 +34,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ErasingOp { if e.span.from_expansion() { return; } - if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node { + if let ExprKind::Binary(ref cmp, ref left, ref right) = e.kind { match cmp.node { BinOpKind::Mul | BinOpKind::BitAnd => { check(cx, left, e.span); diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index e174cdfb8603..5b890f6abe08 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal { let parent_node = cx.tcx.hir().find(parent_id); if let Some(Node::Item(item)) = parent_node { - if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind { return; } } @@ -139,9 +139,9 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { } if let Categorization::Rvalue(..) = cmt.cat { if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(cmt.hir_id)) { - if let StmtKind::Local(ref loc) = st.node { + if let StmtKind::Local(ref loc) = st.kind { if let Some(ref ex) = loc.init { - if let ExprKind::Box(..) = ex.node { + if let ExprKind::Box(..) = ex.kind { if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) { // let x = box (...) self.set.insert(consume_pat.hir_id); diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index a92ac5865d95..d22ae970d357 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaReduction { return; } - match expr.node { + match expr.kind { ExprKind::Call(_, ref args) | ExprKind::MethodCall(_, _, ref args) => { for arg in args { check_closure(cx, arg) @@ -77,14 +77,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaReduction { } fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) { - if let ExprKind::Closure(_, ref decl, eid, _, _) = expr.node { + if let ExprKind::Closure(_, ref decl, eid, _, _) = expr.kind { let body = cx.tcx.hir().body(eid); let ex = &body.value; if_chain!( - if let ExprKind::Call(ref caller, ref args) = ex.node; + if let ExprKind::Call(ref caller, ref args) = ex.kind; - if let ExprKind::Path(_) = caller.node; + if let ExprKind::Path(_) = caller.kind; // Not the same number of arguments, there is no way the closure is the same as the function return; if args.len() == decl.inputs.len(); @@ -115,7 +115,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) { ); if_chain!( - if let ExprKind::MethodCall(ref path, _, ref args) = ex.node; + if let ExprKind::MethodCall(ref path, _, ref args) = ex.kind; // Not the same number of arguments, there is no way the closure is the same as the function return; if args.len() == decl.inputs.len(); @@ -207,9 +207,9 @@ fn compare_inputs( call_args: &mut dyn Iterator, ) -> bool { for (closure_input, function_arg) in closure_inputs.zip(call_args) { - if let PatKind::Binding(_, _, ident, _) = closure_input.pat.node { + if let PatKind::Binding(_, _, ident, _) = closure_input.pat.kind { // XXXManishearth Should I be checking the binding mode here? - if let ExprKind::Path(QPath::Resolved(None, ref p)) = function_arg.node { + if let ExprKind::Path(QPath::Resolved(None, ref p)) = function_arg.kind { if p.segments.len() != 1 { // If it's a proper path, it can't be a local variable return false; diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 83da6dd589e0..84c0110f1111 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -60,9 +60,9 @@ declare_lint_pass!(EvalOrderDependence => [EVAL_ORDER_DEPENDENCE, DIVERGING_SUB_ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // Find a write to a local variable. - match expr.node { + match expr.kind { ExprKind::Assign(ref lhs, _) | ExprKind::AssignOp(_, ref lhs, _) => { - if let ExprKind::Path(ref qpath) = lhs.node { + if let ExprKind::Path(ref qpath) = lhs.kind { if let QPath::Resolved(_, ref path) = *qpath { if path.segments.len() == 1 { if let def::Res::Local(var) = cx.tables.qpath_res(qpath, lhs.hir_id) { @@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence { } } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - match stmt.node { + match stmt.kind { StmtKind::Local(ref local) => { if let Local { init: Some(ref e), .. } = **local { DivergenceVisitor { cx }.visit_expr(e); @@ -100,7 +100,7 @@ struct DivergenceVisitor<'a, 'tcx> { impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { fn maybe_walk_expr(&mut self, e: &'tcx Expr) { - match e.node { + match e.kind { ExprKind::Closure(..) => {}, ExprKind::Match(ref e, ref arms, _) => { self.visit_expr(e); @@ -124,7 +124,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr) { - match e.node { + match e.kind { ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e), ExprKind::Call(ref func, _) => { let typ = self.cx.tables.expr_ty(func); @@ -218,7 +218,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St return StopEarly::KeepGoing; } - match expr.node { + match expr.kind { ExprKind::Array(_) | ExprKind::Tup(_) | ExprKind::MethodCall(..) @@ -261,7 +261,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St } fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly { - match stmt.node { + match stmt.kind { StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => check_expr(vis, expr), // If the declaration is of a local variable, check its initializer // expression if it has one. Otherwise, keep going. @@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> { return; } - match expr.node { + match expr.kind { ExprKind::Path(ref qpath) => { if_chain! { if let QPath::Resolved(None, ref path) = *qpath; @@ -344,7 +344,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> { /// Returns `true` if `expr` is the LHS of an assignment, like `expr = ...`. fn is_in_assignment_position(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { if let Some(parent) = get_parent_expr(cx, expr) { - if let ExprKind::Assign(ref lhs, _) = parent.node { + if let ExprKind::Assign(ref lhs, _) = parent.kind { return lhs.hir_id == expr.hir_id; } } diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index c95e536d1406..ae9681134ffa 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision { if_chain! { let ty = cx.tables.expr_ty(expr); if let ty::Float(fty) = ty.kind; - if let hir::ExprKind::Lit(ref lit) = expr.node; + if let hir::ExprKind::Lit(ref lit) = expr.kind; if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node; if let Some(sugg) = self.check(sym, fty); then { diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 477f0e760258..926680467428 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -32,17 +32,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { // match call to unwrap - if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.node; + if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.kind; if unwrap_fun.ident.name == sym!(unwrap); // match call to write_fmt if unwrap_args.len() > 0; if let ExprKind::MethodCall(ref write_fun, _, ref write_args) = - unwrap_args[0].node; + unwrap_args[0].kind; if write_fun.ident.name == sym!(write_fmt); // match calls to std::io::stdout() / std::io::stderr () if write_args.len() > 0; - if let ExprKind::Call(ref dest_fun, _) = write_args[0].node; - if let ExprKind::Path(ref qpath) = dest_fun.node; + if let ExprKind::Call(ref dest_fun, _) = write_args[0].kind; + if let ExprKind::Path(ref qpath) = dest_fun.kind; if let Some(dest_fun_id) = resolve_node(cx, qpath, dest_fun.hir_id).opt_def_id(); if let Some(dest_name) = if match_def_path(cx, dest_fun_id, &paths::STDOUT) { Some("stdout") @@ -136,13 +136,13 @@ fn write_output_string(write_args: &HirVec) -> Option { if_chain! { // Obtain the string that should be printed if write_args.len() > 1; - if let ExprKind::Call(_, ref output_args) = write_args[1].node; + if let ExprKind::Call(_, ref output_args) = write_args[1].kind; if output_args.len() > 0; - if let ExprKind::AddrOf(_, ref output_string_expr) = output_args[0].node; - if let ExprKind::Array(ref string_exprs) = output_string_expr.node; + if let ExprKind::AddrOf(_, ref output_string_expr) = output_args[0].kind; + if let ExprKind::Array(ref string_exprs) = output_string_expr.kind; // we only want to provide an automatic suggestion for simple (non-format) strings if string_exprs.len() == 1; - if let ExprKind::Lit(ref lit) = string_exprs[0].node; + if let ExprKind::Lit(ref lit) = string_exprs[0].kind; if let LitKind::Str(ref write_output, _) = lit.node; then { return Some(write_output.to_string()) diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 4b6a2eaf796f..10db2bdef9a7 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom { // check for `impl From for ..` let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id); if_chain! { - if let hir::ItemKind::Impl(.., ref impl_items) = item.node; + if let hir::ItemKind::Impl(.., ref impl_items) = item.kind; if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id); if match_def_path(cx, impl_trait_ref.def_id, &FROM_TRAIT); then { @@ -59,8 +59,8 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it fn visit_expr(&mut self, expr: &'tcx Expr) { // check for `begin_panic` if_chain! { - if let ExprKind::Call(ref func_expr, _) = expr.node; - if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.node; + if let ExprKind::Call(ref func_expr, _) = expr.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind; if let Some(path_def_id) = path.res.opt_def_id(); if match_def_path(self.lcx, path_def_id, &BEGIN_PANIC) || match_def_path(self.lcx, path_def_id, &BEGIN_PANIC_FMT); @@ -91,7 +91,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it if_chain! { if impl_item.ident.name == sym!(from); if let ImplItemKind::Method(_, body_id) = - cx.tcx.hir().impl_item(impl_item.id).node; + cx.tcx.hir().impl_item(impl_item.id).kind; then { // check the body for `begin_panic` or `unwrap` let body = cx.tcx.hir().body(body_id); diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 85d360afd816..db6bba673fca 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -72,37 +72,37 @@ fn span_useless_format(cx: &T, span: Span, help: &str, mut sugg: fn on_argumentv1_new<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, arms: &'a [Arm]) -> Option { if_chain! { - if let ExprKind::AddrOf(_, ref format_args) = expr.node; - if let ExprKind::Array(ref elems) = arms[0].body.node; + if let ExprKind::AddrOf(_, ref format_args) = expr.kind; + if let ExprKind::Array(ref elems) = arms[0].body.kind; if elems.len() == 1; - if let ExprKind::Call(ref fun, ref args) = elems[0].node; - if let ExprKind::Path(ref qpath) = fun.node; + if let ExprKind::Call(ref fun, ref args) = elems[0].kind; + if let ExprKind::Path(ref qpath) = fun.kind; if let Some(did) = resolve_node(cx, qpath, fun.hir_id).opt_def_id(); if match_def_path(cx, did, &paths::FMT_ARGUMENTV1_NEW); // matches `core::fmt::Display::fmt` if args.len() == 2; - if let ExprKind::Path(ref qpath) = args[1].node; + if let ExprKind::Path(ref qpath) = args[1].kind; if let Some(did) = resolve_node(cx, qpath, args[1].hir_id).opt_def_id(); if match_def_path(cx, did, &paths::DISPLAY_FMT_METHOD); // check `(arg0,)` in match block - if let PatKind::Tuple(ref pats, None) = arms[0].pat.node; + if let PatKind::Tuple(ref pats, None) = arms[0].pat.kind; if pats.len() == 1; then { let ty = walk_ptrs_ty(cx.tables.pat_ty(&pats[0])); if ty.kind != rustc::ty::Str && !match_type(cx, ty, &paths::STRING) { return None; } - if let ExprKind::Lit(ref lit) = format_args.node { + if let ExprKind::Lit(ref lit) = format_args.kind { if let LitKind::Str(ref s, _) = lit.node { return Some(format!("{:?}.to_string()", s.as_str())); } } else { let snip = snippet(cx, format_args.span, ""); - if let ExprKind::MethodCall(ref path, _, _) = format_args.node { + if let ExprKind::MethodCall(ref path, _, _) = format_args.kind { if path.ident.name == sym!(to_string) { return Some(format!("{}", snip)); } - } else if let ExprKind::Binary(..) = format_args.node { + } else if let ExprKind::Binary(..) = format_args.kind { return Some(format!("{}", snip)); } return Some(format!("{}.to_string()", snip)); @@ -114,22 +114,22 @@ fn on_argumentv1_new<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, arm fn on_new_v1<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option { if_chain! { - if let ExprKind::Call(ref fun, ref args) = expr.node; + if let ExprKind::Call(ref fun, ref args) = expr.kind; if args.len() == 2; - if let ExprKind::Path(ref qpath) = fun.node; + if let ExprKind::Path(ref qpath) = fun.kind; if let Some(did) = resolve_node(cx, qpath, fun.hir_id).opt_def_id(); if match_def_path(cx, did, &paths::FMT_ARGUMENTS_NEW_V1); // Argument 1 in `new_v1()` - if let ExprKind::AddrOf(_, ref arr) = args[0].node; - if let ExprKind::Array(ref pieces) = arr.node; + if let ExprKind::AddrOf(_, ref arr) = args[0].kind; + if let ExprKind::Array(ref pieces) = arr.kind; if pieces.len() == 1; - if let ExprKind::Lit(ref lit) = pieces[0].node; + if let ExprKind::Lit(ref lit) = pieces[0].kind; if let LitKind::Str(ref s, _) = lit.node; // Argument 2 in `new_v1()` - if let ExprKind::AddrOf(_, ref arg1) = args[1].node; - if let ExprKind::Match(ref matchee, ref arms, MatchSource::Normal) = arg1.node; + if let ExprKind::AddrOf(_, ref arg1) = args[1].kind; + if let ExprKind::Match(ref matchee, ref arms, MatchSource::Normal) = arg1.kind; if arms.len() == 1; - if let ExprKind::Tup(ref tup) = matchee.node; + if let ExprKind::Tup(ref tup) = matchee.kind; then { // `format!("foo")` expansion contains `match () { () => [], }` if tup.is_empty() { @@ -144,23 +144,23 @@ fn on_new_v1<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option { if_chain! { - if let ExprKind::Call(ref fun, ref args) = expr.node; + if let ExprKind::Call(ref fun, ref args) = expr.kind; if args.len() == 3; - if let ExprKind::Path(ref qpath) = fun.node; + if let ExprKind::Path(ref qpath) = fun.kind; if let Some(did) = resolve_node(cx, qpath, fun.hir_id).opt_def_id(); if match_def_path(cx, did, &paths::FMT_ARGUMENTS_NEW_V1_FORMATTED); if check_unformatted(&args[2]); // Argument 1 in `new_v1_formatted()` - if let ExprKind::AddrOf(_, ref arr) = args[0].node; - if let ExprKind::Array(ref pieces) = arr.node; + if let ExprKind::AddrOf(_, ref arr) = args[0].kind; + if let ExprKind::Array(ref pieces) = arr.kind; if pieces.len() == 1; - if let ExprKind::Lit(ref lit) = pieces[0].node; + if let ExprKind::Lit(ref lit) = pieces[0].kind; if let LitKind::Str(..) = lit.node; // Argument 2 in `new_v1_formatted()` - if let ExprKind::AddrOf(_, ref arg1) = args[1].node; - if let ExprKind::Match(ref matchee, ref arms, MatchSource::Normal) = arg1.node; + if let ExprKind::AddrOf(_, ref arg1) = args[1].kind; + if let ExprKind::Match(ref matchee, ref arms, MatchSource::Normal) = arg1.kind; if arms.len() == 1; - if let ExprKind::Tup(ref tup) = matchee.node; + if let ExprKind::Tup(ref tup) = matchee.kind; then { return on_argumentv1_new(cx, &tup[0], arms); } @@ -181,19 +181,19 @@ fn on_new_v1_fmt<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Opti /// ``` fn check_unformatted(expr: &Expr) -> bool { if_chain! { - if let ExprKind::AddrOf(_, ref expr) = expr.node; - if let ExprKind::Array(ref exprs) = expr.node; + if let ExprKind::AddrOf(_, ref expr) = expr.kind; + if let ExprKind::Array(ref exprs) = expr.kind; if exprs.len() == 1; // struct `core::fmt::rt::v1::Argument` - if let ExprKind::Struct(_, ref fields, _) = exprs[0].node; + if let ExprKind::Struct(_, ref fields, _) = exprs[0].kind; if let Some(format_field) = fields.iter().find(|f| f.ident.name == sym!(format)); // struct `core::fmt::rt::v1::FormatSpec` - if let ExprKind::Struct(_, ref fields, _) = format_field.expr.node; + if let ExprKind::Struct(_, ref fields, _) = format_field.expr.kind; if let Some(precision_field) = fields.iter().find(|f| f.ident.name == sym!(precision)); - if let ExprKind::Path(ref precision_path) = precision_field.expr.node; + if let ExprKind::Path(ref precision_path) = precision_field.expr.kind; if last_path_segment(precision_path).ident.name == sym!(Implied); if let Some(width_field) = fields.iter().find(|f| f.ident.name == sym!(width)); - if let ExprKind::Path(ref width_qpath) = width_field.expr.node; + if let ExprKind::Path(ref width_qpath) = width_field.expr.kind; if last_path_segment(width_qpath).ident.name == sym!(Implied); then { return true; diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 463530211157..52ebaa4af7d0 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -87,7 +87,7 @@ declare_lint_pass!(Formatting => [ impl EarlyLintPass for Formatting { fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) { for w in block.stmts.windows(2) { - match (&w[0].node, &w[1].node) { + match (&w[0].kind, &w[1].kind) { (&StmtKind::Expr(ref first), &StmtKind::Expr(ref second)) | (&StmtKind::Expr(ref first), &StmtKind::Semi(ref second)) => { check_missing_else(cx, first, second); @@ -106,10 +106,10 @@ impl EarlyLintPass for Formatting { /// Implementation of the `SUSPICIOUS_ASSIGNMENT_FORMATTING` lint. fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) { - if let ExprKind::Assign(ref lhs, ref rhs) = expr.node { + if let ExprKind::Assign(ref lhs, ref rhs) = expr.kind { if !differing_macro_contexts(lhs.span, rhs.span) && !lhs.span.from_expansion() { let eq_span = lhs.span.between(rhs.span); - if let ExprKind::Unary(op, ref sub_rhs) = rhs.node { + if let ExprKind::Unary(op, ref sub_rhs) = rhs.kind { if let Some(eq_snippet) = snippet_opt(cx, eq_span) { let op = UnOp::to_string(op); let eqop_span = lhs.span.between(sub_rhs.span); @@ -136,7 +136,7 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) { /// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for weird `else`. fn check_else(cx: &EarlyContext<'_>, expr: &Expr) { if_chain! { - if let ExprKind::If(_, then, Some(else_)) = &expr.node; + if let ExprKind::If(_, then, Some(else_)) = &expr.kind; if is_block(else_) || is_if(else_); if !differing_macro_contexts(then.span, else_.span); if !then.span.from_expansion() && !in_external_macro(cx.sess, expr.span); @@ -179,9 +179,9 @@ fn has_unary_equivalent(bin_op: BinOpKind) -> bool { /// Implementation of the `POSSIBLE_MISSING_COMMA` lint for array fn check_array(cx: &EarlyContext<'_>, expr: &Expr) { - if let ExprKind::Array(ref array) = expr.node { + if let ExprKind::Array(ref array) = expr.kind { for element in array { - if let ExprKind::Binary(ref op, ref lhs, _) = element.node { + if let ExprKind::Binary(ref op, ref lhs, _) = element.kind { if has_unary_equivalent(op.node) && !differing_macro_contexts(lhs.span, op.span) { let space_span = lhs.span.between(op.span); if let Some(space_snippet) = snippet_opt(cx, space_span) { @@ -237,7 +237,7 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) { } fn is_block(expr: &Expr) -> bool { - if let ExprKind::Block(..) = expr.node { + if let ExprKind::Block(..) = expr.kind { true } else { false @@ -246,7 +246,7 @@ fn is_block(expr: &Expr) -> bool { /// Check if the expression is an `if` or `if let` fn is_if(expr: &Expr) -> bool { - if let ExprKind::If(..) = expr.node { + if let ExprKind::If(..) = expr.kind { true } else { false diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index b332148cbddc..7b6c8c7cea6d 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -109,7 +109,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { hir_id: hir::HirId, ) { let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { - matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _)) + matches!(item.kind, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _)) } else { false }; @@ -145,7 +145,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) { - if let hir::TraitItemKind::Method(ref sig, ref eid) = item.node { + if let hir::TraitItemKind::Method(ref sig, ref eid) = item.kind { // don't lint extern functions decls, it's not their fault if sig.header.abi == Abi::Rust { self.check_arg_number(cx, &sig.decl, item.span); @@ -269,7 +269,7 @@ impl<'a, 'tcx> Functions { } fn raw_ptr_arg(arg: &hir::Param, ty: &hir::Ty) -> Option { - if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) { + if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.kind, &ty.kind) { Some(id) } else { None @@ -284,7 +284,7 @@ struct DerefVisitor<'a, 'tcx> { impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Call(ref f, ref args) => { let ty = self.tables.expr_ty(f); @@ -317,7 +317,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { impl<'a, 'tcx> DerefVisitor<'a, 'tcx> { fn check_arg(&self, ptr: &hir::Expr) { - if let hir::ExprKind::Path(ref qpath) = ptr.node { + if let hir::ExprKind::Path(ref qpath) = ptr.kind { if let Res::Local(id) = qpath_res(self.cx, qpath, ptr.hir_id) { if self.ptrs.contains(&id) { span_lint( diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index 7431b7818e7b..9910fa8820a1 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -48,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { // Is a method call - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node; + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; // Method name is "get" if path.ident.name == Symbol::intern("get"); @@ -67,10 +67,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen { }, lhs, rhs, - ) = &get_index_arg.node; + ) = &get_index_arg.kind; // LHS of subtraction is "x.len()" - if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.node; + if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args) = &lhs.kind; if arg_lhs_path.ident.name == Symbol::intern("len"); if let Some(arg_lhs_struct) = lhs_args.get(0); @@ -78,7 +78,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen { if SpanlessEq::new(cx).eq_expr(struct_calling_on, arg_lhs_struct); // RHS of subtraction is 1 - if let ExprKind::Lit(rhs_lit) = &rhs.node; + if let ExprKind::Lit(rhs_lit) = &rhs.kind; if let LitKind::Int(rhs_value, ..) = rhs_lit.node; if rhs_value == 1; diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index 2441dd914aff..685c1a4caca0 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -41,13 +41,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { return; } - match e.node { + match e.kind { ExprKind::Match(_, ref arms, MatchSource::TryDesugar) => { - let e = match arms[0].body.node { + let e = match arms[0].body.kind { ExprKind::Ret(Some(ref e)) | ExprKind::Break(_, Some(ref e)) => e, _ => return, }; - if let ExprKind::Call(_, ref args) = e.node { + if let ExprKind::Call(_, ref args) = e.kind { self.try_desugar_arm.push(args[0].hir_id); } }, @@ -87,7 +87,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { }, ExprKind::Call(ref path, ref args) => { - if let ExprKind::Path(ref qpath) = path.node { + if let ExprKind::Path(ref qpath) = path.kind { if let Some(def_id) = resolve_node(cx, qpath, path.hir_id).opt_def_id() { if match_def_path(cx, def_id, &paths::FROM_FROM) { let a = cx.tables.expr_ty(e); diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index f4b98fc60cae..58f5740bf47c 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -32,7 +32,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { if e.span.from_expansion() { return; } - if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node { + if let ExprKind::Binary(ref cmp, ref left, ref right) = e.kind { match cmp.node { BinOpKind::Add | BinOpKind::BitOr | BinOpKind::BitXor => { check(cx, left, 0, e.span, right.span); diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index af9647dc0d69..74f98d6342fa 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -51,9 +51,9 @@ impl EarlyLintPass for IfNotElse { if in_external_macro(cx.sess(), item.span) { return; } - if let ExprKind::If(ref cond, _, Some(ref els)) = item.node { - if let ExprKind::Block(..) = els.node { - match cond.node { + if let ExprKind::If(ref cond, _, Some(ref els)) = item.kind { + if let ExprKind::Block(..) = els.kind { + match cond.kind { ExprKind::Unary(UnOp::Not, _) => { span_help_and_lint( cx, diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index b1b05bdc17fd..722dccf013d5 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -62,7 +62,7 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str) } fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) { - match &expr.node { + match &expr.kind { // loops could be using `break` instead of `return` ExprKind::Block(block, ..) | ExprKind::Loop(block, ..) => { if let Some(expr) = &block.expr { @@ -71,9 +71,9 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) { // only needed in the case of `break` with `;` at the end else if let Some(stmt) = block.stmts.last() { if_chain! { - if let StmtKind::Semi(expr, ..) = &stmt.node; + if let StmtKind::Semi(expr, ..) = &stmt.kind; // make sure it's a break, otherwise we want to skip - if let ExprKind::Break(.., break_expr) = &expr.node; + if let ExprKind::Break(.., break_expr) = &expr.kind; if let Some(break_expr) = break_expr; then { lint(cx, expr.span, break_expr.span, LINT_BREAK); @@ -108,7 +108,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) { // make sure it's not a call that panics ExprKind::Call(expr, ..) => { if_chain! { - if let ExprKind::Path(qpath) = &expr.node; + if let ExprKind::Path(qpath) = &expr.kind; if let Some(path_def_id) = resolve_node(cx, qpath, expr.hir_id).opt_def_id(); if match_def_path(cx, path_def_id, &BEGIN_PANIC) || match_def_path(cx, path_def_id, &BEGIN_PANIC_FMT); diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index d9924212e2ec..a2dbd09d8df4 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -89,7 +89,7 @@ declare_lint_pass!(IndexingSlicing => [INDEXING_SLICING, OUT_OF_BOUNDS_INDEXING] impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Index(ref array, ref index) = &expr.node { + if let ExprKind::Index(ref array, ref index) = &expr.kind { let ty = cx.tables.expr_ty(array); if let Some(range) = higher::range(cx, index) { // Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..] diff --git a/clippy_lints/src/infallible_destructuring_match.rs b/clippy_lints/src/infallible_destructuring_match.rs index 2ae2e2006399..015251a4feb0 100644 --- a/clippy_lints/src/infallible_destructuring_match.rs +++ b/clippy_lints/src/infallible_destructuring_match.rs @@ -46,9 +46,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InfallibleDestructingMatch { fn check_local(&mut self, cx: &LateContext<'a, 'tcx>, local: &'tcx Local) { if_chain! { if let Some(ref expr) = local.init; - if let ExprKind::Match(ref target, ref arms, MatchSource::Normal) = expr.node; + if let ExprKind::Match(ref target, ref arms, MatchSource::Normal) = expr.kind; if arms.len() == 1 && arms[0].guard.is_none(); - if let PatKind::TupleStruct(QPath::Resolved(None, ref variant_name), ref args, _) = arms[0].pat.node; + if let PatKind::TupleStruct(QPath::Resolved(None, ref variant_name), ref args, _) = arms[0].pat.kind; if args.len() == 1; if let Some(arg) = get_arg_name(&args[0]); let body = remove_blocks(&arms[0].body); diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index 48767aa2710d..adda6ae0c113 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -138,7 +138,7 @@ const HEURISTICS: [(&str, usize, Heuristic, Finiteness); 19] = [ ]; fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr) -> Finiteness { - match expr.node { + match expr.kind { ExprKind::MethodCall(ref method, _, ref args) => { for &(name, len, heuristic, cap) in &HEURISTICS { if method.ident.name.as_str() == name && args.len() == len { @@ -152,7 +152,7 @@ fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr) -> Finiteness { } } if method.ident.name == sym!(flat_map) && args.len() == 2 { - if let ExprKind::Closure(_, _, body_id, _, _) = args[1].node { + if let ExprKind::Closure(_, _, body_id, _, _) = args[1].kind { let body = cx.tcx.hir().body(body_id); return is_infinite(cx, &body.value); } @@ -162,7 +162,7 @@ fn is_infinite(cx: &LateContext<'_, '_>, expr: &Expr) -> Finiteness { ExprKind::Block(ref block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)), ExprKind::Box(ref e) | ExprKind::AddrOf(_, ref e) => is_infinite(cx, e), ExprKind::Call(ref path, _) => { - if let ExprKind::Path(ref qpath) = path.node { + if let ExprKind::Path(ref qpath) = path.kind { match_qpath(qpath, &paths::REPEAT).into() } else { Finite @@ -214,7 +214,7 @@ const INFINITE_COLLECTORS: [&[&str]; 8] = [ ]; fn complete_infinite_iter(cx: &LateContext<'_, '_>, expr: &Expr) -> Finiteness { - match expr.node { + match expr.kind { ExprKind::MethodCall(ref method, _, ref args) => { for &(name, len) in &COMPLETING_METHODS { if method.ident.name.as_str() == name && args.len() == len { diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 27170817def1..0eaff14b7bd3 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -49,7 +49,7 @@ impl_lint_pass!(MultipleInherentImpl => [MULTIPLE_INHERENT_IMPL]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl { fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.node { + if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.kind { // Remember for each inherent implementation encoutered its span and generics // but filter out implementations that have generic params (type or lifetime) if generics.params.len() == 0 { diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 26b9657589f3..b92a99488f9d 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InherentToString { if_chain! { // Check if item is a method, called to_string and has a parameter 'self' - if let ImplItemKind::Method(ref signature, _) = impl_item.node; + if let ImplItemKind::Method(ref signature, _) = impl_item.kind; if impl_item.ident.name.as_str() == "to_string"; let decl = &signature.decl; if decl.implicit_self.has_implicit_self(); diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index ffc7a8005055..8c848f697c97 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -32,7 +32,7 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { - if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node { + if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.kind { check_attrs(cx, item.ident.name, &item.attrs); } } diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index c886743533f8..4d588f253e89 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -54,17 +54,17 @@ enum Side { impl IntPlusOne { #[allow(clippy::cast_sign_loss)] fn check_lit(self, lit: &Lit, target_value: i128) -> bool { - if let LitKind::Int(value, ..) = lit.node { + if let LitKind::Int(value, ..) = lit.kind { return value == (target_value as u128); } false } fn check_binop(self, cx: &EarlyContext<'_>, binop: BinOpKind, lhs: &Expr, rhs: &Expr) -> Option { - match (binop, &lhs.node, &rhs.node) { + match (binop, &lhs.kind, &rhs.kind) { // case where `x - 1 >= ...` or `-1 + x >= ...` (BinOpKind::Ge, &ExprKind::Binary(ref lhskind, ref lhslhs, ref lhsrhs), _) => { - match (lhskind.node, &lhslhs.node, &lhsrhs.node) { + match (lhskind.node, &lhslhs.kind, &lhsrhs.kind) { // `-1 + x` (BinOpKind::Add, &ExprKind::Lit(ref lit), _) if self.check_lit(lit, -1) => { self.generate_recommendation(cx, binop, lhsrhs, rhs, Side::LHS) @@ -80,7 +80,7 @@ impl IntPlusOne { (BinOpKind::Ge, _, &ExprKind::Binary(ref rhskind, ref rhslhs, ref rhsrhs)) if rhskind.node == BinOpKind::Add => { - match (&rhslhs.node, &rhsrhs.node) { + match (&rhslhs.kind, &rhsrhs.kind) { // `y + 1` and `1 + y` (&ExprKind::Lit(ref lit), _) if self.check_lit(lit, 1) => { self.generate_recommendation(cx, binop, rhsrhs, lhs, Side::RHS) @@ -95,7 +95,7 @@ impl IntPlusOne { (BinOpKind::Le, &ExprKind::Binary(ref lhskind, ref lhslhs, ref lhsrhs), _) if lhskind.node == BinOpKind::Add => { - match (&lhslhs.node, &lhsrhs.node) { + match (&lhslhs.kind, &lhsrhs.kind) { // `1 + x` and `x + 1` (&ExprKind::Lit(ref lit), _) if self.check_lit(lit, 1) => { self.generate_recommendation(cx, binop, lhsrhs, rhs, Side::LHS) @@ -108,7 +108,7 @@ impl IntPlusOne { } // case where `... >= y - 1` or `... >= -1 + y` (BinOpKind::Le, _, &ExprKind::Binary(ref rhskind, ref rhslhs, ref rhsrhs)) => { - match (rhskind.node, &rhslhs.node, &rhsrhs.node) { + match (rhskind.node, &rhslhs.kind, &rhsrhs.kind) { // `-1 + y` (BinOpKind::Add, &ExprKind::Lit(ref lit), _) if self.check_lit(lit, -1) => { self.generate_recommendation(cx, binop, rhsrhs, lhs, Side::RHS) @@ -169,7 +169,7 @@ impl IntPlusOne { impl EarlyLintPass for IntPlusOne { fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) { - if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = item.node { + if let ExprKind::Binary(ref kind, ref lhs, ref rhs) = item.kind { if let Some(ref rec) = self.check_binop(cx, kind.node, lhs, rhs) { self.emit_warning(cx, item, rec.clone()); } diff --git a/clippy_lints/src/integer_division.rs b/clippy_lints/src/integer_division.rs index 84268fd6963c..efdd1b6a7a9c 100644 --- a/clippy_lints/src/integer_division.rs +++ b/clippy_lints/src/integer_division.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IntegerDivision { fn is_integer_division<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) -> bool { if_chain! { - if let hir::ExprKind::Binary(binop, left, right) = &expr.node; + if let hir::ExprKind::Binary(binop, left, right) = &expr.kind; if let hir::BinOpKind::Div = &binop.node; then { let (left_ty, right_ty) = (cx.tables.expr_ty(left), cx.tables.expr_ty(right)); diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 5a1713467601..a0a7e58ac2d5 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -46,7 +46,7 @@ impl EarlyLintPass for ItemsAfterStatements { let stmts = item .stmts .iter() - .map(|stmt| &stmt.node) + .map(|stmt| &stmt.kind) .skip_while(|s| matches!(**s, StmtKind::Item(..))); // lint on all further items @@ -55,7 +55,7 @@ impl EarlyLintPass for ItemsAfterStatements { if it.span.from_expansion() { return; } - if let ItemKind::MacroDef(..) = it.node { + if let ItemKind::MacroDef(..) = it.kind { // do not lint `macro_rules`, but continue processing further statements continue; } diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 2c2f4d84c73a..d5c1318f6776 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -47,7 +47,7 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) { let did = cx.tcx.hir().local_def_id(item.hir_id); - if let ItemKind::Enum(ref def, _) = item.node { + if let ItemKind::Enum(ref def, _) = item.kind { let ty = cx.tcx.type_of(did); let adt = ty.ty_adt_def().expect("already checked whether this is an enum"); diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index ef924775a18f..df4aacf75e18 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { return; } - match item.node { + match item.kind { ItemKind::Trait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items), ItemKind::Impl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items), _ => (), @@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { return; } - if let ExprKind::Binary(Spanned { node: cmp, .. }, ref left, ref right) = expr.node { + if let ExprKind::Binary(Spanned { node: cmp, .. }, ref left, ref right) = expr.kind { match cmp { BinOpKind::Eq => { check_cmp(cx, expr.span, left, right, "", 0); // len == 0 @@ -208,7 +208,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte } fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr, lit: &Expr, op: &str, compare_to: u32) { - if let (&ExprKind::MethodCall(ref method_path, _, ref args), &ExprKind::Lit(ref lit)) = (&method.node, &lit.node) { + if let (&ExprKind::MethodCall(ref method_path, _, ref args), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) { // check if we are in an is_empty() method if let Some(name) = get_item_name(cx, method) { if name.as_str() == "is_empty" { diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 4b1b57b4808a..541c25ae6050 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -60,12 +60,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { while let Some(stmt) = it.next() { if_chain! { if let Some(expr) = it.peek(); - if let hir::StmtKind::Local(ref local) = stmt.node; - if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.node; - if let hir::StmtKind::Expr(ref if_) = expr.node; + if let hir::StmtKind::Local(ref local) = stmt.kind; + if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.kind; + if let hir::StmtKind::Expr(ref if_) = expr.kind; if let Some((ref cond, ref then, ref else_)) = higher::if_block(&if_); if !used_in_expr(cx, canonical_id, cond); - if let hir::ExprKind::Block(ref then, _) = then.node; + if let hir::ExprKind::Block(ref then, _) = then.kind; if let Some(value) = check_assign(cx, canonical_id, &*then); if !used_in_expr(cx, canonical_id, value); then { @@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { if has_interior_mutability { return; } let (default_multi_stmts, default) = if let Some(ref else_) = *else_ { - if let hir::ExprKind::Block(ref else_, _) = else_.node { + if let hir::ExprKind::Block(ref else_, _) = else_.kind { if let Some(default) = check_assign(cx, canonical_id, else_) { (else_.stmts.len() > 1, default) } else if let Some(ref default) = local.init { @@ -144,7 +144,7 @@ struct UsedVisitor<'a, 'tcx> { impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { if_chain! { - if let hir::ExprKind::Path(ref qpath) = expr.node; + if let hir::ExprKind::Path(ref qpath) = expr.kind; if let Res::Local(local_id) = qpath_res(self.cx, qpath, expr.hir_id); if self.id == local_id; then { @@ -167,9 +167,9 @@ fn check_assign<'a, 'tcx>( if_chain! { if block.expr.is_none(); if let Some(expr) = block.stmts.iter().last(); - if let hir::StmtKind::Semi(ref expr) = expr.node; - if let hir::ExprKind::Assign(ref var, ref value) = expr.node; - if let hir::ExprKind::Path(ref qpath) = var.node; + if let hir::StmtKind::Semi(ref expr) = expr.kind; + if let hir::ExprKind::Assign(ref var, ref value) = expr.kind; + if let hir::ExprKind::Path(ref qpath) = var.kind; if let Res::Local(local_id) = qpath_res(cx, qpath, var.hir_id); if decl == local_id; then { diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index e75e9c6541be..88d393c84ee6 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -59,13 +59,13 @@ declare_lint_pass!(Lifetimes => [NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Fn(ref decl, _, ref generics, id) = item.node { + if let ItemKind::Fn(ref decl, _, ref generics, id) = item.kind { check_fn_inner(cx, decl, Some(id), generics, item.span, true); } } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { - if let ImplItemKind::Method(ref sig, id) = item.node { + if let ImplItemKind::Method(ref sig, id) = item.kind { let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none(); check_fn_inner( cx, @@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes { } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { - if let TraitItemKind::Method(ref sig, ref body) = item.node { + if let TraitItemKind::Method(ref sig, ref body) = item.kind { let body = match *body { TraitMethod::Required(_) => None, TraitMethod::Provided(id) => Some(id), @@ -350,7 +350,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { } fn visit_ty(&mut self, ty: &'tcx Ty) { - match ty.node { + match ty.kind { TyKind::Rptr(ref lt, _) if lt.is_elided() => { self.record(&None); }, @@ -359,7 +359,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { }, TyKind::Def(item, _) => { let map = self.cx.tcx.hir(); - if let ItemKind::OpaqueTy(ref exist_ty) = map.expect_item(item.id).node { + if let ItemKind::OpaqueTy(ref exist_ty) = map.expect_item(item.id).kind { for bound in &exist_ty.bounds { if let GenericBound::Outlives(_) = *bound { self.record(&None); diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 9cc957f1499e..65a266b2eafe 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -347,7 +347,7 @@ impl EarlyLintPass for LiteralDigitGrouping { return; } - if let ExprKind::Lit(ref lit) = expr.node { + if let ExprKind::Lit(ref lit) = expr.kind { self.check_lit(cx, lit) } } @@ -356,7 +356,7 @@ impl EarlyLintPass for LiteralDigitGrouping { impl LiteralDigitGrouping { fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) { let in_macro = in_macro(lit.span); - match lit.node { + match lit.kind { LitKind::Int(..) => { // Lint integral literals. if_chain! { @@ -492,7 +492,7 @@ impl EarlyLintPass for DecimalLiteralRepresentation { return; } - if let ExprKind::Lit(ref lit) = expr.node { + if let ExprKind::Lit(ref lit) = expr.kind { self.check_lit(cx, lit) } } @@ -505,7 +505,7 @@ impl DecimalLiteralRepresentation { fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) { // Lint integral literals. if_chain! { - if let LitKind::Int(..) = lit.node; + if let LitKind::Int(..) = lit.kind; if let Some(src) = snippet_opt(cx, lit.span); if let Some(firstch) = src.chars().next(); if char::to_digit(firstch, 10).is_some(); diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 006f8833afcb..9629f94c75d2 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -486,7 +486,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops { } // check for never_loop - if let ExprKind::Loop(ref block, _, _) = expr.node { + if let ExprKind::Loop(ref block, _, _) = expr.kind { match never_loop_block(block, expr.hir_id) { NeverLoopResult::AlwaysBreak => span_lint(cx, NEVER_LOOP, expr.span, "this loop never actually loops"), NeverLoopResult::MayContinueMainLoop | NeverLoopResult::Otherwise => (), @@ -496,7 +496,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops { // check for `loop { if let {} else break }` that could be `while let` // (also matches an explicit "match" instead of "if let") // (even if the "match" or "if let" is used for declaration) - if let ExprKind::Loop(ref block, _, LoopSource::Loop) = expr.node { + if let ExprKind::Loop(ref block, _, LoopSource::Loop) = expr.kind { // also check for empty `loop {}` statements if block.stmts.is_empty() && block.expr.is_none() { span_lint( @@ -512,7 +512,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops { let inner_stmt_expr = extract_expr_from_first_stmt(block); // or extract the first expression (if any) from the block if let Some(inner) = inner_stmt_expr.or_else(|| extract_first_expr(block)) { - if let ExprKind::Match(ref matchexpr, ref arms, ref source) = inner.node { + if let ExprKind::Match(ref matchexpr, ref arms, ref source) = inner.kind { // ensure "if let" compatible match structure match *source { MatchSource::Normal | MatchSource::IfLetDesugar { .. } => { @@ -551,12 +551,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops { } } } - if let ExprKind::Match(ref match_expr, ref arms, MatchSource::WhileLetDesugar) = expr.node { - let pat = &arms[0].pat.node; + if let ExprKind::Match(ref match_expr, ref arms, MatchSource::WhileLetDesugar) = expr.kind { + let pat = &arms[0].pat.kind; if let ( &PatKind::TupleStruct(ref qpath, ref pat_args, _), &ExprKind::MethodCall(ref method_path, _, ref method_args), - ) = (pat, &match_expr.node) + ) = (pat, &match_expr.kind) { let iter_expr = &method_args[0]; let lhs_constructor = last_path_segment(qpath); @@ -649,7 +649,7 @@ fn never_loop_block(block: &Block, main_loop_id: HirId) -> NeverLoopResult { } fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> { - match stmt.node { + match stmt.kind { StmtKind::Semi(ref e, ..) | StmtKind::Expr(ref e, ..) => Some(e), StmtKind::Local(ref local) => local.init.as_ref().map(|p| &**p), _ => None, @@ -657,7 +657,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> { } fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult { - match expr.node { + match expr.kind { ExprKind::Box(ref e) | ExprKind::Unary(_, ref e) | ExprKind::Cast(ref e, _) @@ -749,7 +749,7 @@ fn check_for_loop<'a, 'tcx>( fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bool { if_chain! { - if let ExprKind::Path(ref qpath) = expr.node; + if let ExprKind::Path(ref qpath) = expr.kind; if let QPath::Resolved(None, ref path) = *qpath; if path.segments.len() == 1; if let Res::Local(local_id) = qpath_res(cx, qpath, expr.hir_id); @@ -798,7 +798,7 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool { fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> Option { fn extract_offset<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, e: &Expr, var: HirId) -> Option { - match e.node { + match e.kind { ExprKind::Lit(ref l) => match l.node { ast::LitKind::Int(x, _ty) => Some(x.to_string()), _ => None, @@ -808,13 +808,13 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: } } - if let ExprKind::Index(ref seqexpr, ref idx) = expr.node { + if let ExprKind::Index(ref seqexpr, ref idx) = expr.kind { let ty = cx.tables.expr_ty(seqexpr); if !is_slice_like(cx, ty) { return None; } - let offset = match idx.node { + let offset = match idx.kind { ExprKind::Binary(op, ref lhs, ref rhs) => match op.node { BinOpKind::Add => { let offset_opt = if same_var(cx, lhs, var) { @@ -855,7 +855,7 @@ fn fetch_cloned_fixed_offset_var<'a, 'tcx>( var: HirId, ) -> Option { if_chain! { - if let ExprKind::MethodCall(ref method, _, ref args) = expr.node; + if let ExprKind::MethodCall(ref method, _, ref args) = expr.kind; if method.ident.name == sym!(clone); if args.len() == 1; if let Some(arg) = args.get(0); @@ -877,7 +877,7 @@ fn get_indexed_assignments<'a, 'tcx>( e: &Expr, var: HirId, ) -> Option<(FixedOffsetVar, FixedOffsetVar)> { - if let ExprKind::Assign(ref lhs, ref rhs) = e.node { + if let ExprKind::Assign(ref lhs, ref rhs) = e.kind { match ( get_fixed_offset_var(cx, lhs, var), fetch_cloned_fixed_offset_var(cx, rhs, var), @@ -897,14 +897,14 @@ fn get_indexed_assignments<'a, 'tcx>( } } - if let ExprKind::Block(ref b, _) = body.node { + if let ExprKind::Block(ref b, _) = body.kind { let Block { ref stmts, ref expr, .. } = **b; stmts .iter() - .map(|stmt| match stmt.node { + .map(|stmt| match stmt.kind { StmtKind::Local(..) | StmtKind::Item(..) => None, StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => Some(get_assignment(cx, e, var)), }) @@ -933,7 +933,7 @@ fn detect_manual_memcpy<'a, 'tcx>( }) = higher::range(cx, arg) { // the var must be a single name - if let PatKind::Binding(_, canonical_id, _, _) = pat.node { + if let PatKind::Binding(_, canonical_id, _, _) = pat.kind { let print_sum = |arg1: &Offset, arg2: &Offset| -> String { match (&arg1.value[..], arg1.negate, &arg2.value[..], arg2.negate) { ("0", _, "0", _) => "".into(), @@ -961,7 +961,7 @@ fn detect_manual_memcpy<'a, 'tcx>( let print_limit = |end: &Option<&Expr>, offset: Offset, var_name: &str| { if let Some(end) = *end { if_chain! { - if let ExprKind::MethodCall(ref method, _, ref len_args) = end.node; + if let ExprKind::MethodCall(ref method, _, ref len_args) = end.kind; if method.ident.name == sym!(len); if len_args.len() == 1; if let Some(arg) = len_args.get(0); @@ -1050,7 +1050,7 @@ fn check_for_loop_range<'a, 'tcx>( }) = higher::range(cx, arg) { // the var must be a single name - if let PatKind::Binding(_, canonical_id, ident, _) = pat.node { + if let PatKind::Binding(_, canonical_id, ident, _) = pat.kind { let mut visitor = VarVisitor { cx, var: canonical_id, @@ -1107,7 +1107,7 @@ fn check_for_loop_range<'a, 'tcx>( let take = if let Some(end) = *end { let mut take_expr = end; - if let ExprKind::Binary(ref op, ref left, ref right) = end.node { + if let ExprKind::Binary(ref op, ref left, ref right) = end.kind { if let BinOpKind::Add = op.node { let start_equal_left = SpanlessEq::new(cx).eq_expr(start, left); let start_equal_right = SpanlessEq::new(cx).eq_expr(start, right); @@ -1202,10 +1202,10 @@ fn check_for_loop_range<'a, 'tcx>( fn is_len_call(expr: &Expr, var: Name) -> bool { if_chain! { - if let ExprKind::MethodCall(ref method, _, ref len_args) = expr.node; + if let ExprKind::MethodCall(ref method, _, ref len_args) = expr.kind; if len_args.len() == 1; if method.ident.name == sym!(len); - if let ExprKind::Path(QPath::Resolved(_, ref path)) = len_args[0].node; + if let ExprKind::Path(QPath::Resolved(_, ref path)) = len_args[0].kind; if path.segments.len() == 1; if path.segments[0].ident.name == var; then { @@ -1223,7 +1223,7 @@ fn is_end_eq_array_len<'tcx>( indexed_ty: Ty<'tcx>, ) -> bool { if_chain! { - if let ExprKind::Lit(ref lit) = end.node; + if let ExprKind::Lit(ref lit) = end.kind; if let ast::LitKind::Int(end_int, _) = lit.node; if let ty::Array(_, arr_len_const) = indexed_ty.kind; if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env); @@ -1328,7 +1328,7 @@ fn lint_iter_method(cx: &LateContext<'_, '_>, args: &[Expr], arg: &Expr, method_ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Expr) { let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used - if let ExprKind::MethodCall(ref method, _, ref args) = arg.node { + if let ExprKind::MethodCall(ref method, _, ref args) = arg.kind { // just the receiver, no arguments if args.len() == 1 { let method_name = &*method.ident.as_str(); @@ -1494,11 +1494,11 @@ fn check_for_loop_over_map_kv<'a, 'tcx>( ) { let pat_span = pat.span; - if let PatKind::Tuple(ref pat, _) = pat.node { + if let PatKind::Tuple(ref pat, _) = pat.kind { if pat.len() == 2 { let arg_span = arg.span; let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).kind { - ty::Ref(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) { + ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) { (key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl), (_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable), _ => return, @@ -1509,7 +1509,7 @@ fn check_for_loop_over_map_kv<'a, 'tcx>( MutImmutable => "", MutMutable => "_mut", }; - let arg = match arg.node { + let arg = match arg.kind { ExprKind::AddrOf(_, ref expr) => &**expr, _ => arg, }; @@ -1613,7 +1613,7 @@ fn mut_warn_with_span(cx: &LateContext<'_, '_>, span: Option) { fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option { if_chain! { - if let ExprKind::Path(ref qpath) = bound.node; + if let ExprKind::Path(ref qpath) = bound.kind; if let QPath::Resolved(None, _) = *qpath; then { let res = qpath_res(cx, qpath, bound.hir_id); @@ -1621,7 +1621,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option let node_str = cx.tcx.hir().get(node_id); if_chain! { if let Node::Binding(pat) = node_str; - if let PatKind::Binding(bind_ann, ..) = pat.node; + if let PatKind::Binding(bind_ann, ..) = pat.kind; if let BindingAnnotation::Mutable = bind_ann; then { return Some(node_id); @@ -1741,7 +1741,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { fn check(&mut self, idx: &'tcx Expr, seqexpr: &'tcx Expr, expr: &'tcx Expr) -> bool { if_chain! { // the indexed container is referenced by a name - if let ExprKind::Path(ref seqpath) = seqexpr.node; + if let ExprKind::Path(ref seqpath) = seqexpr.kind; if let QPath::Resolved(None, ref seqvar) = *seqpath; if seqvar.segments.len() == 1; then { @@ -1802,7 +1802,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr) { if_chain! { // a range index op - if let ExprKind::MethodCall(ref meth, _, ref args) = expr.node; + if let ExprKind::MethodCall(ref meth, _, ref args) = expr.kind; if (meth.ident.name == sym!(index) && match_trait_method(self.cx, expr, &paths::INDEX)) || (meth.ident.name == sym!(index_mut) && match_trait_method(self.cx, expr, &paths::INDEX_MUT)); if !self.check(&args[1], &args[0], expr); @@ -1811,14 +1811,14 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { if_chain! { // an index op - if let ExprKind::Index(ref seqexpr, ref idx) = expr.node; + if let ExprKind::Index(ref seqexpr, ref idx) = expr.kind; if !self.check(idx, seqexpr, expr); then { return } } if_chain! { // directly using a variable - if let ExprKind::Path(ref qpath) = expr.node; + if let ExprKind::Path(ref qpath) = expr.kind; if let QPath::Resolved(None, ref path) = *qpath; if path.segments.len() == 1; then { @@ -1834,7 +1834,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { } let old = self.prefer_mutable; - match expr.node { + match expr.kind { ExprKind::AssignOp(_, ref lhs, ref rhs) | ExprKind::Assign(ref lhs, ref rhs) => { self.prefer_mutable = true; self.visit_expr(lhs); @@ -1972,7 +1972,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> { if block.stmts.is_empty() { return None; } - if let StmtKind::Local(ref local) = block.stmts[0].node { + if let StmtKind::Local(ref local) = block.stmts[0].kind { if let Some(ref expr) = local.init { Some(expr) } else { @@ -1987,7 +1987,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> { fn extract_first_expr(block: &Block) -> Option<&Expr> { match block.expr { Some(ref expr) if block.stmts.is_empty() => Some(expr), - None if !block.stmts.is_empty() => match block.stmts[0].node { + None if !block.stmts.is_empty() => match block.stmts[0].kind { StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => Some(expr), StmtKind::Local(..) | StmtKind::Item(..) => None, }, @@ -1999,7 +1999,7 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> { /// and /// passed expression. The expression may be within a block. fn is_simple_break_expr(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Break(dest, ref passed_expr) if dest.label.is_none() && passed_expr.is_none() => true, ExprKind::Block(ref b, _) => extract_first_expr(b).map_or(false, |subexpr| is_simple_break_expr(subexpr)), _ => false, @@ -2037,7 +2037,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> { if let Some(parent) = get_parent_expr(self.cx, expr) { let state = self.states.entry(def_id).or_insert(VarState::Initial); - match parent.node { + match parent.kind { ExprKind::AssignOp(op, ref lhs, ref rhs) => { if lhs.hir_id == expr.hir_id { if op.node == BinOpKind::Add && is_integer_const(self.cx, rhs, 1) { @@ -2061,7 +2061,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> { walk_expr(self, expr); self.depth -= 1; return; - } else if let ExprKind::Continue(_) = expr.node { + } else if let ExprKind::Continue(_) = expr.kind { self.done = true; return; } @@ -2086,9 +2086,9 @@ struct InitializeVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { fn visit_stmt(&mut self, stmt: &'tcx Stmt) { // Look for declarations of the variable - if let StmtKind::Local(ref local) = stmt.node { + if let StmtKind::Local(ref local) = stmt.kind { if local.pat.hir_id == self.var_id { - if let PatKind::Binding(.., ident, _) = local.pat.node { + if let PatKind::Binding(.., ident, _) = local.pat.kind { self.name = Some(ident.name); self.state = if let Some(ref init) = local.init { @@ -2123,7 +2123,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { // If node is the desired variable, see how it's used if var_def_id(self.cx, expr) == Some(self.var_id) { if let Some(parent) = get_parent_expr(self.cx, expr) { - match parent.node { + match parent.kind { ExprKind::AssignOp(_, ref lhs, _) if lhs.hir_id == expr.hir_id => { self.state = VarState::DontWarn; }, @@ -2160,7 +2160,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { } fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option { - if let ExprKind::Path(ref qpath) = expr.node { + if let ExprKind::Path(ref qpath) = expr.kind { let path_res = qpath_res(cx, qpath, expr.hir_id); if let Res::Local(node_id) = path_res { return Some(node_id); @@ -2170,14 +2170,14 @@ fn var_def_id(cx: &LateContext<'_, '_>, expr: &Expr) -> Option { } fn is_loop(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Loop(..) => true, _ => false, } } fn is_conditional(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Match(..) => true, _ => false, } @@ -2209,7 +2209,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr) } match cx.tcx.hir().find(parent) { Some(Node::Expr(expr)) => { - if let ExprKind::Loop(..) = expr.node { + if let ExprKind::Loop(..) = expr.kind { return true; }; }, @@ -2265,7 +2265,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor { self.nesting = LookFurther; return; } - match expr.node { + match expr.kind { ExprKind::Assign(ref path, _) | ExprKind::AssignOp(_, ref path, _) => { if match_var(path, self.iterator) { self.nesting = RuledOut; @@ -2279,7 +2279,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor { if self.nesting != Unknown { return; } - if let PatKind::Binding(.., span_name, _) = pat.node { + if let PatKind::Binding(.., span_name, _) = pat.kind { if self.iterator == span_name.name { self.nesting = RuledOut; return; @@ -2294,7 +2294,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor { } fn path_name(e: &Expr) -> Option { - if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.node { + if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.kind { let segments = &path.segments; if segments.len() == 1 { return Some(segments[0].ident.name); @@ -2351,7 +2351,7 @@ struct VarCollectorVisitor<'a, 'tcx> { impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> { fn insert_def_id(&mut self, ex: &'tcx Expr) { if_chain! { - if let ExprKind::Path(ref qpath) = ex.node; + if let ExprKind::Path(ref qpath) = ex.kind; if let QPath::Resolved(None, _) = *qpath; let res = qpath_res(self.cx, qpath, ex.hir_id); then { @@ -2372,7 +2372,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr) { - match ex.node { + match ex.kind { ExprKind::Path(_) => self.insert_def_id(ex), // If there is any function/method call… we just stop analysis ExprKind::Call(..) | ExprKind::MethodCall(..) => self.skip = true, @@ -2390,8 +2390,8 @@ const NEEDLESS_COLLECT_MSG: &str = "avoid using `collect()` when not needed"; fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>) { if_chain! { - if let ExprKind::MethodCall(ref method, _, ref args) = expr.node; - if let ExprKind::MethodCall(ref chain_method, _, _) = args[0].node; + if let ExprKind::MethodCall(ref method, _, ref args) = expr.kind; + if let ExprKind::MethodCall(ref chain_method, _, _) = args[0].kind; if chain_method.ident.name == sym!(collect) && match_trait_method(cx, &args[0], &paths::ITERATOR); if let Some(ref generic_args) = chain_method.args; if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0); @@ -2450,8 +2450,8 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx> fn shorten_needless_collect_span(expr: &Expr) -> Span { if_chain! { - if let ExprKind::MethodCall(_, _, ref args) = expr.node; - if let ExprKind::MethodCall(_, ref span, _) = args[0].node; + if let ExprKind::MethodCall(_, _, ref args) = expr.kind; + if let ExprKind::MethodCall(_, ref span, _) = args[0].kind; then { return expr.span.with_lo(span.lo() - BytePos(1)); } diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index 88f1e685ced3..2c3a348b5f7b 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -43,8 +43,8 @@ impl LateLintPass<'_, '_> for MainRecursion { } if_chain! { - if let ExprKind::Call(func, _) = &expr.node; - if let ExprKind::Path(path) = &func.node; + if let ExprKind::Call(func, _) = &expr.kind; + if let ExprKind::Path(path) = &func.kind; if let QPath::Resolved(_, path) = &path; if let Some(def_id) = path.res.opt_def_id(); if is_entrypoint_fn(cx, def_id); diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index b6264af9dfaa..1893f4ed262c 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -48,25 +48,25 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone { } if_chain! { - if let hir::ExprKind::MethodCall(ref method, _, ref args) = e.node; + if let hir::ExprKind::MethodCall(ref method, _, ref args) = e.kind; if args.len() == 2; if method.ident.as_str() == "map"; let ty = cx.tables.expr_ty(&args[0]); if match_type(cx, ty, &paths::OPTION) || match_trait_method(cx, e, &paths::ITERATOR); - if let hir::ExprKind::Closure(_, _, body_id, _, _) = args[1].node; + if let hir::ExprKind::Closure(_, _, body_id, _, _) = args[1].kind; let closure_body = cx.tcx.hir().body(body_id); let closure_expr = remove_blocks(&closure_body.value); then { - match closure_body.params[0].pat.node { + match closure_body.params[0].pat.kind { hir::PatKind::Ref(ref inner, _) => if let hir::PatKind::Binding( hir::BindingAnnotation::Unannotated, .., name, None - ) = inner.node { + ) = inner.kind { if ident_eq(name, closure_expr) { lint(cx, e.span, args[0].span, true); } }, hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => { - match closure_expr.node { + match closure_expr.kind { hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => { if ident_eq(name, inner) && !cx.tables.expr_ty(inner).is_box() { lint(cx, e.span, args[0].span, true); @@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapClone { } fn ident_eq(name: Ident, path: &hir::Expr) -> bool { - if let hir::ExprKind::Path(hir::QPath::Resolved(None, ref path)) = path.node { + if let hir::ExprKind::Path(hir::QPath::Resolved(None, ref path)) = path.kind { path.segments.len() == 1 && path.segments[0].ident == name } else { false diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index ddbd4e961d99..70f324a5081e 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -125,7 +125,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr) -> return None; } - match expr.node { + match expr.kind { hir::ExprKind::Call(_, _) | hir::ExprKind::MethodCall(_, _, _) => { // Calls can't be reduced any more Some(expr.span) @@ -140,7 +140,7 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr) -> (&[ref inner_stmt], None) => { // If block only contains statements, // reduce `{ X; }` to `X` or `X;` - match inner_stmt.node { + match inner_stmt.kind { hir::StmtKind::Local(ref local) => Some(local.span), hir::StmtKind::Expr(ref e) => Some(e.span), hir::StmtKind::Semi(..) => Some(inner_stmt.span), @@ -165,7 +165,7 @@ fn unit_closure<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, expr: &'a hir::Expr, ) -> Option<(&'tcx hir::Param, &'a hir::Expr)> { - if let hir::ExprKind::Closure(_, ref decl, inner_expr_id, _, _) = expr.node { + if let hir::ExprKind::Closure(_, ref decl, inner_expr_id, _, _) = expr.kind { let body = cx.tcx.hir().body(inner_expr_id); let body_expr = &body.value; @@ -188,7 +188,7 @@ fn unit_closure<'a, 'tcx>( /// /// Anything else will return `_`. fn let_binding_name(cx: &LateContext<'_, '_>, var_arg: &hir::Expr) -> String { - match &var_arg.node { + match &var_arg.kind { hir::ExprKind::Field(_, _) => snippet(cx, var_arg.span, "_").replace(".", "_"), hir::ExprKind::Path(_) => format!("_{}", snippet(cx, var_arg.span, "")), _ => "_".to_string(), @@ -264,7 +264,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MapUnit { return; } - if let hir::StmtKind::Semi(ref expr) = stmt.node { + if let hir::StmtKind::Semi(ref expr) = stmt.kind { if let Some(arglists) = method_chain_args(expr, &["map"]) { lint_map_unit_fn(cx, stmt, expr, arglists[0]); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 1c5a8f6240c6..569b189180c6 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -238,7 +238,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches { if in_external_macro(cx.sess(), expr.span) { return; } - if let ExprKind::Match(ref ex, ref arms, MatchSource::Normal) = expr.node { + if let ExprKind::Match(ref ex, ref arms, MatchSource::Normal) = expr.kind { check_single_match(cx, ex, arms, expr); check_match_bool(cx, ex, arms, expr); check_overlapping_arms(cx, ex, arms); @@ -246,7 +246,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches { check_wild_enum_match(cx, ex, arms); check_match_as_ref(cx, ex, arms, expr); } - if let ExprKind::Match(ref ex, ref arms, _) = expr.node { + if let ExprKind::Match(ref ex, ref arms, _) = expr.kind { check_match_ref_pats(cx, ex, arms, expr); } } @@ -255,7 +255,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches { #[rustfmt::skip] fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) { if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() { - if let PatKind::Or(..) = arms[0].pat.node { + if let PatKind::Or(..) = arms[0].pat.kind { // don't lint for or patterns for now, this makes // the lint noisy in unnecessary situations return; @@ -263,7 +263,7 @@ fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: & let els = remove_blocks(&arms[1].body); let els = if is_unit_expr(els) { None - } else if let ExprKind::Block(_, _) = els.node { + } else if let ExprKind::Block(_, _) = els.kind { // matches with blocks that contain statements are prettier as `if let + else` Some(els) } else { @@ -338,7 +338,7 @@ fn check_single_match_opt_like( (&paths::RESULT, "Ok"), ]; - let path = match arms[1].pat.node { + let path = match arms[1].pat.kind { PatKind::TupleStruct(ref path, ref inner, _) => { // Contains any non wildcard patterns (e.g., `Err(err)`)? if !inner.iter().all(is_wild) { @@ -369,8 +369,8 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex move |db| { if arms.len() == 2 { // no guards - let exprs = if let PatKind::Lit(ref arm_bool) = arms[0].pat.node { - if let ExprKind::Lit(ref lit) = arm_bool.node { + let exprs = if let PatKind::Lit(ref arm_bool) = arms[0].pat.kind { + if let ExprKind::Lit(ref lit) = arm_bool.kind { match lit.node { LitKind::Bool(true) => Some((&*arms[0].body, &*arms[1].body)), LitKind::Bool(false) => Some((&*arms[1].body, &*arms[0].body)), @@ -438,7 +438,7 @@ fn check_overlapping_arms<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ex: &'tcx Expr, } fn is_wild(pat: &impl std::ops::Deref) -> bool { - match pat.node { + match pat.kind { PatKind::Wild => true, _ => false, } @@ -448,12 +448,12 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) { let ex_ty = walk_ptrs_ty(cx.tables.expr_ty(ex)); if match_type(cx, ex_ty, &paths::RESULT) { for arm in arms { - if let PatKind::TupleStruct(ref path, ref inner, _) = arm.pat.node { + if let PatKind::TupleStruct(ref path, ref inner, _) = arm.pat.kind { let path_str = print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)); if_chain! { if path_str == "Err"; if inner.iter().any(is_wild); - if let ExprKind::Block(ref block, _) = arm.body.node; + if let ExprKind::Block(ref block, _) = arm.body.kind; if is_panic_block(block); then { // `Err(_)` arm with `panic!` found @@ -484,9 +484,9 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) { let mut wildcard_span = None; let mut wildcard_ident = None; for arm in arms { - if let PatKind::Wild = arm.pat.node { + if let PatKind::Wild = arm.pat.kind { wildcard_span = Some(arm.pat.span); - } else if let PatKind::Binding(_, _, ident, None) = arm.pat.node { + } else if let PatKind::Binding(_, _, ident, None) = arm.pat.kind { wildcard_span = Some(arm.pat.span); wildcard_ident = Some(ident); } @@ -510,11 +510,11 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) { // covered by the set of guards that cover it, but that's really hard to do. continue; } - if let PatKind::Path(ref path) = arm.pat.node { + if let PatKind::Path(ref path) = arm.pat.kind { if let QPath::Resolved(_, p) = path { missing_variants.retain(|e| e.ctor_def_id != Some(p.res.def_id())); } - } else if let PatKind::TupleStruct(ref path, ..) = arm.pat.node { + } else if let PatKind::TupleStruct(ref path, ..) = arm.pat.kind { if let QPath::Resolved(_, p) = path { missing_variants.retain(|e| e.ctor_def_id != Some(p.res.def_id())); } @@ -570,7 +570,7 @@ fn is_panic_block(block: &Block) -> bool { fn check_match_ref_pats(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) { if has_only_ref_pats(arms) { let mut suggs = Vec::new(); - let (title, msg) = if let ExprKind::AddrOf(Mutability::MutImmutable, ref inner) = ex.node { + let (title, msg) = if let ExprKind::AddrOf(Mutability::MutImmutable, ref inner) = ex.kind { let span = ex.span.source_callsite(); suggs.push((span, Sugg::hir_with_macro_callsite(cx, inner, "..").to_string())); ( @@ -587,7 +587,7 @@ fn check_match_ref_pats(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: }; suggs.extend(arms.iter().filter_map(|a| { - if let PatKind::Ref(ref refp, _) = a.pat.node { + if let PatKind::Ref(ref refp, _) = a.pat.kind { Some((a.pat.span, snippet(cx, refp.span, "..").to_string())) } else { None @@ -662,7 +662,7 @@ fn all_ranges<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arms: &'tcx [Arm]) -> Vec(cx: &LateContext<'a, 'tcx>, arms: &'tcx [Arm]) -> Vec]) -> TypedRanges { } fn is_unit_expr(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Tup(ref v) if v.is_empty() => true, ExprKind::Block(ref b, _) if b.stmts.is_empty() && b.expr.is_none() => true, _ => false, @@ -730,7 +730,7 @@ fn is_unit_expr(expr: &Expr) -> bool { // Checks if arm has the form `None => None` fn is_none_arm(arm: &Arm) -> bool { - match arm.pat.node { + match arm.pat.kind { PatKind::Path(ref path) if match_qpath(path, &paths::OPTION_NONE) => true, _ => false, } @@ -739,14 +739,14 @@ fn is_none_arm(arm: &Arm) -> bool { // Checks if arm has the form `Some(ref v) => Some(v)` (checks for `ref` and `ref mut`) fn is_ref_some_arm(arm: &Arm) -> Option { if_chain! { - if let PatKind::TupleStruct(ref path, ref pats, _) = arm.pat.node; + if let PatKind::TupleStruct(ref path, ref pats, _) = arm.pat.kind; if pats.len() == 1 && match_qpath(path, &paths::OPTION_SOME); - if let PatKind::Binding(rb, .., ident, _) = pats[0].node; + if let PatKind::Binding(rb, .., ident, _) = pats[0].kind; if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut; - if let ExprKind::Call(ref e, ref args) = remove_blocks(&arm.body).node; - if let ExprKind::Path(ref some_path) = e.node; + if let ExprKind::Call(ref e, ref args) = remove_blocks(&arm.body).kind; + if let ExprKind::Path(ref some_path) = e.kind; if match_qpath(some_path, &paths::OPTION_SOME) && args.len() == 1; - if let ExprKind::Path(ref qpath) = args[0].node; + if let ExprKind::Path(ref qpath) = args[0].kind; if let &QPath::Resolved(_, ref path2) = qpath; if path2.segments.len() == 1 && ident.name == path2.segments[0].ident.name; then { @@ -760,7 +760,7 @@ fn has_only_ref_pats(arms: &[Arm]) -> bool { let mapped = arms .iter() .map(|a| { - match a.pat.node { + match a.pat.kind { PatKind::Ref(..) => Some(true), // &-patterns PatKind::Wild => Some(false), // an "anything" wildcard is also fine _ => None, // any other pattern is not fine diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index d1966a9f61ed..1d18a312020e 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -32,9 +32,9 @@ declare_lint_pass!(MemDiscriminant => [MEM_DISCRIMINANT_NON_ENUM]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Call(ref func, ref func_args) = expr.node; + if let ExprKind::Call(ref func, ref func_args) = expr.kind; // is `mem::discriminant` - if let ExprKind::Path(ref func_qpath) = func.node; + if let ExprKind::Path(ref func_qpath) = func.kind; if let Some(def_id) = cx.tables.qpath_res(func_qpath, func.hir_id).opt_def_id(); if match_def_path(cx, def_id, &paths::MEM_DISCRIMINANT); // type is non-enum @@ -57,7 +57,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant { let mut derefs_needed = ptr_depth; let mut cur_expr = param; while derefs_needed > 0 { - if let ExprKind::AddrOf(_, ref inner_expr) = cur_expr.node { + if let ExprKind::AddrOf(_, ref inner_expr) = cur_expr.kind { derefs_needed -= 1; cur_expr = inner_expr; } else { diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 9d457f453e62..fb98be92a07b 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -27,8 +27,8 @@ declare_lint_pass!(MemForget => [MEM_FORGET]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::Call(ref path_expr, ref args) = e.node { - if let ExprKind::Path(ref qpath) = path_expr.node { + if let ExprKind::Call(ref path_expr, ref args) = e.kind { + if let ExprKind::Path(ref qpath) = path_expr.kind { if let Some(def_id) = qpath_res(cx, qpath, path_expr.hir_id).opt_def_id() { if match_def_path(cx, def_id, &paths::MEM_FORGET) { let forgot_ty = cx.tables.expr_ty(&args[0]); diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 3e1155806b9e..23bc4412717e 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -73,15 +73,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { // Check that `expr` is a call to `mem::replace()` - if let ExprKind::Call(ref func, ref func_args) = expr.node; + if let ExprKind::Call(ref func, ref func_args) = expr.kind; if func_args.len() == 2; - if let ExprKind::Path(ref func_qpath) = func.node; + if let ExprKind::Path(ref func_qpath) = func.kind; if let Some(def_id) = cx.tables.qpath_res(func_qpath, func.hir_id).opt_def_id(); if match_def_path(cx, def_id, &paths::MEM_REPLACE); // Check that second argument is `Option::None` then { - if let ExprKind::Path(ref replacement_qpath) = func_args[1].node { + if let ExprKind::Path(ref replacement_qpath) = func_args[1].kind { if match_qpath(replacement_qpath, &paths::OPTION_NONE) { // Since this is a late pass (already type-checked), @@ -89,9 +89,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace { // `Option`, we do not need to check the first // argument's type. All that's left is to get // replacee's path. - let replaced_path = match func_args[0].node { + let replaced_path = match func_args[0].kind { ExprKind::AddrOf(MutMutable, ref replaced) => { - if let ExprKind::Path(QPath::Resolved(None, ref replaced_path)) = replaced.node { + if let ExprKind::Path(QPath::Resolved(None, ref replaced_path)) = replaced.kind { replaced_path } else { return @@ -113,10 +113,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace { ); } } - if let ExprKind::Call(ref repl_func, ref repl_args) = func_args[1].node { + if let ExprKind::Call(ref repl_func, ref repl_args) = func_args[1].kind { if_chain! { if repl_args.is_empty(); - if let ExprKind::Path(ref repl_func_qpath) = repl_func.node; + if let ExprKind::Path(ref repl_func_qpath) = repl_func.kind; if let Some(repl_def_id) = cx.tables.qpath_res(repl_func_qpath, repl_func.hir_id).opt_def_id(); then { if match_def_path(cx, repl_def_id, &paths::MEM_UNINITIALIZED) { diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index 6bfd402f7b1e..075039954bd2 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -85,9 +85,9 @@ enum MinMax { fn is_min_or_max<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr) -> Option { // `T::max_value()` `T::min_value()` inherent methods if_chain! { - if let hir::ExprKind::Call(func, args) = &expr.node; + if let hir::ExprKind::Call(func, args) = &expr.kind; if args.is_empty(); - if let hir::ExprKind::Path(path) = &func.node; + if let hir::ExprKind::Path(path) = &func.kind; if let hir::QPath::TypeRelative(_, segment) = path; then { match &*segment.ident.as_str() { @@ -102,7 +102,7 @@ fn is_min_or_max<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr) -> Option(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr) -> Option(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr) -> Option Option { - if let hir::ExprKind::Unary(hir::UnNeg, inner) = &expr.node { - if let hir::ExprKind::Lit(..) = &inner.node { + if let hir::ExprKind::Unary(hir::UnNeg, inner) = &expr.kind { + if let hir::ExprKind::Lit(..) = &inner.kind { return Some(Sign::Neg); } - } else if let hir::ExprKind::Lit(..) = &expr.node { + } else if let hir::ExprKind::Lit(..) = &expr.kind { return Some(Sign::Pos); } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 9c0fbc4d56cd..be233c6e69ad 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1112,7 +1112,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { _ => {}, } - match expr.node { + match expr.kind { hir::ExprKind::MethodCall(ref method_call, ref method_span, ref args) => { lint_or_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args); lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args); @@ -1162,9 +1162,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { let def_id = cx.tcx.hir().local_def_id(item.hir_id); let ty = cx.tcx.type_of(def_id); if_chain! { - if let hir::ImplItemKind::Method(ref sig, id) = impl_item.node; + if let hir::ImplItemKind::Method(ref sig, id) = impl_item.kind; if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next(); - if let hir::ItemKind::Impl(_, _, _, _, None, _, _) = item.node; + if let hir::ItemKind::Impl(_, _, _, _, None, _, _) = item.kind; let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id); let method_sig = cx.tcx.fn_sig(method_def_id); @@ -1221,7 +1221,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { } } - if let hir::ImplItemKind::Method(_, _) = impl_item.node { + if let hir::ImplItemKind::Method(_, _) = impl_item.kind { let ret_ty = return_ty(cx, impl_item.hir_id); // walk the return type and check for Self (this does not check associated types) @@ -1279,7 +1279,7 @@ fn lint_or_fun_call<'a, 'tcx>( impl<'a, 'tcx> intravisit::Visitor<'tcx> for FunCallFinder<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let call_found = match &expr.node { + let call_found = match &expr.kind { // ignore enum and struct constructors hir::ExprKind::Call(..) => !is_ctor_function(self.cx, expr), hir::ExprKind::MethodCall(..) => true, @@ -1322,7 +1322,7 @@ fn lint_or_fun_call<'a, 'tcx>( if_chain! { if !or_has_args; if name == "unwrap_or"; - if let hir::ExprKind::Path(ref qpath) = fun.node; + if let hir::ExprKind::Path(ref qpath) = fun.kind; let path = &*last_path_segment(qpath).ident.as_str(); if ["default", "new"].contains(&path); let arg_ty = cx.tables.expr_ty(arg); @@ -1406,7 +1406,7 @@ fn lint_or_fun_call<'a, 'tcx>( } if args.len() == 2 { - match args[1].node { + match args[1].kind { hir::ExprKind::Call(ref fun, ref or_args) => { let or_has_args = !or_args.is_empty(); if !check_unwrap_or_default(cx, name, fun, &args[0], &args[1], or_has_args, expr.span) { @@ -1445,7 +1445,7 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: fn get_arg_root<'a>(cx: &LateContext<'_, '_>, arg: &'a hir::Expr) -> &'a hir::Expr { let mut arg_root = arg; loop { - arg_root = match &arg_root.node { + arg_root = match &arg_root.kind { hir::ExprKind::AddrOf(_, expr) => expr, hir::ExprKind::MethodCall(method_name, _, call_args) => { if call_args.len() == 1 @@ -1488,9 +1488,9 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: applicability: &mut Applicability, ) -> Vec { if_chain! { - if let hir::ExprKind::AddrOf(_, ref format_arg) = a.node; - if let hir::ExprKind::Match(ref format_arg_expr, _, _) = format_arg.node; - if let hir::ExprKind::Tup(ref format_arg_expr_tup) = format_arg_expr.node; + if let hir::ExprKind::AddrOf(_, ref format_arg) = a.kind; + if let hir::ExprKind::Match(ref format_arg_expr, _, _) = format_arg.kind; + if let hir::ExprKind::Tup(ref format_arg_expr_tup) = format_arg_expr.kind; then { format_arg_expr_tup @@ -1506,7 +1506,7 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: fn is_call(node: &hir::ExprKind) -> bool { match node { hir::ExprKind::AddrOf(_, expr) => { - is_call(&expr.node) + is_call(&expr.kind) }, hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) @@ -1517,7 +1517,7 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: } } - if args.len() != 2 || name != "expect" || !is_call(&args[1].node) { + if args.len() != 2 || name != "expect" || !is_call(&args[1].kind) { return; } @@ -1537,9 +1537,9 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: let mut applicability = Applicability::MachineApplicable; //Special handling for `format!` as arg_root - if let hir::ExprKind::Call(ref inner_fun, ref inner_args) = arg_root.node { + if let hir::ExprKind::Call(ref inner_fun, ref inner_args) = arg_root.kind { if is_expn_of(inner_fun.span, "format").is_some() && inner_args.len() == 1 { - if let hir::ExprKind::Call(_, format_args) = &inner_args[0].node { + if let hir::ExprKind::Call(_, format_args) = &inner_args[0].kind { let fmt_spec = &format_args[0]; let fmt_args = &format_args[1]; @@ -1626,7 +1626,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) { let parent = cx.tcx.hir().get_parent_node(expr.hir_id); match &cx.tcx.hir().get(parent) { - hir::Node::Expr(parent) => match parent.node { + hir::Node::Expr(parent) => match parent.kind { // &*x is a nop, &x.clone() is not hir::ExprKind::AddrOf(..) | // (*x).func() is useless, x.clone().func() can work in case func borrows mutably @@ -1634,8 +1634,8 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp _ => {}, }, hir::Node::Stmt(stmt) => { - if let hir::StmtKind::Local(ref loc) = stmt.node { - if let hir::PatKind::Ref(..) = loc.pat.node { + if let hir::StmtKind::Local(ref loc) = stmt.kind { + if let hir::PatKind::Ref(..) = loc.pat.kind { // let ref y = *x borrows x, let ref y = x.clone() does not return; } @@ -1796,12 +1796,12 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args: ) { if_chain! { // Extract the body of the closure passed to fold - if let hir::ExprKind::Closure(_, _, body_id, _, _) = fold_args[2].node; + if let hir::ExprKind::Closure(_, _, body_id, _, _) = fold_args[2].kind; let closure_body = cx.tcx.hir().body(body_id); let closure_expr = remove_blocks(&closure_body.value); // Check if the closure body is of the form `acc some_expr(x)` - if let hir::ExprKind::Binary(ref bin_op, ref left_expr, ref right_expr) = closure_expr.node; + if let hir::ExprKind::Binary(ref bin_op, ref left_expr, ref right_expr) = closure_expr.kind; if bin_op.node == op; // Extract the names of the two arguments to the closure @@ -1852,7 +1852,7 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args: ); // Check if the first argument to .fold is a suitable literal - if let hir::ExprKind::Lit(ref lit) = fold_args[1].node { + if let hir::ExprKind::Lit(ref lit) = fold_args[1].kind { match lit.node { ast::LitKind::Bool(false) => { check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Or, "any", true) @@ -1932,7 +1932,7 @@ fn lint_get_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, get_a if_chain! { if needs_ref; if let Some(parent) = get_parent_expr(cx, expr); - if let hir::ExprKind::Unary(hir::UnOp::UnDeref, _) = parent.node; + if let hir::ExprKind::Unary(hir::UnOp::UnDeref, _) = parent.kind; then { needs_ref = false; span = parent.span; @@ -1995,7 +1995,7 @@ fn derefs_to_slice<'a, 'tcx>( } } - if let hir::ExprKind::MethodCall(ref path, _, ref args) = expr.node { + if let hir::ExprKind::MethodCall(ref path, _, ref args) = expr.kind { if path.ident.name == sym!(iter) && may_slice(cx, cx.tables.expr_ty(&args[0])) { Some(&args[0]) } else { @@ -2160,7 +2160,7 @@ fn lint_map_unwrap_or_else<'a, 'tcx>( fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, map_or_args: &'tcx [hir::Expr]) { if match_type(cx, cx.tables.expr_ty(&map_or_args[0]), &paths::OPTION) { // check if the first non-self argument to map_or() is None - let map_or_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].node { + let map_or_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].kind { match_qpath(qpath, &paths::OPTION_NONE) } else { false @@ -2195,13 +2195,13 @@ fn lint_option_and_then_some(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: & return; } - match args[1].node { + match args[1].kind { hir::ExprKind::Closure(_, _, body_id, closure_args_span, _) => { let closure_body = cx.tcx.hir().body(body_id); let closure_expr = remove_blocks(&closure_body.value); if_chain! { - if let hir::ExprKind::Call(ref some_expr, ref some_args) = closure_expr.node; - if let hir::ExprKind::Path(ref qpath) = some_expr.node; + if let hir::ExprKind::Call(ref some_expr, ref some_args) = closure_expr.kind; + if let hir::ExprKind::Path(ref qpath) = some_expr.kind; if match_qpath(qpath, &paths::OPTION_SOME); if some_args.len() == 1; then { @@ -2381,7 +2381,7 @@ fn lint_flat_map_identity<'a, 'tcx>( flat_map_span: Span, ) { if match_trait_method(cx, expr, &paths::ITERATOR) { - let arg_node = &flat_map_args[1].node; + let arg_node = &flat_map_args[1].kind; let apply_lint = |message: &str| { span_lint_and_sugg( @@ -2399,8 +2399,8 @@ fn lint_flat_map_identity<'a, 'tcx>( if let hir::ExprKind::Closure(_, _, body_id, _, _) = arg_node; let body = cx.tcx.hir().body(*body_id); - if let hir::PatKind::Binding(_, _, binding_ident, _) = body.params[0].pat.node; - if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = body.value.node; + if let hir::PatKind::Binding(_, _, binding_ident, _) = body.params[0].pat.kind; + if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = body.value.kind; if path.segments.len() == 1; if path.segments[0].ident.as_str() == binding_ident.as_str(); @@ -2444,11 +2444,11 @@ fn lint_search_is_some<'a, 'tcx>( // suggest `any(|..| *..)` instead of `any(|..| **..)` for `find(|..| **..).is_some()` let any_search_snippet = if_chain! { if search_method == "find"; - if let hir::ExprKind::Closure(_, _, body_id, ..) = search_args[1].node; + if let hir::ExprKind::Closure(_, _, body_id, ..) = search_args[1].kind; let closure_body = cx.tcx.hir().body(body_id); if let Some(closure_arg) = closure_body.params.get(0); then { - if let hir::PatKind::Ref(..) = closure_arg.pat.node { + if let hir::PatKind::Ref(..) = closure_arg.pat.kind { Some(search_snippet.replacen('&', "", 1)) } else if let Some(name) = get_arg_name(&closure_arg.pat) { Some(search_snippet.replace(&format!("*{}", name), &name.as_str())) @@ -2516,9 +2516,9 @@ fn lint_chars_cmp( ) -> bool { if_chain! { if let Some(args) = method_chain_args(info.chain, chain_methods); - if let hir::ExprKind::Call(ref fun, ref arg_char) = info.other.node; + if let hir::ExprKind::Call(ref fun, ref arg_char) = info.other.kind; if arg_char.len() == 1; - if let hir::ExprKind::Path(ref qpath) = fun.node; + if let hir::ExprKind::Path(ref qpath) = fun.kind; if let Some(segment) = single_segment_path(qpath); if segment.ident.name == sym!(Some); then { @@ -2574,7 +2574,7 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>( ) -> bool { if_chain! { if let Some(args) = method_chain_args(info.chain, chain_methods); - if let hir::ExprKind::Lit(ref lit) = info.other.node; + if let hir::ExprKind::Lit(ref lit) = info.other.kind; if let ast::LitKind::Char(c) = lit.node; then { let mut applicability = Applicability::MachineApplicable; @@ -2616,7 +2616,7 @@ fn lint_chars_last_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: & /// lint for length-1 `str`s for methods in `PATTERN_METHODS` fn lint_single_char_pattern<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, _expr: &'tcx hir::Expr, arg: &'tcx hir::Expr) { if_chain! { - if let hir::ExprKind::Lit(lit) = &arg.node; + if let hir::ExprKind::Lit(lit) = &arg.kind; if let ast::LitKind::Str(r, style) = lit.node; if r.as_str().len() == 1; then { @@ -2659,7 +2659,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re // allow the `as_ref` or `as_mut` if it is followed by another method call if_chain! { if let Some(parent) = get_parent_expr(cx, expr); - if let hir::ExprKind::MethodCall(_, ref span, _) = parent.node; + if let hir::ExprKind::MethodCall(_, ref span, _) = parent.kind; if span != &expr.span; then { return; @@ -2725,9 +2725,9 @@ fn lint_into_iter(cx: &LateContext<'_, '_>, expr: &hir::Expr, self_ref_ty: Ty<'_ /// lint for `MaybeUninit::uninit().assume_init()` (we already have the latter) fn lint_maybe_uninit(cx: &LateContext<'_, '_>, expr: &hir::Expr, outer: &hir::Expr) { if_chain! { - if let hir::ExprKind::Call(ref callee, ref args) = expr.node; + if let hir::ExprKind::Call(ref callee, ref args) = expr.kind; if args.is_empty(); - if let hir::ExprKind::Path(ref path) = callee.node; + if let hir::ExprKind::Path(ref path) = callee.kind; if match_qpath(path, &paths::MEM_MAYBEUNINIT_UNINIT); if !is_maybe_uninit_ty_valid(cx, cx.tables.expr_ty_adjusted(outer)); then { @@ -2945,20 +2945,20 @@ enum OutType { impl OutType { fn matches(self, cx: &LateContext<'_, '_>, ty: &hir::FunctionRetTy) -> bool { - let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyKind::Tup(vec![].into())); + let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.kind, &hir::TyKind::Tup(vec![].into())); match (self, ty) { (Self::Unit, &hir::DefaultReturn(_)) => true, (Self::Unit, &hir::Return(ref ty)) if is_unit(ty) => true, (Self::Bool, &hir::Return(ref ty)) if is_bool(ty) => true, (Self::Any, &hir::Return(ref ty)) if !is_unit(ty) => true, - (Self::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyKind::Rptr(_, _)), + (Self::Ref, &hir::Return(ref ty)) => matches!(ty.kind, hir::TyKind::Rptr(_, _)), _ => false, } } } fn is_bool(ty: &hir::Ty) -> bool { - if let hir::TyKind::Path(ref p) = ty.node { + if let hir::TyKind::Path(ref p) = ty.kind { match_qpath(p, &["bool"]) } else { false @@ -2976,7 +2976,7 @@ fn contains_return(expr: &hir::Expr) -> bool { if self.found { return; } - if let hir::ExprKind::Ret(..) = &expr.node { + if let hir::ExprKind::Ret(..) = &expr.kind { self.found = true; } else { intravisit::walk_expr(self, expr); diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index 465404c5ae07..abcdc35cd888 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -15,7 +15,7 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr return; } - if let hir::ExprKind::Closure(_, _, body_id, ..) = args[1].node { + if let hir::ExprKind::Closure(_, _, body_id, ..) = args[1].kind { let body = cx.tcx.hir().body(body_id); let arg_id = body.params[0].pat.hir_id; let mutates_arg = @@ -56,14 +56,14 @@ fn check_expression<'a, 'tcx>( arg_id: hir::HirId, expr: &'tcx hir::Expr, ) -> (bool, bool) { - match &expr.node { + match &expr.kind { hir::ExprKind::Call(ref func, ref args) => { if_chain! { - if let hir::ExprKind::Path(ref path) = func.node; + if let hir::ExprKind::Path(ref path) = func.kind; then { if match_qpath(path, &paths::OPTION_SOME) { if_chain! { - if let hir::ExprKind::Path(path) = &args[0].node; + if let hir::ExprKind::Path(path) = &args[0].kind; if let Res::Local(ref local) = cx.tables.qpath_res(path, args[0].hir_id); then { if arg_id == *local { @@ -124,7 +124,7 @@ impl<'a, 'tcx> ReturnVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for ReturnVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Ret(Some(expr)) = &expr.node { + if let hir::ExprKind::Ret(Some(expr)) = &expr.kind { let (found_mapping, found_filtering) = check_expression(self.cx, self.arg_id, expr); self.found_mapping |= found_mapping; self.found_filtering |= found_filtering; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 4cc1e0e3691d..7b2d73a3b5d8 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -60,8 +60,8 @@ enum MinMax { } fn min_max<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<(MinMax, Constant, &'a Expr)> { - if let ExprKind::Call(ref path, ref args) = expr.node { - if let ExprKind::Path(ref qpath) = path.node { + if let ExprKind::Call(ref path, ref args) = expr.kind { + if let ExprKind::Path(ref qpath) = path.kind { cx.tables.qpath_res(qpath, path.hir_id).opt_def_id().and_then(|def_id| { if match_def_path(cx, def_id, &paths::CMP_MIN) { fetch_const(cx, args, MinMax::Min) diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 0cf6b6093c61..437114066cdf 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -246,7 +246,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { return; } for arg in iter_input_pats(decl, body) { - match arg.pat.node { + match arg.pat.kind { PatKind::Binding(BindingAnnotation::Ref, ..) | PatKind::Binding(BindingAnnotation::RefMut, ..) => { span_lint( cx, @@ -263,8 +263,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { if_chain! { - if let StmtKind::Local(ref local) = stmt.node; - if let PatKind::Binding(an, .., name, None) = local.pat.node; + if let StmtKind::Local(ref local) = stmt.kind; + if let PatKind::Binding(an, .., name, None) = local.pat.kind; if let Some(ref init) = local.init; then { if an == BindingAnnotation::Ref || an == BindingAnnotation::RefMut { @@ -307,8 +307,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { } }; if_chain! { - if let StmtKind::Semi(ref expr) = stmt.node; - if let ExprKind::Binary(ref binop, ref a, ref b) = expr.node; + if let StmtKind::Semi(ref expr) = stmt.kind; + if let ExprKind::Binary(ref binop, ref a, ref b) = expr.kind; if binop.node == BinOpKind::And || binop.node == BinOpKind::Or; if let Some(sugg) = Sugg::hir_opt(cx, a); then { @@ -334,7 +334,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { } fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - match expr.node { + match expr.kind { ExprKind::Cast(ref e, ref ty) => { check_cast(cx, expr.span, e, ty); return; @@ -342,10 +342,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { ExprKind::Binary(ref cmp, ref left, ref right) => { let op = cmp.node; if op.is_comparison() { - if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.node { + if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.kind { check_nan(cx, path, expr); } - if let ExprKind::Path(QPath::Resolved(_, ref path)) = right.node { + if let ExprKind::Path(QPath::Resolved(_, ref path)) = right.kind { check_nan(cx, path, expr); } check_to_owned(cx, left, right); @@ -403,7 +403,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints { // Don't lint things expanded by #[derive(...)], etc return; } - let binding = match expr.node { + let binding = match expr.kind { ExprKind::Path(ref qpath) => { let binding = last_path_segment(qpath).ident.as_str(); if binding.starts_with('_') && @@ -477,12 +477,12 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> bool { // Return true if `expr` is the result of `signum()` invoked on a float value. fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { // The negation of a signum is still a signum - if let ExprKind::Unary(UnNeg, ref child_expr) = expr.node { + if let ExprKind::Unary(UnNeg, ref child_expr) = expr.kind { return is_signum(cx, &child_expr); } if_chain! { - if let ExprKind::MethodCall(ref method_name, _, ref expressions) = expr.node; + if let ExprKind::MethodCall(ref method_name, _, ref expressions) = expr.kind; if sym!(signum) == method_name.ident.name; // Check that the receiver of the signum() is a float (expressions[0] is the receiver of // the method call) @@ -498,7 +498,7 @@ fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { } fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { - let (arg_ty, snip) = match expr.node { + let (arg_ty, snip) = match expr.kind { ExprKind::MethodCall(.., ref args) if args.len() == 1 => { if match_trait_method(cx, expr, &paths::TO_STRING) || match_trait_method(cx, expr, &paths::TO_OWNED) { (cx.tables.expr_ty_adjusted(&args[0]), snippet(cx, args[0].span, "..")) @@ -507,7 +507,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { } }, ExprKind::Call(ref path, ref v) if v.len() == 1 => { - if let ExprKind::Path(ref path) = path.node { + if let ExprKind::Path(ref path) = path.kind { if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) { (cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, "..")) } else { @@ -538,7 +538,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { return; } - let other_gets_derefed = match other.node { + let other_gets_derefed = match other.kind { ExprKind::Unary(UnDeref, _) => true, _ => false, }; @@ -584,7 +584,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { /// of what it means for an expression to be "used". fn is_used(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { if let Some(parent) = get_parent_expr(cx, expr) { - match parent.node { + match parent.kind { ExprKind::Assign(_, ref rhs) | ExprKind::AssignOp(_, _, ref rhs) => SpanlessEq::new(cx).eq_expr(rhs, expr), _ => is_used(cx, parent), } @@ -621,8 +621,8 @@ fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool { fn check_cast(cx: &LateContext<'_, '_>, span: Span, e: &Expr, ty: &Ty) { if_chain! { - if let TyKind::Ptr(MutTy { mutbl, .. }) = ty.node; - if let ExprKind::Lit(ref lit) = e.node; + if let TyKind::Ptr(MutTy { mutbl, .. }) = ty.kind; + if let ExprKind::Lit(ref lit) = e.kind; if let LitKind::Int(value, ..) = lit.node; if value == 0; if !in_constant(cx, e.hir_id); diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 588f5f75c1e7..43a5e5c1b4b1 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -260,9 +260,9 @@ impl ReturnVisitor { impl<'ast> Visitor<'ast> for ReturnVisitor { fn visit_expr(&mut self, ex: &'ast Expr) { - if let ExprKind::Ret(_) = ex.node { + if let ExprKind::Ret(_) = ex.kind { self.found_return = true; - } else if let ExprKind::Try(_) = ex.node { + } else if let ExprKind::Try(_) = ex.kind { self.found_return = true; } @@ -288,7 +288,7 @@ impl EarlyLintPass for MiscEarlyLints { } fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &Pat) { - if let PatKind::Struct(ref npat, ref pfields, _) = pat.node { + if let PatKind::Struct(ref npat, ref pfields, _) = pat.kind { let mut wilds = 0; let type_name = npat .segments @@ -298,7 +298,7 @@ impl EarlyLintPass for MiscEarlyLints { .name; for field in pfields { - if let PatKind::Wild = field.pat.node { + if let PatKind::Wild = field.pat.kind { wilds += 1; } } @@ -316,7 +316,7 @@ impl EarlyLintPass for MiscEarlyLints { let mut normal = vec![]; for field in pfields { - match field.pat.node { + match field.pat.kind { PatKind::Wild => {}, _ => { if let Ok(n) = cx.sess().source_map().span_to_snippet(field.span) { @@ -326,7 +326,7 @@ impl EarlyLintPass for MiscEarlyLints { } } for field in pfields { - if let PatKind::Wild = field.pat.node { + if let PatKind::Wild = field.pat.kind { wilds -= 1; if wilds > 0 { span_lint( @@ -350,8 +350,8 @@ impl EarlyLintPass for MiscEarlyLints { } } - if let PatKind::Ident(_, ident, Some(ref right)) = pat.node { - if let PatKind::Wild = right.node { + if let PatKind::Ident(_, ident, Some(ref right)) = pat.kind { + if let PatKind::Wild = right.kind { span_lint_and_sugg( cx, REDUNDANT_PATTERN, @@ -374,7 +374,7 @@ impl EarlyLintPass for MiscEarlyLints { let mut registered_names: FxHashMap = FxHashMap::default(); for arg in &decl.inputs { - if let PatKind::Ident(_, ident, None) = arg.pat.node { + if let PatKind::Ident(_, ident, None) = arg.pat.kind { let arg_name = ident.to_string(); if arg_name.starts_with('_') { @@ -401,10 +401,10 @@ impl EarlyLintPass for MiscEarlyLints { if in_external_macro(cx.sess(), expr.span) { return; } - match expr.node { + match expr.kind { ExprKind::Call(ref paren, _) => { - if let ExprKind::Paren(ref closure) = paren.node { - if let ExprKind::Closure(_, _, _, ref decl, ref block, _) = closure.node { + if let ExprKind::Paren(ref closure) = paren.kind { + if let ExprKind::Closure(_, _, _, ref decl, ref block, _) = closure.kind { let mut visitor = ReturnVisitor::new(); visitor.visit_expr(block); if !visitor.found_return { @@ -427,7 +427,7 @@ impl EarlyLintPass for MiscEarlyLints { } }, ExprKind::Unary(UnOp::Neg, ref inner) => { - if let ExprKind::Unary(UnOp::Neg, _) = inner.node { + if let ExprKind::Unary(UnOp::Neg, _) = inner.kind { span_lint( cx, DOUBLE_NEG, @@ -444,14 +444,14 @@ impl EarlyLintPass for MiscEarlyLints { fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) { for w in block.stmts.windows(2) { if_chain! { - if let StmtKind::Local(ref local) = w[0].node; + if let StmtKind::Local(ref local) = w[0].kind; if let Option::Some(ref t) = local.init; - if let ExprKind::Closure(..) = t.node; - if let PatKind::Ident(_, ident, _) = local.pat.node; - if let StmtKind::Semi(ref second) = w[1].node; - if let ExprKind::Assign(_, ref call) = second.node; - if let ExprKind::Call(ref closure, _) = call.node; - if let ExprKind::Path(_, ref path) = closure.node; + if let ExprKind::Closure(..) = t.kind; + if let PatKind::Ident(_, ident, _) = local.pat.kind; + if let StmtKind::Semi(ref second) = w[1].kind; + if let ExprKind::Assign(_, ref call) = second.kind; + if let ExprKind::Call(ref closure, _) = call.kind; + if let ExprKind::Path(_, ref path) = closure.kind; then { if ident == path.segments[0].ident { span_lint( @@ -479,7 +479,7 @@ impl MiscEarlyLints { _ => return, }; - if let LitKind::Int(value, lit_int_type) = lit.node { + if let LitKind::Int(value, lit_int_type) = lit.kind { let suffix = match lit_int_type { LitIntType::Signed(ty) => ty.ty_to_string(), LitIntType::Unsigned(ty) => ty.ty_to_string(), @@ -542,7 +542,7 @@ impl MiscEarlyLints { }, ); } - } else if let LitKind::Float(_, float_ty) = lit.node { + } else if let LitKind::Float(_, float_ty) = lit.kind { let suffix = float_ty.ty_to_string(); let maybe_last_sep_idx = lit_snip.len() - suffix.len() - 1; if lit_snip.as_bytes()[maybe_last_sep_idx] != b'_' { @@ -561,7 +561,7 @@ impl MiscEarlyLints { } fn check_unneeded_wildcard_pattern(cx: &EarlyContext<'_>, pat: &Pat) { - if let PatKind::TupleStruct(_, ref patterns) | PatKind::Tuple(ref patterns) = pat.node { + if let PatKind::TupleStruct(_, ref patterns) | PatKind::Tuple(ref patterns) = pat.kind { fn span_lint(cx: &EarlyContext<'_>, span: Span, only_one: bool) { span_lint_and_sugg( cx, @@ -580,7 +580,7 @@ fn check_unneeded_wildcard_pattern(cx: &EarlyContext<'_>, pat: &Pat) { #[allow(clippy::trivially_copy_pass_by_ref)] fn is_wild>(pat: &&P) -> bool { - if let PatKind::Wild = pat.node { + if let PatKind::Wild = pat.kind { true } else { false diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 33d1fce4e2a6..f09a864240ba 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -56,7 +56,7 @@ impl MissingDoc { fn has_include(meta: Option) -> bool { if_chain! { if let Some(meta) = meta; - if let MetaItemKind::List(list) = meta.node; + if let MetaItemKind::List(list) = meta.kind; if let Some(meta) = list.get(0); if let Some(name) = meta.ident(); then { @@ -127,7 +127,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) { - let desc = match it.node { + let desc = match it.kind { hir::ItemKind::Const(..) => "a constant", hir::ItemKind::Enum(..) => "an enum", hir::ItemKind::Fn(..) => { @@ -160,7 +160,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) { - let desc = match trait_item.node { + let desc = match trait_item.kind { hir::TraitItemKind::Const(..) => "an associated constant", hir::TraitItemKind::Method(..) => "a trait method", hir::TraitItemKind::Type(..) => "an associated type", @@ -181,7 +181,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { }, } - let desc = match impl_item.node { + let desc = match impl_item.kind { hir::ImplItemKind::Const(..) => "an associated constant", hir::ImplItemKind::Method(..) => "a method", hir::ImplItemKind::TyAlias(_) => "an associated type", diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 865543ce3d86..d9cd78dcd41d 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -88,7 +88,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { if !cx.access_levels.is_exported(it.hir_id) { return; } - match it.node { + match it.kind { hir::ItemKind::Fn(..) => { let desc = "a function"; check_missing_inline_attrs(cx, &it.attrs, it.span, desc); @@ -98,7 +98,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { // `LateLintPass::check_trait_item` here. for tit in trait_items { let tit_ = cx.tcx.hir().trait_item(tit.id); - match tit_.node { + match tit_.kind { hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {}, hir::TraitItemKind::Method(..) => { if tit.defaultness.has_value() { @@ -140,7 +140,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { return; } - let desc = match impl_item.node { + let desc = match impl_item.kind { hir::ImplItemKind::Method(..) => "a method", hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) | hir::ImplItemKind::OpaqueTy(_) => return, }; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 457062d5dd1b..37f9197549d1 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -57,8 +57,8 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { // Let's ignore the generated code. intravisit::walk_expr(self, arg); intravisit::walk_expr(self, body); - } else if let hir::ExprKind::AddrOf(hir::MutMutable, ref e) = expr.node { - if let hir::ExprKind::AddrOf(hir::MutMutable, _) = e.node { + } else if let hir::ExprKind::AddrOf(hir::MutMutable, ref e) = expr.kind { + if let hir::ExprKind::AddrOf(hir::MutMutable, _) = e.kind { span_lint( self.cx, MUT_MUT, @@ -83,14 +83,14 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { ty: ref pty, mutbl: hir::MutMutable, }, - ) = ty.node + ) = ty.kind { if let hir::TyKind::Rptr( _, hir::MutTy { mutbl: hir::MutMutable, .. }, - ) = pty.node + ) = pty.kind { span_lint( self.cx, diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index e8f3beb9f923..798699eeea66 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -27,9 +27,9 @@ declare_lint_pass!(UnnecessaryMutPassed => [UNNECESSARY_MUT_PASSED]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - match e.node { + match e.kind { ExprKind::Call(ref fn_expr, ref arguments) => { - if let ExprKind::Path(ref path) = fn_expr.node { + if let ExprKind::Path(ref path) = fn_expr.kind { check_arguments( cx, arguments, @@ -59,7 +59,7 @@ fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], typ | ty::RawPtr(ty::TypeAndMut { mutbl: MutImmutable, .. }) => { - if let ExprKind::AddrOf(MutMutable, _) = argument.node { + if let ExprKind::AddrOf(MutMutable, _) = argument.kind { span_lint( cx, UNNECESSARY_MUT_PASSED, diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index d19939be6c0d..dffce2215dce 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool { applicability, ); }; - if let ExprKind::Block(ref then_block, _) = then_block.node { + if let ExprKind::Block(ref then_block, _) = then_block.kind { match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) { (RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => { span_lint( @@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison { return; } - if let ExprKind::Binary(Spanned { node, .. }, ..) = e.node { + if let ExprKind::Binary(Spanned { node, .. }, ..) = e.kind { let ignore_case = None::<(fn(_) -> _, &str)>; let ignore_no_literal = None::<(fn(_, _) -> _, &str)>; match node { @@ -193,7 +193,7 @@ fn check_comparison<'a, 'tcx>( ) { use self::Expression::*; - if let ExprKind::Binary(_, ref left_side, ref right_side) = e.node { + if let ExprKind::Binary(_, ref left_side, ref right_side) = e.kind { let (l_ty, r_ty) = (cx.tables.expr_ty(left_side), cx.tables.expr_ty(right_side)); if l_ty.is_bool() && r_ty.is_bool() { let mut applicability = Applicability::MachineApplicable; @@ -259,8 +259,8 @@ fn fetch_bool_block(block: &Block) -> Expression { match (&*block.stmts, block.expr.as_ref()) { (&[], Some(e)) => fetch_bool_expr(&**e), (&[ref e], None) => { - if let StmtKind::Semi(ref e) = e.node { - if let ExprKind::Ret(_) = e.node { + if let StmtKind::Semi(ref e) = e.kind { + if let ExprKind::Ret(_) = e.kind { fetch_bool_expr(&**e) } else { Expression::Other @@ -274,7 +274,7 @@ fn fetch_bool_block(block: &Block) -> Expression { } fn fetch_bool_expr(expr: &Expr) -> Expression { - match expr.node { + match expr.kind { ExprKind::Block(ref block, _) => fetch_bool_block(block), ExprKind::Lit(ref lit_ptr) => { if let LitKind::Bool(value) = lit_ptr.node { diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index da363a9b6d67..8093a06ab6fe 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { if e.span.from_expansion() || self.derived_item.is_some() { return; } - if let ExprKind::AddrOf(MutImmutable, ref inner) = e.node { + if let ExprKind::AddrOf(MutImmutable, ref inner) = e.kind { if let ty::Ref(..) = cx.tables.expr_ty(inner).kind { for adj3 in cx.tables.expr_adjustments(e).windows(3) { if let [Adjustment { @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { return; } if_chain! { - if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.node; + if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.kind; if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).kind; if mutbl == MutImmutable; if let ty::Ref(_, _, mutbl) = tam.kind; diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 9afa67dadd14..2c4c5461ae1f 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -61,10 +61,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef { if_chain! { // Only lint immutable refs, because `&mut ref T` may be useful. - if let PatKind::Ref(ref sub_pat, MutImmutable) = pat.node; + if let PatKind::Ref(ref sub_pat, MutImmutable) = pat.kind; // Check sub_pat got a `ref` keyword (excluding `ref mut`). - if let PatKind::Binding(BindingAnnotation::Ref, .., spanned_name, _) = sub_pat.node; + if let PatKind::Binding(BindingAnnotation::Ref, .., spanned_name, _) = sub_pat.kind; let parent_id = cx.tcx.hir().get_parent_node(pat.hir_id); if let Some(parent_node) = cx.tcx.hir().find(parent_id); then { diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 79da82ae3e20..bd9d1583493c 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -181,7 +181,7 @@ impl EarlyLintPass for NeedlessContinue { /// - The expression node is a block with the first statement being a /// `continue`. fn needless_continue_in_else(else_expr: &ast::Expr, label: Option<&ast::Label>) -> bool { - match else_expr.node { + match else_expr.kind { ast::ExprKind::Block(ref else_block, _) => is_first_block_stmt_continue(else_block, label), ast::ExprKind::Continue(l) => compare_labels(label, l.as_ref()), _ => false, @@ -189,9 +189,9 @@ fn needless_continue_in_else(else_expr: &ast::Expr, label: Option<&ast::Label>) } fn is_first_block_stmt_continue(block: &ast::Block, label: Option<&ast::Label>) -> bool { - block.stmts.get(0).map_or(false, |stmt| match stmt.node { + block.stmts.get(0).map_or(false, |stmt| match stmt.kind { ast::StmtKind::Semi(ref e) | ast::StmtKind::Expr(ref e) => { - if let ast::ExprKind::Continue(ref l) = e.node { + if let ast::ExprKind::Continue(ref l) = e.kind { compare_labels(label, l.as_ref()) } else { false @@ -221,7 +221,7 @@ where { if let ast::ExprKind::While(_, loop_block, label) | ast::ExprKind::ForLoop(_, _, loop_block, label) - | ast::ExprKind::Loop(loop_block, label) = &expr.node + | ast::ExprKind::Loop(loop_block, label) = &expr.kind { func(loop_block, label.as_ref()); } @@ -239,9 +239,9 @@ fn with_if_expr(stmt: &ast::Stmt, mut func: F) where F: FnMut(&ast::Expr, &ast::Expr, &ast::Block, &ast::Expr), { - match stmt.node { + match stmt.kind { ast::StmtKind::Semi(ref e) | ast::StmtKind::Expr(ref e) => { - if let ast::ExprKind::If(ref cond, ref if_block, Some(ref else_expr)) = e.node { + if let ast::ExprKind::If(ref cond, ref if_block, Some(ref else_expr)) = e.kind { func(e, cond, if_block, else_expr); } }, diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 66e84a404c54..e2ac39f82628 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Exclude non-inherent impls if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { - if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | + if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { return; @@ -160,7 +160,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Ignore `self`s. if idx == 0 { - if let PatKind::Binding(.., ident, _) = arg.pat.node { + if let PatKind::Binding(.., ident, _) = arg.pat.kind { if ident.as_str() == "self" { continue; } @@ -202,7 +202,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if !implements_borrow_trait; if !all_borrowable_trait; - if let PatKind::Binding(mode, canonical_id, ..) = arg.pat.node; + if let PatKind::Binding(mode, canonical_id, ..) = arg.pat.kind; if !moved_vars.contains(&canonical_id); then { if mode == BindingAnnotation::Mutable || mode == BindingAnnotation::RefMut { @@ -224,7 +224,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")); if let Some(clone_spans) = get_spans(cx, Some(body.id()), idx, &[("clone", ".to_owned()")]); - if let TyKind::Path(QPath::Resolved(_, ref path)) = input.node; + if let TyKind::Path(QPath::Resolved(_, ref path)) = input.kind; if let Some(elem_ty) = path.segments.iter() .find(|seg| seg.ident.name == sym!(Vec)) .and_then(|ps| ps.args.as_ref()) @@ -367,7 +367,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { match node { Node::Expr(e) => { // `match` and `if let` - if let ExprKind::Match(ref c, ..) = e.node { + if let ExprKind::Match(ref c, ..) = e.kind { self.spans_need_deref .entry(vid) .or_insert_with(FxHashSet::default) @@ -378,7 +378,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { Node::Stmt(s) => { // `let = x;` if_chain! { - if let StmtKind::Local(ref local) = s.node; + if let StmtKind::Local(ref local) = s.kind; then { self.spans_need_deref .entry(vid) diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 8cc27182d83c..a92523eb5523 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -36,7 +36,7 @@ declare_lint_pass!(NeedlessUpdate => [NEEDLESS_UPDATE]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessUpdate { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.node { + if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.kind { let ty = cx.tables.expr_ty(expr); if let ty::Adt(def, _) = ty.kind { if fields.len() == def.non_enum_variant().fields.len() { diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index e05a953b3060..f25a00ca6927 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -49,8 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd { if_chain! { if !in_external_macro(cx.sess(), expr.span); - if let ExprKind::Unary(UnOp::UnNot, ref inner) = expr.node; - if let ExprKind::Binary(ref op, ref left, _) = inner.node; + if let ExprKind::Unary(UnOp::UnNot, ref inner) = expr.kind; + if let ExprKind::Binary(ref op, ref left, _) = inner.kind; if let BinOpKind::Le | BinOpKind::Ge | BinOpKind::Lt | BinOpKind::Gt = op.node; then { diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index c235661a432b..b4901cd3ffdb 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -34,9 +34,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply { }, ref l, ref r, - ) = e.node + ) = e.kind { - match (&l.node, &r.node) { + match (&l.kind, &r.kind) { (&ExprKind::Unary(..), &ExprKind::Unary(..)) => (), (&ExprKind::Unary(UnNeg, ref lit), _) => check_mul(cx, e.span, lit, r), (_, &ExprKind::Unary(UnNeg, ref lit)) => check_mul(cx, e.span, lit, l), @@ -48,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply { fn check_mul(cx: &LateContext<'_, '_>, span: Span, lit: &Expr, exp: &Expr) { if_chain! { - if let ExprKind::Lit(ref l) = lit.node; + if let ExprKind::Lit(ref l) = lit.kind; if let Constant::Int(val) = consts::lit_to_constant(&l.node, cx.tables.expr_ty(lit)); if val == 1; if cx.tables.expr_ty(exp).is_integral(); diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 16c8e2c4c479..f6bb2e4cf567 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -93,14 +93,14 @@ impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { - if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.node { + if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.kind { for assoc_item in items { if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind { let impl_item = cx.tcx.hir().impl_item(assoc_item.id); if in_external_macro(cx.sess(), impl_item.span) { return; } - if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node { + if let hir::ImplItemKind::Method(ref sig, _) = impl_item.kind { let name = impl_item.ident.name; let id = impl_item.hir_id; if sig.header.constness == hir::Constness::Const { diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 571e664d4d47..f8cbfc434fec 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -46,7 +46,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { if expr.span.from_expansion() { return false; } - match expr.node { + match expr.kind { ExprKind::Lit(..) | ExprKind::Closure(..) => true, ExprKind::Path(..) => !has_drop(cx, cx.tables.expr_ty(expr)), ExprKind::Index(ref a, ref b) | ExprKind::Binary(_, ref a, ref b) => { @@ -66,7 +66,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { && base.as_ref().map_or(true, |base| has_no_effect(cx, base)) }, ExprKind::Call(ref callee, ref args) => { - if let ExprKind::Path(ref qpath) = callee.node { + if let ExprKind::Path(ref qpath) = callee.kind { let res = qpath_res(cx, qpath, callee.hir_id); match res { Res::Def(DefKind::Struct, ..) | Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(..), _) => { @@ -89,7 +89,7 @@ declare_lint_pass!(NoEffect => [NO_EFFECT, UNNECESSARY_OPERATION]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoEffect { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtKind::Semi(ref expr) = stmt.node { + if let StmtKind::Semi(ref expr) = stmt.kind { if has_no_effect(cx, expr) { span_lint(cx, NO_EFFECT, stmt.span, "statement with no effect"); } else if let Some(reduced) = reduce_expression(cx, expr) { @@ -123,7 +123,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option Some(vec![&**a, &**b]), ExprKind::Binary(ref binop, ref a, ref b) if binop.node != BinOpKind::And && binop.node != BinOpKind::Or => { Some(vec![&**a, &**b]) @@ -144,7 +144,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option { - if let ExprKind::Path(ref qpath) = callee.node { + if let ExprKind::Path(ref qpath) = callee.kind { let res = qpath_res(cx, qpath, callee.hir_id); match res { Res::Def(DefKind::Struct, ..) | Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(..), _) diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 90a31f710f4d..33f1dde98728 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -142,14 +142,14 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx Item) { - if let ItemKind::Const(hir_ty, ..) = &it.node { + if let ItemKind::Const(hir_ty, ..) = &it.kind { let ty = hir_ty_to_ty(cx.tcx, hir_ty); verify_ty_bound(cx, ty, Source::Item { item: it.span }); } } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx TraitItem) { - if let TraitItemKind::Const(hir_ty, ..) = &trait_item.node { + if let TraitItemKind::Const(hir_ty, ..) = &trait_item.kind { let ty = hir_ty_to_ty(cx.tcx, hir_ty); verify_ty_bound( cx, @@ -163,11 +163,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) { - if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node { + if let ImplItemKind::Const(hir_ty, ..) = &impl_item.kind { let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id); let item = cx.tcx.hir().expect_item(item_hir_id); // Ensure the impl is an inherent impl. - if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, None, _, _) = item.kind { let ty = hir_ty_to_ty(cx.tcx, hir_ty); verify_ty_bound( cx, @@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { } fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Path(qpath) = &expr.node { + if let ExprKind::Path(qpath) = &expr.kind { // Only lint if we use the const item inside a function. if in_constant(cx, expr.hir_id) { return; @@ -204,7 +204,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { break; } if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find(parent_id) { - match &parent_expr.node { + match &parent_expr.kind { ExprKind::AddrOf(..) => { // `&e` => `e` must be referenced. needs_check_adjustment = false; diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index ff06eaca465e..25e8efe3cad6 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -128,7 +128,7 @@ struct SimilarNamesNameVisitor<'a, 'tcx, 'b>(&'b mut SimilarNamesLocalVisitor<'a impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { fn visit_pat(&mut self, pat: &'tcx Pat) { - match pat.node { + match pat.kind { PatKind::Ident(_, ident, _) => self.check_ident(ident), PatKind::Struct(_, ref fields, _) => { for field in fields { @@ -350,13 +350,13 @@ impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> { impl EarlyLintPass for NonExpressiveNames { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Fn(ref decl, _, _, ref blk) = item.node { + if let ItemKind::Fn(ref decl, _, _, ref blk) = item.kind { do_check(self, cx, &item.attrs, decl, blk); } } fn check_impl_item(&mut self, cx: &EarlyContext<'_>, item: &ImplItem) { - if let ImplItemKind::Method(ref sig, ref blk) = item.node { + if let ImplItemKind::Method(ref sig, ref blk) = item.kind { do_check(self, cx, &item.attrs, &sig.decl, blk); } } diff --git a/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index 7105376d5983..6973909b70d6 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -39,10 +39,10 @@ declare_lint_pass!(OkIfLet => [IF_LET_SOME_RESULT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OkIfLet { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { //begin checking variables - if let ExprKind::Match(ref op, ref body, ref source) = expr.node; //test if expr is a match + if let ExprKind::Match(ref op, ref body, ref source) = expr.kind; //test if expr is a match if let MatchSource::IfLetDesugar { .. } = *source; //test if it is an If Let - if let ExprKind::MethodCall(_, _, ref result_types) = op.node; //check is expr.ok() has type Result.ok() - if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.node; //get operation + if let ExprKind::MethodCall(_, _, ref result_types) = op.kind; //check is expr.ok() has type Result.ok() + if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.kind; //get operation if method_chain_args(op, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized; then { diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 5a3af2c3773f..cc8d17e28147 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -29,7 +29,7 @@ declare_lint_pass!(OpenOptions => [NONSENSICAL_OPEN_OPTIONS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OpenOptions { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::MethodCall(ref path, _, ref arguments) = e.node { + if let ExprKind::MethodCall(ref path, _, ref arguments) = e.kind { let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(&arguments[0])); if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) { let mut options = Vec::new(); @@ -57,12 +57,12 @@ enum OpenOption { } fn get_open_options(cx: &LateContext<'_, '_>, argument: &Expr, options: &mut Vec<(OpenOption, Argument)>) { - if let ExprKind::MethodCall(ref path, _, ref arguments) = argument.node { + if let ExprKind::MethodCall(ref path, _, ref arguments) = argument.kind { let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(&arguments[0])); // Only proceed if this is a call on some object of type std::fs::OpenOptions if match_type(cx, obj_ty, &paths::OPEN_OPTIONS) && arguments.len() >= 2 { - let argument_option = match arguments[1].node { + let argument_option = match arguments[1].kind { ExprKind::Lit(ref span) => { if let Spanned { node: LitKind::Bool(lit), diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index f4c301958b9e..b14f04d0ae0c 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -30,11 +30,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { let eq = |l, r| SpanlessEq::new(cx).eq_path_segment(l, r); if_chain! { - if let ExprKind::Binary(ref op, ref first, ref second) = expr.node; - if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = first.node; - if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.node; - if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.node; - if let ExprKind::Path(QPath::Resolved(_, ref path3)) = second.node; + if let ExprKind::Binary(ref op, ref first, ref second) = expr.kind; + if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = first.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path3)) = second.kind; if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]); if cx.tables.expr_ty(ident1).is_integral(); if cx.tables.expr_ty(ident2).is_integral(); @@ -55,11 +55,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional { } if_chain! { - if let ExprKind::Binary(ref op, ref first, ref second) = expr.node; - if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = second.node; - if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.node; - if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.node; - if let ExprKind::Path(QPath::Resolved(_, ref path3)) = first.node; + if let ExprKind::Binary(ref op, ref first, ref second) = expr.kind; + if let ExprKind::Binary(ref op2, ref ident1, ref ident2) = second.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path1)) = ident1.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path3)) = first.kind; if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]); if cx.tables.expr_ty(ident1).is_integral(); if cx.tables.expr_ty(ident2).is_integral(); diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index 617ac2393d51..4b0fbc5e15b4 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -47,10 +47,10 @@ declare_lint_pass!(PanicUnimplemented => [PANIC_PARAMS, UNIMPLEMENTED]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Block(ref block, _) = expr.node; + if let ExprKind::Block(ref block, _) = expr.kind; if let Some(ref ex) = block.expr; - if let ExprKind::Call(ref fun, ref params) = ex.node; - if let ExprKind::Path(ref qpath) = fun.node; + if let ExprKind::Call(ref fun, ref params) = ex.kind; + if let ExprKind::Path(ref qpath) = fun.kind; if let Some(fun_def_id) = resolve_node(cx, qpath, fun.hir_id).opt_def_id(); if match_def_path(cx, fun_def_id, &paths::BEGIN_PANIC); if params.len() == 2; @@ -83,7 +83,7 @@ fn get_outer_span(expr: &Expr) -> Span { fn match_panic(params: &P<[Expr]>, expr: &Expr, cx: &LateContext<'_, '_>) { if_chain! { - if let ExprKind::Lit(ref lit) = params[0].node; + if let ExprKind::Lit(ref lit) = params[0].kind; if is_direct_expn_of(expr.span, "panic").is_some(); if let LitKind::Str(ref string, _) = lit.node; let string = string.as_str().replace("{{", "").replace("}}", ""); diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 805efa7cf20a..ad046edf29e4 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -33,7 +33,7 @@ declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PartialEqNeImpl { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { if_chain! { - if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node; + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.kind; if !is_automatically_derived(&*item.attrs); if let Some(eq_trait) = cx.tcx.lang_items().eq_trait(); if trait_ref.path.res.def_id() == eq_trait; diff --git a/clippy_lints/src/path_buf_push_overwrite.rs b/clippy_lints/src/path_buf_push_overwrite.rs index 8ebb5150ab47..464845c3c741 100644 --- a/clippy_lints/src/path_buf_push_overwrite.rs +++ b/clippy_lints/src/path_buf_push_overwrite.rs @@ -43,12 +43,12 @@ declare_lint_pass!(PathBufPushOverwrite => [PATH_BUF_PUSH_OVERWRITE]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathBufPushOverwrite { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node; + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; if path.ident.name == sym!(push); if args.len() == 2; if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::PATH_BUF); if let Some(get_index_arg) = args.get(1); - if let ExprKind::Lit(ref lit) = get_index_arg.node; + if let ExprKind::Lit(ref lit) = get_index_arg.kind; if let LitKind::Str(ref path_lit, _) = lit.node; if let pushed_path = Path::new(&path_lit.as_str()); if let Some(pushed_path_lit) = pushed_path.to_str(); diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 8e57b8ed7785..b00062cd55a1 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -36,7 +36,7 @@ impl EarlyLintPass for Precedence { return; } - if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node { + if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.kind { let span_sugg = |expr: &Expr, sugg, appl| { span_lint_and_sugg( cx, @@ -85,11 +85,11 @@ impl EarlyLintPass for Precedence { } } - if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.node { - if let ExprKind::MethodCall(_, ref args) = rhs.node { + if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.kind { + if let ExprKind::MethodCall(_, ref args) = rhs.kind { if let Some(slf) = args.first() { - if let ExprKind::Lit(ref lit) = slf.node { - match lit.node { + if let ExprKind::Lit(ref lit) = slf.kind { + match lit.kind { LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( @@ -115,7 +115,7 @@ impl EarlyLintPass for Precedence { } fn is_arith_expr(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Binary(Spanned { node: op, .. }, _, _) => is_arith_op(op), _ => false, } diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index f5cc89a73304..8b9e39e34277 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -101,16 +101,16 @@ declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Fn(ref decl, _, _, body_id) = item.node { + if let ItemKind::Fn(ref decl, _, _, body_id) = item.kind { check_fn(cx, decl, item.hir_id, Some(body_id)); } } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { - if let ImplItemKind::Method(ref sig, body_id) = item.node { + if let ImplItemKind::Method(ref sig, body_id) = item.kind { let parent_item = cx.tcx.hir().get_parent_item(item.hir_id); if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) { - if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node { + if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.kind { return; // ignore trait impls } } @@ -119,7 +119,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr { } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { - if let TraitItemKind::Method(ref sig, ref trait_method) = item.node { + if let TraitItemKind::Method(ref sig, ref trait_method) = item.kind { let body_id = if let TraitMethod::Provided(b) = *trait_method { Some(b) } else { @@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr { } fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Binary(ref op, ref l, ref r) = expr.node { + if let ExprKind::Binary(ref op, ref l, ref r) = expr.kind { if (op.node == BinOpKind::Eq || op.node == BinOpKind::Ne) && (is_null_path(l) || is_null_path(r)) { span_lint( cx, @@ -154,7 +154,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) { let mut ty_snippet = None; if_chain! { - if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).node; + if let TyKind::Path(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).kind; if let Some(&PathSegment{args: Some(ref parameters), ..}) = path.segments.last(); then { let types: Vec<_> = parameters.args.iter().filter_map(|arg| match arg { @@ -219,8 +219,8 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: } } else if match_type(cx, ty, &paths::COW) { if_chain! { - if let TyKind::Rptr(_, MutTy { ref ty, ..} ) = arg.node; - if let TyKind::Path(ref path) = ty.node; + if let TyKind::Rptr(_, MutTy { ref ty, ..} ) = arg.kind; + if let TyKind::Path(ref path) = ty.kind; if let QPath::Resolved(None, ref pp) = *path; if let [ref bx] = *pp.segments; if let Some(ref params) = bx.args; @@ -285,7 +285,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: } fn get_rptr_lm(ty: &Ty) -> Option<(&Lifetime, Mutability, Span)> { - if let TyKind::Rptr(ref lt, ref m) = ty.node { + if let TyKind::Rptr(ref lt, ref m) = ty.kind { Some((lt, m.mutbl, ty.span)) } else { None @@ -293,9 +293,9 @@ fn get_rptr_lm(ty: &Ty) -> Option<(&Lifetime, Mutability, Span)> { } fn is_null_path(expr: &Expr) -> bool { - if let ExprKind::Call(ref pathexp, ref args) = expr.node { + if let ExprKind::Call(ref pathexp, ref args) = expr.kind { if args.is_empty() { - if let ExprKind::Path(ref path) = pathexp.node { + if let ExprKind::Path(ref path) = pathexp.kind { return match_qpath(path, &paths::PTR_NULL) || match_qpath(path, &paths::PTR_NULL_MUT); } } diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index ffd6d4ca0f56..d2e48e1d7984 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PtrOffsetWithCast { // If the given expression is a cast from a usize, return the lhs of the cast fn expr_as_cast_from_usize<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> Option<&'tcx Expr> { - if let ExprKind::Cast(ref cast_lhs_expr, _) = expr.node { + if let ExprKind::Cast(ref cast_lhs_expr, _) = expr.kind { if is_expr_ty_usize(cx, &cast_lhs_expr) { return Some(cast_lhs_expr); } @@ -90,7 +90,7 @@ fn expr_as_ptr_offset_call<'a, 'tcx>( cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, ) -> Option<(&'tcx Expr, &'tcx Expr, Method)> { - if let ExprKind::MethodCall(ref path_segment, _, ref args) = expr.node { + if let ExprKind::MethodCall(ref path_segment, _, ref args) = expr.kind { if is_expr_ty_raw_ptr(cx, &args[0]) { if path_segment.ident.name == sym!(offset) { return Some((&args[0], &args[1], Method::Offset)); diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 7e3453e260c4..fd8133066e4f 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -49,7 +49,7 @@ impl QuestionMark { fn check_is_none_and_early_return_none(cx: &LateContext<'_, '_>, expr: &Expr) { if_chain! { if let Some((if_expr, body, else_)) = higher::if_block(&expr); - if let ExprKind::MethodCall(segment, _, args) = &if_expr.node; + if let ExprKind::MethodCall(segment, _, args) = &if_expr.kind; if segment.ident.name == sym!(is_none); if Self::expression_returns_none(cx, body); if let Some(subject) = args.get(0); @@ -60,7 +60,7 @@ impl QuestionMark { let mut replacement: Option = None; if let Some(else_) = else_ { if_chain! { - if let ExprKind::Block(block, None) = &else_.node; + if let ExprKind::Block(block, None) = &else_.kind; if block.stmts.len() == 0; if let Some(block_expr) = &block.expr; if SpanlessEq::new(cx).ignore_fn().eq_expr(subject, block_expr); @@ -107,7 +107,7 @@ impl QuestionMark { } fn expression_returns_none(cx: &LateContext<'_, '_>, expression: &Expr) -> bool { - match expression.node { + match expression.kind { ExprKind::Block(ref block, _) => { if let Some(return_expression) = Self::return_expression(block) { return Self::expression_returns_none(cx, &return_expression); @@ -134,8 +134,8 @@ impl QuestionMark { if_chain! { if block.stmts.len() == 1; if let Some(expr) = block.stmts.iter().last(); - if let StmtKind::Semi(ref expr) = expr.node; - if let ExprKind::Ret(ref ret_expr) = expr.node; + if let StmtKind::Semi(ref expr) = expr.kind; + if let ExprKind::Ret(ref ret_expr) = expr.kind; if let &Some(ref ret_expr) = ret_expr; then { @@ -146,7 +146,7 @@ impl QuestionMark { // Check for `return` without a semicolon. if_chain! { if block.stmts.len() == 0; - if let Some(ExprKind::Ret(Some(ret_expr))) = block.expr.as_ref().map(|e| &e.node); + if let Some(ExprKind::Ret(Some(ret_expr))) = block.expr.as_ref().map(|e| &e.kind); then { return Some(ret_expr); } diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 0fb40ee9f56b..03a969c9e0c7 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -109,7 +109,7 @@ declare_lint_pass!(Ranges => [ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node { + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind { let name = path.ident.as_str(); // Range with step_by(0). @@ -124,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges { ); } } else if name == "zip" && args.len() == 2 { - let iter = &args[0].node; + let iter = &args[0].kind; let zip_arg = &args[1]; if_chain! { // `.iter()` call @@ -134,11 +134,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges { if let Some(higher::Range { start: Some(start), end: Some(end), .. }) = higher::range(cx, zip_arg); if is_integer_const(cx, start, 0); // `.len()` call - if let ExprKind::MethodCall(ref len_path, _, ref len_args) = end.node; + if let ExprKind::MethodCall(ref len_path, _, ref len_args) = end.kind; if len_path.ident.name == sym!(len) && len_args.len() == 1; // `.iter()` and `.len()` called on same `Path` - if let ExprKind::Path(QPath::Resolved(_, ref iter_path)) = iter_args[0].node; - if let ExprKind::Path(QPath::Resolved(_, ref len_path)) = len_args[0].node; + if let ExprKind::Path(QPath::Resolved(_, ref iter_path)) = iter_args[0].kind; + if let ExprKind::Path(QPath::Resolved(_, ref len_path)) = len_args[0].kind; if SpanlessEq::new(cx).eq_path_segments(&iter_path.segments, &len_path.segments); then { span_lint(cx, @@ -240,7 +240,7 @@ fn has_step_by(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { } fn y_plus_one<'t>(cx: &LateContext<'_, '_>, expr: &'t Expr) -> Option<&'t Expr> { - match expr.node { + match expr.kind { ExprKind::Binary( Spanned { node: BinOpKind::Add, .. @@ -261,7 +261,7 @@ fn y_plus_one<'t>(cx: &LateContext<'_, '_>, expr: &'t Expr) -> Option<&'t Expr> } fn y_minus_one<'t>(cx: &LateContext<'_, '_>, expr: &'t Expr) -> Option<&'t Expr> { - match expr.node { + match expr.kind { ExprKind::Binary( Spanned { node: BinOpKind::Sub, .. diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 389f72057890..c666ca93649b 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -36,12 +36,12 @@ declare_lint_pass!(RedundantFieldNames => [REDUNDANT_FIELD_NAMES]); impl EarlyLintPass for RedundantFieldNames { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - if let ExprKind::Struct(_, ref fields, _) = expr.node { + if let ExprKind::Struct(_, ref fields, _) = expr.kind { for field in fields { if field.is_shorthand { continue; } - if let ExprKind::Path(None, path) = &field.expr.node { + if let ExprKind::Path(None, path) = &field.expr.kind { if path.segments.len() == 1 && path.segments[0].ident == field.ident && path.segments[0].args.is_none() diff --git a/clippy_lints/src/redundant_pattern_matching.rs b/clippy_lints/src/redundant_pattern_matching.rs index 8fea20dba67c..2af3634be432 100644 --- a/clippy_lints/src/redundant_pattern_matching.rs +++ b/clippy_lints/src/redundant_pattern_matching.rs @@ -46,7 +46,7 @@ declare_lint_pass!(RedundantPatternMatching => [REDUNDANT_PATTERN_MATCHING]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantPatternMatching { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Match(ref op, ref arms, ref match_source) = expr.node { + if let ExprKind::Match(ref op, ref arms, ref match_source) = expr.kind { match match_source { MatchSource::Normal => find_sugg_for_match(cx, expr, op, arms), MatchSource::IfLetDesugar { contains_else_clause } => { @@ -65,9 +65,9 @@ fn find_sugg_for_if_let<'a, 'tcx>( arms: &HirVec, has_else: bool, ) { - let good_method = match arms[0].pat.node { + let good_method = match arms[0].pat.kind { PatKind::TupleStruct(ref path, ref patterns, _) if patterns.len() == 1 => { - if let PatKind::Wild = patterns[0].node { + if let PatKind::Wild = patterns[0].kind { if match_qpath(path, &paths::RESULT_OK) { "is_ok()" } else if match_qpath(path, &paths::RESULT_ERR) { @@ -108,14 +108,14 @@ fn find_sugg_for_if_let<'a, 'tcx>( fn find_sugg_for_match<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, op: &P, arms: &HirVec) { if arms.len() == 2 { - let node_pair = (&arms[0].pat.node, &arms[1].pat.node); + let node_pair = (&arms[0].pat.kind, &arms[1].pat.kind); let found_good_method = match node_pair { ( PatKind::TupleStruct(ref path_left, ref patterns_left, _), PatKind::TupleStruct(ref path_right, ref patterns_right, _), ) if patterns_left.len() == 1 && patterns_right.len() == 1 => { - if let (PatKind::Wild, PatKind::Wild) = (&patterns_left[0].node, &patterns_right[0].node) { + if let (PatKind::Wild, PatKind::Wild) = (&patterns_left[0].kind, &patterns_right[0].kind) { find_good_method_for_match( arms, path_left, @@ -133,7 +133,7 @@ fn find_sugg_for_match<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, o | (PatKind::Path(ref path_left), PatKind::TupleStruct(ref path_right, ref patterns, _)) if patterns.len() == 1 => { - if let PatKind::Wild = patterns[0].node { + if let PatKind::Wild = patterns[0].kind { find_good_method_for_match( arms, path_left, @@ -180,9 +180,9 @@ fn find_good_method_for_match<'a>( should_be_right: &'a str, ) -> Option<&'a str> { let body_node_pair = if match_qpath(path_left, expected_left) && match_qpath(path_right, expected_right) { - (&(*arms[0].body).node, &(*arms[1].body).node) + (&(*arms[0].body).kind, &(*arms[1].body).kind) } else if match_qpath(path_right, expected_left) && match_qpath(path_left, expected_right) { - (&(*arms[1].body).node, &(*arms[0].body).node) + (&(*arms[1].body).kind, &(*arms[0].body).kind) } else { return None; }; diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 6a1ef19dd6cd..06af5f9ecc1a 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -34,7 +34,7 @@ declare_lint_pass!(RedundantStaticLifetimes => [REDUNDANT_STATIC_LIFETIMES]); impl RedundantStaticLifetimes { // Recursively visit types fn visit_type(&mut self, ty: &Ty, cx: &EarlyContext<'_>, reason: &str) { - match ty.node { + match ty.kind { // Be careful of nested structures (arrays and tuples) TyKind::Array(ref ty, _) => { self.visit_type(&*ty, cx, reason); @@ -48,7 +48,7 @@ impl RedundantStaticLifetimes { TyKind::Rptr(ref optional_lifetime, ref borrow_type) => { // Match the 'static lifetime if let Some(lifetime) = *optional_lifetime { - match borrow_type.ty.node { + match borrow_type.ty.kind { TyKind::Path(..) | TyKind::Slice(..) | TyKind::Array(..) | TyKind::Tup(..) => { if lifetime.ident.name == syntax::symbol::kw::StaticLifetime { let snip = snippet(cx, borrow_type.ty.span, ""); @@ -79,13 +79,13 @@ impl RedundantStaticLifetimes { impl EarlyLintPass for RedundantStaticLifetimes { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { if !item.span.from_expansion() { - if let ItemKind::Const(ref var_type, _) = item.node { + if let ItemKind::Const(ref var_type, _) = item.kind { self.visit_type(var_type, cx, "Constants have by default a `'static` lifetime"); // Don't check associated consts because `'static` cannot be elided on those (issue // #2438) } - if let ItemKind::Static(ref var_type, _, _) = item.node { + if let ItemKind::Static(ref var_type, _, _) = item.kind { self.visit_type(var_type, cx, "Statics have by default a `'static` lifetime"); } } diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 54582c6015c2..d9628558697a 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -27,7 +27,7 @@ declare_clippy_lint! { declare_lint_pass!(DerefAddrOf => [DEREF_ADDROF]); fn without_parens(mut e: &Expr) -> &Expr { - while let ExprKind::Paren(ref child_e) = e.node { + while let ExprKind::Paren(ref child_e) = e.kind { e = child_e; } e @@ -36,8 +36,8 @@ fn without_parens(mut e: &Expr) -> &Expr { impl EarlyLintPass for DerefAddrOf { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) { if_chain! { - if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.node; - if let ExprKind::AddrOf(_, ref addrof_target) = without_parens(deref_target).node; + if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.kind; + if let ExprKind::AddrOf(_, ref addrof_target) = without_parens(deref_target).kind; if !in_macro(addrof_target.span); then { let mut applicability = Applicability::MachineApplicable; @@ -78,9 +78,9 @@ declare_lint_pass!(RefInDeref => [REF_IN_DEREF]); impl EarlyLintPass for RefInDeref { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) { if_chain! { - if let ExprKind::Field(ref object, _) = e.node; - if let ExprKind::Paren(ref parened) = object.node; - if let ExprKind::AddrOf(_, ref inner) = parened.node; + if let ExprKind::Field(ref object, _) = e.kind; + if let ExprKind::Paren(ref parened) = object.kind; + if let ExprKind::AddrOf(_, ref inner) = parened.kind; then { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 95f5455d4270..22c4b107f006 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -107,8 +107,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Regex { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Call(ref fun, ref args) = expr.node; - if let ExprKind::Path(ref qpath) = fun.node; + if let ExprKind::Call(ref fun, ref args) = expr.kind; + if let ExprKind::Path(ref qpath) = fun.kind; if args.len() == 1; if let Some(def_id) = cx.tables.qpath_res(qpath, fun.hir_id).opt_def_id(); then { @@ -185,8 +185,8 @@ fn is_trivial_regex(s: ®ex_syntax::hir::Hir) -> Option<&'static str> { fn check_set<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, utf8: bool) { if_chain! { - if let ExprKind::AddrOf(_, ref expr) = expr.node; - if let ExprKind::Array(ref exprs) = expr.node; + if let ExprKind::AddrOf(_, ref expr) = expr.kind; + if let ExprKind::Array(ref exprs) = expr.kind; then { for expr in exprs { check_regex(cx, expr, utf8); @@ -201,7 +201,7 @@ fn check_regex<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, utf8: boo .allow_invalid_utf8(!utf8) .build(); - if let ExprKind::Lit(ref lit) = expr.node { + if let ExprKind::Lit(ref lit) = expr.kind { if let LitKind::Str(ref r, style) = lit.node { let r = &r.as_str(); let offset = if let StrStyle::Raw(n) = style { 2 + n } else { 1 }; diff --git a/clippy_lints/src/replace_consts.rs b/clippy_lints/src/replace_consts.rs index 0dbc7f055178..d3dd4cb9041f 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -36,7 +36,7 @@ declare_lint_pass!(ReplaceConsts => [REPLACE_CONSTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ReplaceConsts { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { if_chain! { - if let hir::ExprKind::Path(ref qp) = expr.node; + if let hir::ExprKind::Path(ref qp) = expr.kind; if let Res::Def(DefKind::Const, def_id) = cx.tables.qpath_res(qp, expr.hir_id); then { for (const_path, repl_snip) in &REPLACEMENTS { diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 116ea8c899bc..47fdc226e992 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -95,7 +95,7 @@ impl Return { // Check the final stmt or expr in a block for unnecessary return. fn check_block_return(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) { if let Some(stmt) = block.stmts.last() { - match stmt.node { + match stmt.kind { ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => { self.check_final_expr(cx, expr, Some(stmt.span), RetReplacement::Empty); }, @@ -112,7 +112,7 @@ impl Return { span: Option, replacement: RetReplacement, ) { - match expr.node { + match expr.kind { // simple return is always "bad" ast::ExprKind::Ret(ref inner) => { // allow `#[cfg(a)] return a; #[cfg(b)] return b;` @@ -197,15 +197,15 @@ impl Return { // we need both a let-binding stmt and an expr if_chain! { if let Some(retexpr) = it.next_back(); - if let ast::StmtKind::Expr(ref retexpr) = retexpr.node; + if let ast::StmtKind::Expr(ref retexpr) = retexpr.kind; if let Some(stmt) = it.next_back(); - if let ast::StmtKind::Local(ref local) = stmt.node; + if let ast::StmtKind::Local(ref local) = stmt.kind; // don't lint in the presence of type inference if local.ty.is_none(); if local.attrs.is_empty(); if let Some(ref initexpr) = local.init; - if let ast::PatKind::Ident(_, ident, _) = local.pat.node; - if let ast::ExprKind::Path(_, ref path) = retexpr.node; + if let ast::PatKind::Ident(_, ident, _) = local.pat.kind; + if let ast::ExprKind::Path(_, ref path) = retexpr.kind; if match_path_ast(path, &[&*ident.name.as_str()]); if !in_external_macro(cx.sess(), initexpr.span); if !in_external_macro(cx.sess(), retexpr.span); @@ -246,7 +246,7 @@ impl EarlyLintPass for Return { } if_chain! { if let ast::FunctionRetTy::Ty(ref ty) = decl.output; - if let ast::TyKind::Tup(ref vals) = ty.node; + if let ast::TyKind::Tup(ref vals) = ty.kind; if vals.is_empty() && !ty.span.from_expansion() && get_def(span) == get_def(ty.span); then { let (rspan, appl) = if let Ok(fn_source) = @@ -278,7 +278,7 @@ impl EarlyLintPass for Return { self.check_let_return(cx, block); if_chain! { if let Some(ref stmt) = block.stmts.last(); - if let ast::StmtKind::Expr(ref expr) = stmt.node; + if let ast::StmtKind::Expr(ref expr) = stmt.kind; if is_unit_expr(expr) && !stmt.span.from_expansion(); then { let sp = expr.span; @@ -295,7 +295,7 @@ impl EarlyLintPass for Return { } fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { - match e.node { + match e.kind { ast::ExprKind::Ret(Some(ref expr)) | ast::ExprKind::Break(_, Some(ref expr)) => { if is_unit_expr(expr) && !expr.span.from_expansion() { span_lint_and_then(cx, UNUSED_UNIT, expr.span, "unneeded `()`", |db| { @@ -328,7 +328,7 @@ fn get_def(span: Span) -> Option { // is this expr a `()` unit? fn is_unit_expr(expr: &ast::Expr) -> bool { - if let ast::ExprKind::Tup(ref vals) = expr.node { + if let ast::ExprKind::Tup(ref vals) = expr.kind { vals.is_empty() } else { false diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index bb4ebf63066b..a71a7fdaba18 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -22,7 +22,7 @@ declare_lint_pass!(SerdeAPI => [SERDE_API_MISUSE]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SerdeAPI { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.kind { let did = trait_ref.path.res.def_id(); if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) { if did == visit_did { diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index a9467756c111..4797b701efa0 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -102,7 +102,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Shadow { fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tcx Body) { let mut bindings = Vec::new(); for arg in iter_input_pats(decl, body) { - if let PatKind::Binding(.., ident, _) = arg.pat.node { + if let PatKind::Binding(.., ident, _) = arg.pat.kind { bindings.push((ident.name, ident.span)) } } @@ -112,7 +112,7 @@ fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tc fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, bindings: &mut Vec<(Name, Span)>) { let len = bindings.len(); for stmt in &block.stmts { - match stmt.node { + match stmt.kind { StmtKind::Local(ref local) => check_local(cx, local, bindings), StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => check_expr(cx, e, bindings), StmtKind::Item(..) => {}, @@ -165,7 +165,7 @@ fn check_pat<'a, 'tcx>( bindings: &mut Vec<(Name, Span)>, ) { // TODO: match more stuff / destructuring - match pat.node { + match pat.kind { PatKind::Binding(.., ident, ref inner) => { let name = ident.name; if is_binding(cx, pat.hir_id) { @@ -188,7 +188,7 @@ fn check_pat<'a, 'tcx>( }, PatKind::Struct(_, ref pfields, _) => { if let Some(init_struct) = init { - if let ExprKind::Struct(_, ref efields, _) = init_struct.node { + if let ExprKind::Struct(_, ref efields, _) = init_struct.kind { for field in pfields { let name = field.ident.name; let efield = efields @@ -209,7 +209,7 @@ fn check_pat<'a, 'tcx>( }, PatKind::Tuple(ref inner, _) => { if let Some(init_tup) = init { - if let ExprKind::Tup(ref tup) = init_tup.node { + if let ExprKind::Tup(ref tup) = init_tup.kind { for (i, p) in inner.iter().enumerate() { check_pat(cx, p, Some(&tup[i]), p.span, bindings); } @@ -226,7 +226,7 @@ fn check_pat<'a, 'tcx>( }, PatKind::Box(ref inner) => { if let Some(initp) = init { - if let ExprKind::Box(ref inner_init) = initp.node { + if let ExprKind::Box(ref inner_init) = initp.kind { check_pat(cx, inner, Some(&**inner_init), span, bindings); } else { check_pat(cx, inner, init, span, bindings); @@ -312,7 +312,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: if in_external_macro(cx.sess(), expr.span) { return; } - match expr.node { + match expr.kind { ExprKind::Unary(_, ref e) | ExprKind::Field(ref e, _) | ExprKind::AddrOf(_, ref e) | ExprKind::Box(ref e) => { check_expr(cx, e, bindings) }, @@ -344,7 +344,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: } fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) { - match ty.node { + match ty.kind { TyKind::Slice(ref sty) => check_ty(cx, sty, bindings), TyKind::Array(ref fty, ref anon_const) => { check_ty(cx, fty, bindings); @@ -364,7 +364,7 @@ fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut V } fn is_self_shadow(name: Name, expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Box(ref inner) | ExprKind::AddrOf(_, ref inner) => is_self_shadow(name, inner), ExprKind::Block(ref block, _) => { block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e)) diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 7e543bfe60f7..3b9985a42451 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -62,10 +62,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SlowVectorInit { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // Matches initialization on reassignements. For example: `vec = Vec::with_capacity(100)` if_chain! { - if let ExprKind::Assign(ref left, ref right) = expr.node; + if let ExprKind::Assign(ref left, ref right) = expr.kind; // Extract variable name - if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.node; + if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.kind; if let Some(variable_name) = path.segments.get(0); // Extract len argument @@ -86,8 +86,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SlowVectorInit { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { // Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)` if_chain! { - if let StmtKind::Local(ref local) = stmt.node; - if let PatKind::Binding(BindingAnnotation::Mutable, .., variable_name, None) = local.pat.node; + if let StmtKind::Local(ref local) = stmt.kind; + if let PatKind::Binding(BindingAnnotation::Mutable, .., variable_name, None) = local.pat.kind; if let Some(ref init) = local.init; if let Some(ref len_arg) = Self::is_vec_with_capacity(init); @@ -109,8 +109,8 @@ impl SlowVectorInit { /// of the first argument of `with_capacity` call if it matches or `None` if it does not. fn is_vec_with_capacity(expr: &Expr) -> Option<&Expr> { if_chain! { - if let ExprKind::Call(ref func, ref args) = expr.node; - if let ExprKind::Path(ref path) = func.node; + if let ExprKind::Call(ref func, ref args) = expr.kind; + if let ExprKind::Path(ref path) = func.kind; if match_qpath(path, &["Vec", "with_capacity"]); if args.len() == 1; @@ -200,8 +200,8 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { fn search_slow_extend_filling(&mut self, expr: &'tcx Expr) { if_chain! { if self.initialization_found; - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node; - if let ExprKind::Path(ref qpath_subj) = args[0].node; + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; + if let ExprKind::Path(ref qpath_subj) = args[0].kind; if match_qpath(&qpath_subj, &[&*self.vec_alloc.variable_name.as_str()]); if path.ident.name == sym!(extend); if let Some(ref extend_arg) = args.get(1); @@ -217,14 +217,14 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { fn search_slow_resize_filling(&mut self, expr: &'tcx Expr) { if_chain! { if self.initialization_found; - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node; - if let ExprKind::Path(ref qpath_subj) = args[0].node; + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; + if let ExprKind::Path(ref qpath_subj) = args[0].kind; if match_qpath(&qpath_subj, &[&*self.vec_alloc.variable_name.as_str()]); if path.ident.name == sym!(resize); if let (Some(ref len_arg), Some(fill_arg)) = (args.get(1), args.get(2)); // Check that is filled with 0 - if let ExprKind::Lit(ref lit) = fill_arg.node; + if let ExprKind::Lit(ref lit) = fill_arg.kind; if let LitKind::Int(0, _) = lit.node; // Check that len expression is equals to `with_capacity` expression @@ -239,7 +239,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { /// Returns `true` if give expression is `repeat(0).take(...)` fn is_repeat_take(&self, expr: &Expr) -> bool { if_chain! { - if let ExprKind::MethodCall(ref take_path, _, ref take_args) = expr.node; + if let ExprKind::MethodCall(ref take_path, _, ref take_args) = expr.kind; if take_path.ident.name == sym!(take); // Check that take is applied to `repeat(0)` @@ -261,11 +261,11 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { /// Returns `true` if given expression is `repeat(0)` fn is_repeat_zero(&self, expr: &Expr) -> bool { if_chain! { - if let ExprKind::Call(ref fn_expr, ref repeat_args) = expr.node; - if let ExprKind::Path(ref qpath_repeat) = fn_expr.node; + if let ExprKind::Call(ref fn_expr, ref repeat_args) = expr.kind; + if let ExprKind::Path(ref qpath_repeat) = fn_expr.kind; if match_qpath(&qpath_repeat, &["repeat"]); if let Some(ref repeat_arg) = repeat_args.get(0); - if let ExprKind::Lit(ref lit) = repeat_arg.node; + if let ExprKind::Lit(ref lit) = repeat_arg.kind; if let LitKind::Int(0, _) = lit.node; then { @@ -280,7 +280,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> { fn visit_stmt(&mut self, stmt: &'tcx Stmt) { if self.initialization_found { - match stmt.node { + match stmt.kind { StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => { self.search_slow_extend_filling(expr); self.search_slow_resize_filling(expr); diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 4135fc87fcd1..fca70fe8dbde 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -83,13 +83,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd { }, ref left, _, - ) = e.node + ) = e.kind { if is_string(cx, left) { if !is_allowed(cx, STRING_ADD_ASSIGN, e.hir_id) { let parent = get_parent_expr(cx, e); if let Some(p) = parent { - if let ExprKind::Assign(ref target, _) = p.node { + if let ExprKind::Assign(ref target, _) = p.kind { // avoid duplicate matches if SpanlessEq::new(cx).eq_expr(target, left) { return; @@ -104,7 +104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd { "you added something to a string. Consider using `String::push_str()` instead", ); } - } else if let ExprKind::Assign(ref target, ref src) = e.node { + } else if let ExprKind::Assign(ref target, ref src) = e.kind { if is_string(cx, target) && is_add(cx, src, target) { span_lint( cx, @@ -123,7 +123,7 @@ fn is_string(cx: &LateContext<'_, '_>, e: &Expr) -> bool { } fn is_add(cx: &LateContext<'_, '_>, src: &Expr, target: &Expr) -> bool { - match src.node { + match src.kind { ExprKind::Binary( Spanned { node: BinOpKind::Add, .. @@ -148,9 +148,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes { use crate::utils::{snippet, snippet_with_applicability}; use syntax::ast::{LitKind, StrStyle}; - if let ExprKind::MethodCall(ref path, _, ref args) = e.node { + if let ExprKind::MethodCall(ref path, _, ref args) = e.kind { if path.ident.name == sym!(as_bytes) { - if let ExprKind::Lit(ref lit) = args[0].node { + if let ExprKind::Lit(ref lit) = args[0].kind { if let LitKind::Str(ref lit_content, style) = lit.node { let callsite = snippet(cx, args[0].span.source_callsite(), r#""foo""#); let expanded = if let StrStyle::Raw(n) = style { diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 0a70c77ae0a0..c91768be6d8a 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -53,7 +53,7 @@ declare_lint_pass!(SuspiciousImpl => [SUSPICIOUS_ARITHMETIC_IMPL, SUSPICIOUS_OP_ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Binary(binop, _, _) = expr.node { + if let hir::ExprKind::Binary(binop, _, _) = expr.kind { match binop.node { hir::BinOpKind::Eq | hir::BinOpKind::Lt @@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { let mut parent_expr = cx.tcx.hir().get_parent_node(expr.hir_id); while parent_expr != hir::CRATE_HIR_ID { if let hir::Node::Expr(e) = cx.tcx.hir().get(parent_expr) { - match e.node { + match e.kind { hir::ExprKind::Binary(..) | hir::ExprKind::Unary(hir::UnOp::UnNot, _) | hir::ExprKind::Unary(hir::UnOp::UnNeg, _) => return, @@ -185,7 +185,7 @@ struct BinaryExprVisitor { impl<'a, 'tcx> Visitor<'tcx> for BinaryExprVisitor { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Binary(..) | hir::ExprKind::Unary(hir::UnOp::UnNot, _) | hir::ExprKind::Unary(hir::UnOp::UnNeg, _) => self.in_binary_expr = true, diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 998d008c6a85..b278171abceb 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -79,18 +79,18 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { for w in block.stmts.windows(3) { if_chain! { // let t = foo(); - if let StmtKind::Local(ref tmp) = w[0].node; + if let StmtKind::Local(ref tmp) = w[0].kind; if let Some(ref tmp_init) = tmp.init; - if let PatKind::Binding(.., ident, None) = tmp.pat.node; + if let PatKind::Binding(.., ident, None) = tmp.pat.kind; // foo() = bar(); - if let StmtKind::Semi(ref first) = w[1].node; - if let ExprKind::Assign(ref lhs1, ref rhs1) = first.node; + if let StmtKind::Semi(ref first) = w[1].kind; + if let ExprKind::Assign(ref lhs1, ref rhs1) = first.kind; // bar() = t; - if let StmtKind::Semi(ref second) = w[2].node; - if let ExprKind::Assign(ref lhs2, ref rhs2) = second.node; - if let ExprKind::Path(QPath::Resolved(None, ref rhs2)) = rhs2.node; + if let StmtKind::Semi(ref second) = w[2].kind; + if let ExprKind::Assign(ref lhs2, ref rhs2) = second.kind; + if let ExprKind::Path(QPath::Resolved(None, ref rhs2)) = rhs2.kind; if rhs2.segments.len() == 1; if ident.as_str() == rhs2.segments[0].ident.as_str(); @@ -102,8 +102,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { lhs1: &'a Expr, lhs2: &'a Expr, ) -> Option<(&'a Expr, &'a Expr, &'a Expr)> { - if let ExprKind::Index(ref lhs1, ref idx1) = lhs1.node { - if let ExprKind::Index(ref lhs2, ref idx2) = lhs2.node { + if let ExprKind::Index(ref lhs1, ref idx1) = lhs1.kind { + if let ExprKind::Index(ref lhs2, ref idx2) = lhs2.kind { if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) { let ty = walk_ptrs_ty(cx.tables.expr_ty(lhs1)); @@ -120,8 +120,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { None } - if let ExprKind::Field(ref lhs1, _) = lhs1.node { - if let ExprKind::Field(ref lhs2, _) = lhs2.node { + if let ExprKind::Field(ref lhs1, _) = lhs1.kind { + if let ExprKind::Field(ref lhs2, _) = lhs2.kind { if lhs1.hir_id.owner_def_id() == lhs2.hir_id.owner_def_id() { return; } @@ -175,11 +175,11 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) { for w in block.stmts.windows(2) { if_chain! { - if let StmtKind::Semi(ref first) = w[0].node; - if let StmtKind::Semi(ref second) = w[1].node; + if let StmtKind::Semi(ref first) = w[0].kind; + if let StmtKind::Semi(ref second) = w[1].kind; if !differing_macro_contexts(first.span, second.span); - if let ExprKind::Assign(ref lhs0, ref rhs0) = first.node; - if let ExprKind::Assign(ref lhs1, ref rhs1) = second.node; + if let ExprKind::Assign(ref lhs0, ref rhs0) = first.kind; + if let ExprKind::Assign(ref lhs1, ref rhs1) = second.kind; if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs0, rhs1); if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, rhs0); then { diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 81054c0d1f1d..72d1e982d64a 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -24,7 +24,7 @@ declare_clippy_lint! { } fn is_temporary(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { - match &expr.node { + match &expr.kind { ExprKind::Struct(..) | ExprKind::Tup(..) => true, ExprKind::Path(qpath) => { if let Res::Def(DefKind::Const, ..) = cx.tables.qpath_res(qpath, expr.hir_id) { @@ -41,9 +41,9 @@ declare_lint_pass!(TemporaryAssignment => [TEMPORARY_ASSIGNMENT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TemporaryAssignment { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Assign(target, _) = &expr.node { + if let ExprKind::Assign(target, _) = &expr.kind { let mut base = target; - while let ExprKind::Field(f, _) | ExprKind::Index(f, _) = &base.node { + while let ExprKind::Field(f, _) | ExprKind::Index(f, _) = &base.kind { base = f; } if is_temporary(cx, base) && !is_adjusted(cx, base) { diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 31223cb27a2e..1f029491df42 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -231,8 +231,8 @@ declare_lint_pass!(Transmute => [ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { #[allow(clippy::similar_names, clippy::too_many_lines)] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprKind::Call(ref path_expr, ref args) = e.node { - if let ExprKind::Path(ref qpath) = path_expr.node { + if let ExprKind::Call(ref path_expr, ref args) = e.kind { + if let ExprKind::Path(ref qpath) = path_expr.kind { if let Some(def_id) = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id() { if match_def_path(cx, def_id, &paths::TRANSMUTE) { let from_ty = cx.tables.expr_ty(&args[0]); @@ -502,7 +502,7 @@ fn get_type_snippet(cx: &LateContext<'_, '_>, path: &QPath, to_ref_ty: Ty<'_>) - GenericArg::Type(ty) => Some(ty), _ => None, }).nth(1); - if let TyKind::Rptr(_, ref to_ty) = to_ty.node; + if let TyKind::Rptr(_, ref to_ty) = to_ty.kind; then { return snippet(cx, to_ty.ty.span, &to_ref_ty.to_string()).to_string(); } diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index 9390b643592d..ed0be2f669ae 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -35,8 +35,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TransmutingNull { } if_chain! { - if let ExprKind::Call(ref func, ref args) = expr.node; - if let ExprKind::Path(ref path) = func.node; + if let ExprKind::Call(ref func, ref args) = expr.kind; + if let ExprKind::Path(ref path) = func.kind; if match_qpath(path, &paths::STD_MEM_TRANSMUTE); if args.len() == 1; @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TransmutingNull { // Catching transmute over constants that resolve to `null`. let mut const_eval_context = constant_context(cx, cx.tables); if_chain! { - if let ExprKind::Path(ref _qpath) = args[0].node; + if let ExprKind::Path(ref _qpath) = args[0].kind; let x = const_eval_context.expr(&args[0]); if let Some(constant) = x; if let Constant::RawPtr(ptr_value) = constant; @@ -62,8 +62,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TransmutingNull { // Catching: // `std::mem::transmute(0 as *const i32)` if_chain! { - if let ExprKind::Cast(ref inner_expr, ref _cast_ty) = args[0].node; - if let ExprKind::Lit(ref lit) = inner_expr.node; + if let ExprKind::Cast(ref inner_expr, ref _cast_ty) = args[0].kind; + if let ExprKind::Lit(ref lit) = inner_expr.kind; if let LitKind::Int(0, _) = lit.node; then { span_lint( @@ -77,8 +77,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TransmutingNull { // Catching: // `std::mem::transmute(std::ptr::null::())` if_chain! { - if let ExprKind::Call(ref func1, ref args1) = args[0].node; - if let ExprKind::Path(ref path1) = func1.node; + if let ExprKind::Call(ref func1, ref args1) = args[0].kind; + if let ExprKind::Path(ref path1) = func1.kind; if match_qpath(path1, &paths::STD_PTR_NULL); if args1.len() == 0; then { diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index 3bda90a66e3a..bdc679c902af 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx> TriviallyCopyPassByRef { if is_copy(cx, ty); if let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes()); if size <= self.limit; - if let hir::TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node; + if let hir::TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.kind; then { let value_type = if is_self_ty(decl_ty) { "self".into() @@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { return; } - if let hir::TraitItemKind::Method(method_sig, _) = &item.node { + if let hir::TraitItemKind::Method(method_sig, _) = &item.kind { self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None); } } @@ -166,7 +166,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { // Exclude non-inherent impls if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { - if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | + if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { return; diff --git a/clippy_lints/src/try_err.rs b/clippy_lints/src/try_err.rs index 4d9934cee30a..35592a1ce503 100644 --- a/clippy_lints/src/try_err.rs +++ b/clippy_lints/src/try_err.rs @@ -54,16 +54,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TryErr { // val, // }; if_chain! { - if let ExprKind::Match(ref match_arg, _, MatchSource::TryDesugar) = expr.node; - if let ExprKind::Call(ref match_fun, ref try_args) = match_arg.node; - if let ExprKind::Path(ref match_fun_path) = match_fun.node; + if let ExprKind::Match(ref match_arg, _, MatchSource::TryDesugar) = expr.kind; + if let ExprKind::Call(ref match_fun, ref try_args) = match_arg.kind; + if let ExprKind::Path(ref match_fun_path) = match_fun.kind; if match_qpath(match_fun_path, &paths::TRY_INTO_RESULT); if let Some(ref try_arg) = try_args.get(0); - if let ExprKind::Call(ref err_fun, ref err_args) = try_arg.node; + if let ExprKind::Call(ref err_fun, ref err_args) = try_arg.kind; if let Some(ref err_arg) = err_args.get(0); - if let ExprKind::Path(ref err_fun_path) = err_fun.node; + if let ExprKind::Path(ref err_fun_path) = err_fun.kind; if match_qpath(err_fun_path, &paths::RESULT_ERR); - if let Some(return_type) = find_err_return_type(cx, &expr.node); + if let Some(return_type) = find_err_return_type(cx, &expr.kind); then { let err_type = cx.tables.expr_ty(err_arg); @@ -106,9 +106,9 @@ fn find_err_return_type<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx ExprKi // Check for From::from in one of the match arms. fn find_err_return_type_arm<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arm: &'tcx Arm) -> Option> { if_chain! { - if let ExprKind::Ret(Some(ref err_ret)) = arm.body.node; - if let ExprKind::Call(ref from_error_path, ref from_error_args) = err_ret.node; - if let ExprKind::Path(ref from_error_fn) = from_error_path.node; + if let ExprKind::Ret(Some(ref err_ret)) = arm.body.kind; + if let ExprKind::Call(ref from_error_path, ref from_error_args) = err_ret.kind; + if let ExprKind::Path(ref from_error_fn) = from_error_path.kind; if match_qpath(from_error_fn, &paths::TRY_FROM_ERROR); if let Some(from_error_arg) = from_error_args.get(0); then { diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 57be349c1053..e976b055791d 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -170,7 +170,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types { fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: HirId) { // Skip trait implementations; see issue #605. if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) { - if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind { return; } } @@ -183,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types { } fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem) { - match item.node { + match item.kind { TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => check_ty(cx, ty, false), TraitItemKind::Method(ref sig, _) => check_fn_decl(cx, &sig.decl), _ => (), @@ -217,7 +217,7 @@ fn match_type_parameter(cx: &LateContext<'_, '_>, qpath: &QPath, path: &[&str]) GenericArg::Type(ty) => Some(ty), _ => None, }); - if let TyKind::Path(ref qpath) = ty.node; + if let TyKind::Path(ref qpath) = ty.kind; if let Some(did) = qpath_res(cx, qpath, ty.hir_id).opt_def_id(); if match_def_path(cx, did, path); then { @@ -237,7 +237,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { if hir_ty.span.from_expansion() { return; } - match hir_ty.node { + match hir_ty.kind { TyKind::Path(ref qpath) if !is_local => { let hir_id = hir_ty.hir_id; let res = qpath_res(cx, qpath, hir_id); @@ -262,7 +262,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { _ => None, }); // ty is now _ at this point - if let TyKind::Path(ref ty_qpath) = ty.node; + if let TyKind::Path(ref ty_qpath) = ty.kind; let res = qpath_res(cx, ty_qpath, ty.hir_id); if let Some(def_id) = res.opt_def_id(); if Some(def_id) == cx.tcx.lang_items().owned_box(); @@ -366,7 +366,7 @@ fn check_ty(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool) { } fn check_ty_rptr(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool, lt: &Lifetime, mut_ty: &MutTy) { - match mut_ty.ty.node { + match mut_ty.ty.kind { TyKind::Path(ref qpath) => { let hir_id = mut_ty.ty.hir_id; let def = qpath_res(cx, qpath, hir_id); @@ -424,7 +424,7 @@ fn check_ty_rptr(cx: &LateContext<'_, '_>, hir_ty: &hir::Ty, is_local: bool, lt: // Returns true if given type is `Any` trait. fn is_any_trait(t: &hir::Ty) -> bool { if_chain! { - if let TyKind::TraitObject(ref traits, _) = t.node; + if let TyKind::TraitObject(ref traits, _) = t.kind; if traits.len() >= 1; // Only Send/Sync can be used as additional traits, so it is enough to // check only the first trait. @@ -460,7 +460,7 @@ declare_lint_pass!(LetUnitValue => [LET_UNIT_VALUE]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnitValue { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtKind::Local(ref local) = stmt.node { + if let StmtKind::Local(ref local) = stmt.kind { if is_unit(cx.tables.pat_ty(&local.pat)) { if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() { return; @@ -529,7 +529,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp { if expr.span.from_expansion() { return; } - if let ExprKind::Binary(ref cmp, ref left, _) = expr.node { + if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind { let op = cmp.node; if op.is_comparison() && is_unit(cx.tables.expr_ty(left)) { let result = match op { @@ -596,11 +596,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg { } } - match expr.node { + match expr.kind { ExprKind::Call(_, ref args) | ExprKind::MethodCall(_, _, ref args) => { for arg in args { if is_unit(cx.tables.expr_ty(arg)) && !is_unit_literal(arg) { - if let ExprKind::Match(.., match_source) = &arg.node { + if let ExprKind::Match(.., match_source) = &arg.kind { if *match_source == MatchSource::TryDesugar { continue; } @@ -625,7 +625,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg { fn is_questionmark_desugar_marked_call(expr: &Expr) -> bool { use syntax_pos::hygiene::DesugaringKind; - if let ExprKind::Call(ref callee, _) = expr.node { + if let ExprKind::Call(ref callee, _) = expr.kind { callee.span.is_desugaring(DesugaringKind::QuestionMark) } else { false @@ -640,7 +640,7 @@ fn is_unit(ty: Ty<'_>) -> bool { } fn is_unit_literal(expr: &Expr) -> bool { - match expr.node { + match expr.kind { ExprKind::Tup(ref slice) if slice.is_empty() => true, _ => false, } @@ -921,7 +921,7 @@ fn span_precision_loss_lint(cx: &LateContext<'_, '_>, expr: &Expr, cast_from: Ty } fn should_strip_parens(op: &Expr, snip: &str) -> bool { - if let ExprKind::Binary(_, _, _) = op.node { + if let ExprKind::Binary(_, _, _) = op.kind { if snip.starts_with('(') && snip.ends_with(')') { return true; } @@ -1118,10 +1118,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts { if expr.span.from_expansion() { return; } - if let ExprKind::Cast(ref ex, _) = expr.node { + if let ExprKind::Cast(ref ex, _) = expr.kind { let (cast_from, cast_to) = (cx.tables.expr_ty(ex), cx.tables.expr_ty(expr)); lint_fn_to_numeric_cast(cx, expr, ex, cast_from, cast_to); - if let ExprKind::Lit(ref lit) = ex.node { + if let ExprKind::Lit(ref lit) = ex.kind { if let LitKind::Int(n, _) = lit.node { if cast_to.is_floating_point() { let from_nbits = 128 - n.leading_zeros(); @@ -1352,7 +1352,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity { } fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - match item.node { + match item.kind { ItemKind::Static(ref ty, _, _) | ItemKind::Const(ref ty, _) => self.check_type(cx, ty), // functions, enums, structs, impls and traits are covered _ => (), @@ -1360,7 +1360,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity { } fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { - match item.node { + match item.kind { TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty), TraitItemKind::Method(MethodSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl), // methods with default impl are covered by check_fn @@ -1369,7 +1369,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { - match item.node { + match item.kind { ImplItemKind::Const(ref ty, _) | ImplItemKind::TyAlias(ref ty) => self.check_type(cx, ty), // methods are covered by check_fn _ => (), @@ -1424,7 +1424,7 @@ struct TypeComplexityVisitor { impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor { fn visit_ty(&mut self, ty: &'tcx hir::Ty) { - let (add_score, sub_nest) = match ty.node { + let (add_score, sub_nest) = match ty.kind { // _, &x and *x have only small overhead; don't mess with nesting level TyKind::Infer | TyKind::Ptr(..) | TyKind::Rptr(..) => (1, 0), @@ -1495,8 +1495,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { if !expr.span.from_expansion(); - if let ExprKind::Cast(e, _) = &expr.node; - if let ExprKind::Lit(l) = &e.node; + if let ExprKind::Cast(e, _) = &expr.kind; + if let ExprKind::Lit(l) = &e.kind; if let LitKind::Char(c) = l.node; if ty::Uint(UintTy::U8) == cx.tables.expr_ty(expr).kind; then { @@ -1573,7 +1573,7 @@ enum AbsurdComparisonResult { } fn is_cast_between_fixed_and_target<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> bool { - if let ExprKind::Cast(ref cast_exp, _) = expr.node { + if let ExprKind::Cast(ref cast_exp, _) = expr.kind { let precast_ty = cx.tables.expr_ty(cast_exp); let cast_ty = cx.tables.expr_ty(expr); @@ -1668,7 +1668,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons { use crate::types::AbsurdComparisonResult::*; use crate::types::ExtremeType::*; - if let ExprKind::Binary(ref cmp, ref lhs, ref rhs) = expr.node { + if let ExprKind::Binary(ref cmp, ref lhs, ref rhs) = expr.kind { if let Some((culprit, result)) = detect_absurd_comparison(cx, cmp.node, lhs, rhs) { if !expr.span.from_expansion() { let msg = "this comparison involving the minimum or maximum element for this \ @@ -1771,7 +1771,7 @@ impl Ord for FullInt { fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<(FullInt, FullInt)> { use std::*; - if let ExprKind::Cast(ref cast_exp, _) = expr.node { + if let ExprKind::Cast(ref cast_exp, _) = expr.kind { let pre_cast_ty = cx.tables.expr_ty(cast_exp); let cast_ty = cx.tables.expr_ty(expr); // if it's a cast from i32 to u32 wrapping will invalidate all these checks @@ -1846,7 +1846,7 @@ fn node_as_const_fullint<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) } fn err_upcast_comparison(cx: &LateContext<'_, '_>, span: Span, expr: &Expr, always: bool) { - if let ExprKind::Cast(ref cast_val, _) = expr.node { + if let ExprKind::Cast(ref cast_val, _) = expr.kind { span_lint( cx, INVALID_UPCAST_COMPARISONS, @@ -1920,7 +1920,7 @@ fn upcast_comparison_bounds_err<'a, 'tcx>( impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidUpcastComparisons { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprKind::Binary(ref cmp, ref lhs, ref rhs) = expr.node { + if let ExprKind::Binary(ref cmp, ref lhs, ref rhs) = expr.kind { let normalized = comparisons::normalize_comparison(cmp.node, lhs, rhs); let (rel, normalized_lhs, normalized_rhs) = if let Some(val) = normalized { val @@ -2029,7 +2029,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher { return; } - match item.node { + match item.kind { ItemKind::Impl(_, _, _, ref generics, _, ref ty, ref items) => { let mut vis = ImplicitHasherTypeVisitor::new(cx); vis.visit_ty(ty); @@ -2120,7 +2120,7 @@ enum ImplicitHasherType<'tcx> { impl<'tcx> ImplicitHasherType<'tcx> { /// Checks that `ty` is a target type without a BuildHasher. fn new<'a>(cx: &LateContext<'a, 'tcx>, hir_ty: &hir::Ty) -> Option { - if let TyKind::Path(QPath::Resolved(None, ref path)) = hir_ty.node { + if let TyKind::Path(QPath::Resolved(None, ref path)) = hir_ty.kind { let params: Vec<_> = path .segments .last() @@ -2240,9 +2240,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 't fn visit_expr(&mut self, e: &'tcx Expr) { if_chain! { - if let ExprKind::Call(ref fun, ref args) = e.node; - if let ExprKind::Path(QPath::TypeRelative(ref ty, ref method)) = fun.node; - if let TyKind::Path(QPath::Resolved(None, ref ty_path)) = ty.node; + if let ExprKind::Call(ref fun, ref args) = e.kind; + if let ExprKind::Path(QPath::TypeRelative(ref ty, ref method)) = fun.kind; + if let TyKind::Path(QPath::Resolved(None, ref ty_path)) = ty.kind; then { if !same_tys(self.cx, self.target.ty(), self.body.expr_ty(e)) { return; @@ -2325,11 +2325,11 @@ declare_lint_pass!(RefToMut => [CAST_REF_TO_MUT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RefToMut { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::Unary(UnOp::UnDeref, e) = &expr.node; - if let ExprKind::Cast(e, t) = &e.node; - if let TyKind::Ptr(MutTy { mutbl: Mutability::MutMutable, .. }) = t.node; - if let ExprKind::Cast(e, t) = &e.node; - if let TyKind::Ptr(MutTy { mutbl: Mutability::MutImmutable, .. }) = t.node; + if let ExprKind::Unary(UnOp::UnDeref, e) = &expr.kind; + if let ExprKind::Cast(e, t) = &e.kind; + if let TyKind::Ptr(MutTy { mutbl: Mutability::MutMutable, .. }) = t.kind; + if let ExprKind::Cast(e, t) = &e.kind; + if let TyKind::Ptr(MutTy { mutbl: Mutability::MutImmutable, .. }) = t.kind; if let ty::Ref(..) = cx.tables.node_type(e.hir_id).kind; then { span_lint( diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index f7e1edae5162..7726b05a2c8d 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -67,7 +67,7 @@ declare_lint_pass!(Unicode => [ZERO_WIDTH_SPACE, NON_ASCII_LITERAL, UNICODE_NOT_ impl LateLintPass<'_, '_> for Unicode { fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &'_ Expr) { - if let ExprKind::Lit(ref lit) = expr.node { + if let ExprKind::Lit(ref lit) = expr.kind { if let LitKind::Str(_, _) = lit.node { check_str(cx, lit.span, expr.hir_id) } diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index deeeefb88ab5..29c8015edcff 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -30,7 +30,7 @@ declare_lint_pass!(UnsafeNameRemoval => [UNSAFE_REMOVED_FROM_NAME]); impl EarlyLintPass for UnsafeNameRemoval { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Use(ref use_tree) = item.node { + if let ItemKind::Use(ref use_tree) = item.kind { check_use_tree(use_tree, cx, item.span); } } diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index b3de0823bd45..6f02d56b8ea0 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -34,15 +34,15 @@ declare_lint_pass!(UnusedIoAmount => [UNUSED_IO_AMOUNT]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { - let expr = match s.node { + let expr = match s.kind { hir::StmtKind::Semi(ref expr) | hir::StmtKind::Expr(ref expr) => &**expr, _ => return, }; - match expr.node { + match expr.kind { hir::ExprKind::Match(ref res, _, _) if is_try(expr).is_some() => { - if let hir::ExprKind::Call(ref func, ref args) = res.node { - if let hir::ExprKind::Path(ref path) = func.node { + if let hir::ExprKind::Call(ref func, ref args) = res.kind { + if let hir::ExprKind::Path(ref path) = func.kind { if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 { check_method_call(cx, &args[0], expr); } @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { } fn check_method_call(cx: &LateContext<'_, '_>, call: &hir::Expr, expr: &hir::Expr) { - if let hir::ExprKind::MethodCall(ref path, _, _) = call.node { + if let hir::ExprKind::MethodCall(ref path, _, _) = call.kind { let symbol = &*path.ident.as_str(); if match_trait_method(cx, call, &paths::IO_READ) && symbol == "read" { span_lint( diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index 8323078df7e9..721458e1d9a1 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel { impl<'a, 'tcx> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Break(destination, _) | hir::ExprKind::Continue(destination) => { if let Some(label) = destination.label { self.labels.remove(&label.ident.name); diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 061d4aa7460c..39d3ee18452d 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -83,7 +83,7 @@ fn collect_unwrap_info<'a, 'tcx>( expr: &'tcx Expr, invert: bool, ) -> Vec> { - if let ExprKind::Binary(op, left, right) = &expr.node { + if let ExprKind::Binary(op, left, right) = &expr.kind { match (invert, op.node) { (false, BinOpKind::And) | (false, BinOpKind::BitAnd) | (true, BinOpKind::Or) | (true, BinOpKind::BitOr) => { let mut unwrap_info = collect_unwrap_info(cx, left, invert); @@ -92,12 +92,12 @@ fn collect_unwrap_info<'a, 'tcx>( }, _ => (), } - } else if let ExprKind::Unary(UnNot, expr) = &expr.node { + } else if let ExprKind::Unary(UnNot, expr) = &expr.kind { return collect_unwrap_info(cx, expr, !invert); } else { if_chain! { - if let ExprKind::MethodCall(method_name, _, args) = &expr.node; - if let ExprKind::Path(QPath::Resolved(None, path)) = &args[0].node; + if let ExprKind::MethodCall(method_name, _, args) = &expr.kind; + if let ExprKind::Path(QPath::Resolved(None, path)) = &args[0].kind; let ty = cx.tables.expr_ty(&args[0]); if match_type(cx, ty, &paths::OPTION) || match_type(cx, ty, &paths::RESULT); let name = method_name.ident.as_str(); @@ -145,8 +145,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { } else { // find `unwrap[_err]()` calls: if_chain! { - if let ExprKind::MethodCall(ref method_name, _, ref args) = expr.node; - if let ExprKind::Path(QPath::Resolved(None, ref path)) = args[0].node; + if let ExprKind::MethodCall(ref method_name, _, ref args) = expr.kind; + if let ExprKind::Path(QPath::Resolved(None, ref path)) = args[0].kind; if [sym!(unwrap), sym!(unwrap_err)].contains(&method_name.ident.name); let call_to_unwrap = method_name.ident.name == sym!(unwrap); if let Some(unwrappable) = self.unwrappables.iter() diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index f428c2892aee..b09257377023 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TraitImplTyVisitor<'a, 'tcx> { let impl_ty = self.impl_type_walker.next(); if_chain! { - if let TyKind::Path(QPath::Resolved(_, path)) = &t.node; + if let TyKind::Path(QPath::Resolved(_, path)) = &t.kind; // The implementation and trait types don't match which means that // the concrete type was specified by the implementation @@ -164,8 +164,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf { return; } if_chain! { - if let ItemKind::Impl(.., ref item_type, ref refs) = item.node; - if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.node; + if let ItemKind::Impl(.., ref item_type, ref refs) = item.kind; + if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.kind; then { let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args; let should_check = if let Some(ref params) = *parameters { @@ -189,7 +189,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf { for impl_item_ref in refs { let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id); if let ImplItemKind::Method(MethodSig{ decl: impl_decl, .. }, impl_body_id) - = &impl_item.node { + = &impl_item.kind { let item_type = cx.tcx.type_of(impl_def_id); check_trait_method_impl_decl(cx, item_type, impl_item, impl_decl, &impl_trait_ref); @@ -250,7 +250,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> { } fn visit_item(&mut self, item: &'tcx Item) { - match item.node { + match item.kind { ItemKind::Use(..) | ItemKind::Static(..) | ItemKind::Enum(..) diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 044e9838090a..f36570904c0d 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -34,10 +34,10 @@ declare_clippy_lint! { /// ```rust,ignore /// // ./tests/ui/new_lint.stdout /// if_chain! { - /// if let ExprKind::If(ref cond, ref then, None) = item.node, - /// if let ExprKind::Binary(BinOp::Eq, ref left, ref right) = cond.node, - /// if let ExprKind::Path(ref path) = left.node, - /// if let ExprKind::Lit(ref lit) = right.node, + /// if let ExprKind::If(ref cond, ref then, None) = item.kind, + /// if let ExprKind::Binary(BinOp::Eq, ref left, ref right) = cond.kind, + /// if let ExprKind::Path(ref path) = left.kind, + /// if let ExprKind::Lit(ref lit) = right.kind, /// if let LitKind::Int(42, _) = lit.node, /// then { /// // report your lint here @@ -127,7 +127,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Author { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx hir::Stmt) { - if !has_attr(cx.sess(), stmt.node.attrs()) { + if !has_attr(cx.sess(), stmt.kind.attrs()) { return; } prelude(); @@ -215,8 +215,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { } print!(" if let ExprKind::"); - let current = format!("{}.node", self.current); - match expr.node { + let current = format!("{}.kind", self.current); + match expr.kind { ExprKind::Box(ref inner) => { let inner_pat = self.next("inner"); println!("Box(ref {}) = {};", inner_pat, current); @@ -309,8 +309,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { let qp_label = self.next("qp"); println!("Cast(ref {}, ref {}) = {};", cast_pat, cast_ty, current); - if let TyKind::Path(ref qp) = ty.node { - println!(" if let TyKind::Path(ref {}) = {}.node;", qp_label, cast_ty); + if let TyKind::Path(ref qp) = ty.kind { + println!(" if let TyKind::Path(ref {}) = {}.kind;", qp_label, cast_ty); self.current = qp_label; self.print_qpath(qp); } @@ -401,7 +401,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { let obj_pat = self.next("object"); let field_name_pat = self.next("field_name"); println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current); - println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.as_str()); + println!(" if {}.as_str() == {:?}", field_name_pat, field_ident.as_str()); self.current = obj_pat; self.visit_expr(object); }, @@ -510,8 +510,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { #[allow(clippy::too_many_lines)] fn visit_pat(&mut self, pat: &Pat) { print!(" if let PatKind::"); - let current = format!("{}.node", self.current); - match pat.node { + let current = format!("{}.kind", self.current); + match pat.kind { PatKind::Wild => println!("Wild = {};", current), PatKind::Binding(anno, .., ident, ref sub) => { let anno_pat = match anno { @@ -532,7 +532,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { } else { println!("Binding({}, _, {}, None) = {};", anno_pat, name_pat, current); } - println!(" if {}.node.as_str() == \"{}\";", name_pat, ident.as_str()); + println!(" if {}.as_str() == \"{}\";", name_pat, ident.as_str()); }, PatKind::Struct(ref path, ref fields, ignore) => { let path_pat = self.next("path"); @@ -636,8 +636,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { fn visit_stmt(&mut self, s: &Stmt) { print!(" if let StmtKind::"); - let current = format!("{}.node", self.current); - match s.node { + let current = format!("{}.kind", self.current); + match s.kind { // A local (let) binding: StmtKind::Local(ref local) => { let local_pat = self.next("local"); @@ -723,7 +723,7 @@ fn print_path(path: &QPath, first: &mut bool) { print!("{:?}", segment.ident.as_str()); } }, - QPath::TypeRelative(ref ty, ref segment) => match ty.node { + QPath::TypeRelative(ref ty, ref segment) => match ty.kind { hir::TyKind::Path(ref inner_path) => { print_path(inner_path, first); if *first { diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 0c5db79dfd87..4595819f5578 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -14,12 +14,12 @@ use toml; pub fn file_from_args(args: &[ast::NestedMetaItem]) -> Result, (&'static str, source_map::Span)> { for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) { if arg.check_name(sym!(conf_file)) { - return match arg.node { + return match arg.kind { ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => { Err(("`conf_file` must be a named value", arg.span)) }, ast::MetaItemKind::NameValue(ref value) => { - if let ast::LitKind::Str(ref file, _) = value.node { + if let ast::LitKind::Str(ref file, _) = value.kind { Ok(Some(file.to_string().into())) } else { Err(("`conf_file` value must be a string", value.span)) diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index dd53a7111a2a..4fea47b37b56 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -86,7 +86,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O // depending on // `#[no_std]`. Testing both instead of resolving the paths. - match expr.node { + match expr.kind { hir::ExprKind::Path(ref path) => { if match_qpath(path, &paths::RANGE_FULL_STD) || match_qpath(path, &paths::RANGE_FULL) { Some(Range { @@ -99,7 +99,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O } }, hir::ExprKind::Call(ref path, ref args) => { - if let hir::ExprKind::Path(ref path) = path.node { + if let hir::ExprKind::Path(ref path) = path.kind { if match_qpath(path, &paths::RANGE_INCLUSIVE_STD_NEW) || match_qpath(path, &paths::RANGE_INCLUSIVE_NEW) { Some(Range { @@ -159,7 +159,7 @@ pub fn is_from_for_desugar(local: &hir::Local) -> bool { // ``` if_chain! { if let Some(ref expr) = local.init; - if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.node; + if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.kind; then { return true; } @@ -184,14 +184,14 @@ pub fn is_from_for_desugar(local: &hir::Local) -> bool { /// `for pat in arg { body }` becomes `(pat, arg, body)`. pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> { if_chain! { - if let hir::ExprKind::Match(ref iterexpr, ref arms, hir::MatchSource::ForLoopDesugar) = expr.node; - if let hir::ExprKind::Call(_, ref iterargs) = iterexpr.node; + if let hir::ExprKind::Match(ref iterexpr, ref arms, hir::MatchSource::ForLoopDesugar) = expr.kind; + if let hir::ExprKind::Call(_, ref iterargs) = iterexpr.kind; if iterargs.len() == 1 && arms.len() == 1 && arms[0].guard.is_none(); - if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.node; + if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.kind; if block.expr.is_none(); if let [ _, _, ref let_stmt, ref body ] = *block.stmts; - if let hir::StmtKind::Local(ref local) = let_stmt.node; - if let hir::StmtKind::Expr(ref expr) = body.node; + if let hir::StmtKind::Local(ref local) = let_stmt.kind; + if let hir::StmtKind::Expr(ref expr) = body.kind; then { return Some((&*local.pat, &iterargs[0], expr)); } @@ -203,10 +203,10 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> /// `while cond { body }` becomes `(cond, body)`. pub fn while_loop(expr: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr)> { if_chain! { - if let hir::ExprKind::Loop(block, _, hir::LoopSource::While) = &expr.node; + if let hir::ExprKind::Loop(block, _, hir::LoopSource::While) = &expr.kind; if let hir::Block { expr: Some(expr), .. } = &**block; - if let hir::ExprKind::Match(cond, arms, hir::MatchSource::WhileDesugar) = &expr.node; - if let hir::ExprKind::DropTemps(cond) = &cond.node; + if let hir::ExprKind::Match(cond, arms, hir::MatchSource::WhileDesugar) = &expr.kind; + if let hir::ExprKind::DropTemps(cond) = &cond.kind; if let [arm, ..] = &arms[..]; if let hir::Arm { body, .. } = arm; then { @@ -219,8 +219,8 @@ pub fn while_loop(expr: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr)> { /// Recover the essential nodes of a desugared if block /// `if cond { then } else { els }` becomes `(cond, then, Some(els))` pub fn if_block(expr: &hir::Expr) -> Option<(&hir::Expr, &hir::Expr, Option<&hir::Expr>)> { - if let hir::ExprKind::Match(ref cond, ref arms, hir::MatchSource::IfDesugar { contains_else_clause }) = expr.node { - let cond = if let hir::ExprKind::DropTemps(ref cond) = cond.node { + if let hir::ExprKind::Match(ref cond, ref arms, hir::MatchSource::IfDesugar { contains_else_clause }) = expr.kind { + let cond = if let hir::ExprKind::DropTemps(ref cond) = cond.kind { cond } else { panic!("If block desugar must contain DropTemps"); @@ -249,8 +249,8 @@ pub enum VecArgs<'a> { /// from `vec!`. pub fn vec_macro<'e>(cx: &LateContext<'_, '_>, expr: &'e hir::Expr) -> Option> { if_chain! { - if let hir::ExprKind::Call(ref fun, ref args) = expr.node; - if let hir::ExprKind::Path(ref path) = fun.node; + if let hir::ExprKind::Call(ref fun, ref args) = expr.kind; + if let hir::ExprKind::Path(ref path) = fun.kind; if is_expn_of(fun.span, "vec").is_some(); if let Some(fun_def_id) = resolve_node(cx, path, fun.hir_id).opt_def_id(); then { @@ -261,8 +261,8 @@ pub fn vec_macro<'e>(cx: &LateContext<'_, '_>, expr: &'e hir::Expr) -> Option SpanlessEq<'a, 'tcx> { /// Checks whether two statements are the same. pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool { - match (&left.node, &right.node) { + match (&left.kind, &right.kind) { (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => { self.eq_pat(&l.pat, &r.pat) && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) @@ -76,7 +76,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { } } - match (&left.node, &right.node) { + match (&left.kind, &right.kind) { (&ExprKind::AddrOf(l_mut, ref le), &ExprKind::AddrOf(r_mut, ref re)) => { l_mut == r_mut && self.eq_expr(le, re) }, @@ -181,7 +181,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { /// Checks whether two patterns are the same. pub fn eq_pat(&mut self, left: &Pat, right: &Pat) -> bool { - match (&left.node, &right.node) { + match (&left.kind, &right.kind) { (&PatKind::Box(ref l), &PatKind::Box(ref r)) => self.eq_pat(l, r), (&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => { self.eq_qpath(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs @@ -258,7 +258,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { } pub fn eq_ty(&mut self, left: &Ty, right: &Ty) -> bool { - self.eq_ty_kind(&left.node, &right.node) + self.eq_ty_kind(&left.kind, &right.kind) } #[allow(clippy::similar_names)] @@ -394,9 +394,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { return e.hash(&mut self.s); } - std::mem::discriminant(&e.node).hash(&mut self.s); + std::mem::discriminant(&e.kind).hash(&mut self.s); - match e.node { + match e.kind { ExprKind::AddrOf(m, ref e) => { m.hash(&mut self.s); self.hash_expr(e); @@ -555,9 +555,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } pub fn hash_stmt(&mut self, b: &Stmt) { - std::mem::discriminant(&b.node).hash(&mut self.s); + std::mem::discriminant(&b.kind).hash(&mut self.s); - match &b.node { + match &b.kind { StmtKind::Local(local) => { if let Some(ref init) = local.init { self.hash_expr(init); @@ -595,7 +595,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } pub fn hash_ty(&mut self, ty: &Ty) { - self.hash_tykind(&ty.node); + self.hash_tykind(&ty.kind); } pub fn hash_tykind(&mut self, ty: &TyKind) { diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index d70f8bab8f73..846e47cee374 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -57,7 +57,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector { if item.defaultness.is_default() { println!("default"); } - match item.node { + match item.kind { hir::ImplItemKind::Const(_, body_id) => { println!("associated constant"); print_expr(cx, &cx.tcx.hir().body(body_id).value, 1); @@ -111,10 +111,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx hir::Stmt) { - if !has_attr(cx.sess(), stmt.node.attrs()) { + if !has_attr(cx.sess(), stmt.kind.attrs()) { return; } - match stmt.node { + match stmt.kind { hir::StmtKind::Local(ref local) => { println!("local variable of type {}", cx.tables.node_type(local.hir_id)); println!("pattern:"); @@ -148,7 +148,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) { println!("{}+", ind); println!("{}ty: {}", ind, cx.tables.expr_ty(expr)); println!("{}adjustments: {:?}", ind, cx.tables.adjustments().get(expr.hir_id)); - match expr.node { + match expr.kind { hir::ExprKind::Box(ref e) => { println!("{}Box", ind); print_expr(cx, e, indent + 1); @@ -334,7 +334,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) { ), hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"), } - match item.node { + match item.kind { hir::ItemKind::ExternCrate(ref _renamed_from) => { let def_id = cx.tcx.hir().local_def_id(item.hir_id); if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(def_id) { @@ -399,7 +399,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) { fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) { let ind = " ".repeat(indent); println!("{}+", ind); - match pat.node { + match pat.kind { hir::PatKind::Wild => println!("{}Wild", ind), hir::PatKind::Binding(ref mode, .., ident, ref inner) => { println!("{}Binding", ind); diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 48400593b9d2..1ec89cb93f17 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -108,9 +108,9 @@ impl EarlyLintPass for ClippyLintsInternal { .iter() .find(|item| item.ident.name.as_str() == "utils") { - if let ItemKind::Mod(ref utils_mod) = utils.node { + if let ItemKind::Mod(ref utils_mod) = utils.kind { if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name.as_str() == "paths") { - if let ItemKind::Mod(ref paths_mod) = paths.node { + if let ItemKind::Mod(ref paths_mod) = paths.kind { let mut last_name: Option = None; for item in &*paths_mod.items { let name = item.ident.as_str(); @@ -144,11 +144,11 @@ impl_lint_pass!(LintWithoutLintPass => [LINT_WITHOUT_LINT_PASS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let hir::ItemKind::Static(ref ty, MutImmutable, _) = item.node { + if let hir::ItemKind::Static(ref ty, MutImmutable, _) = item.kind { if is_lint_ref_type(cx, ty) { self.declared_lints.insert(item.ident.name, item.span); } - } else if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { + } else if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.kind { if_chain! { if let hir::TraitRef{path, ..} = trait_ref; if let Res::Def(DefKind::Trait, def_id) = path.res; @@ -201,9 +201,9 @@ fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty) -> bool { ty: ref inner, mutbl: MutImmutable, }, - ) = ty.node + ) = ty.kind { - if let TyKind::Path(ref path) = inner.node { + if let TyKind::Path(ref path) = inner.kind { if let Res::Def(DefKind::Struct, def_id) = cx.tables.qpath_res(path, inner.hir_id) { return match_def_path(cx, def_id, &paths::LINT); } @@ -255,7 +255,7 @@ impl_lint_pass!(CompilerLintFunctions => [COMPILER_LINT_FUNCTIONS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CompilerLintFunctions { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if_chain! { - if let ExprKind::MethodCall(ref path, _, ref args) = expr.node; + if let ExprKind::MethodCall(ref path, _, ref args) = expr.kind; let fn_name = path.ident; if let Some(sugg) = self.map.get(&*fn_name.as_str()); let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0])); diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index f98ff14b892b..ffeb90e1cad5 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -69,28 +69,28 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool { let parent_id = cx.tcx.hir().get_parent_item(id); match cx.tcx.hir().get(parent_id) { Node::Item(&Item { - node: ItemKind::Const(..), + kind: ItemKind::Const(..), .. }) | Node::TraitItem(&TraitItem { - node: TraitItemKind::Const(..), + kind: TraitItemKind::Const(..), .. }) | Node::ImplItem(&ImplItem { - node: ImplItemKind::Const(..), + kind: ImplItemKind::Const(..), .. }) | Node::AnonConst(_) | Node::Item(&Item { - node: ItemKind::Static(..), + kind: ItemKind::Static(..), .. }) => true, Node::Item(&Item { - node: ItemKind::Fn(_, header, ..), + kind: ItemKind::Fn(_, header, ..), .. }) => header.constness == Constness::Const, Node::ImplItem(&ImplItem { - node: ImplItemKind::Method(ref sig, _), + kind: ImplItemKind::Method(ref sig, _), .. }) => sig.header.constness == Constness::Const, _ => false, @@ -152,7 +152,7 @@ pub fn match_trait_method(cx: &LateContext<'_, '_>, expr: &Expr, path: &[&str]) /// Checks if an expression references a variable of the given name. pub fn match_var(expr: &Expr, var: Name) -> bool { - if let ExprKind::Path(QPath::Resolved(None, ref path)) = expr.node { + if let ExprKind::Path(QPath::Resolved(None, ref path)) = expr.kind { if path.segments.len() == 1 && path.segments[0].ident.name == var { return true; } @@ -187,7 +187,7 @@ pub fn single_segment_path(path: &QPath) -> Option<&PathSegment> { pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool { match *path { QPath::Resolved(_, ref path) => match_path(path, segments), - QPath::TypeRelative(ref ty, ref segment) => match ty.node { + QPath::TypeRelative(ref ty, ref segment) => match ty.kind { TyKind::Path(ref inner_path) => { !segments.is_empty() && match_qpath(inner_path, &segments[..(segments.len() - 1)]) @@ -344,7 +344,7 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> O if_chain! { if parent_impl != hir::CRATE_HIR_ID; if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl); - if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.node; + if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.kind; then { return trait_ref.as_ref(); } } None @@ -372,7 +372,7 @@ pub fn method_calls(expr: &Expr, max_depth: usize) -> (Vec, Vec<&[Expr]> let mut current = expr; for _ in 0..max_depth { - if let ExprKind::MethodCall(path, span, args) = ¤t.node { + if let ExprKind::MethodCall(path, span, args) = ¤t.kind { if args.iter().any(|e| e.span.from_expansion()) { break; } @@ -399,7 +399,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option first - if let ExprKind::MethodCall(ref path, _, ref args) = current.node { + if let ExprKind::MethodCall(ref path, _, ref args) = current.kind { if path.ident.name.as_str() == *method_name { if args.iter().any(|e| e.span.from_expansion()) { return None; @@ -439,7 +439,7 @@ pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option { /// Gets the name of a `Pat`, if any. pub fn get_pat_name(pat: &Pat) -> Option { - match pat.node { + match pat.kind { PatKind::Binding(.., ref spname, _) => Some(spname.name), PatKind::Path(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name), PatKind::Box(ref p) | PatKind::Ref(ref p, _) => get_pat_name(&*p), @@ -562,7 +562,7 @@ pub fn expr_block<'a, T: LintContext>(cx: &T, expr: &Expr, option: Option(cx: &LateContext<'a, 'tcx>, hir_id: HirId) match node { Node::Block(block) => Some(block), Node::Item(&Item { - node: ItemKind::Fn(_, _, _, eid), + kind: ItemKind::Fn(_, _, _, eid), .. }) | Node::ImplItem(&ImplItem { - node: ImplItemKind::Method(_, eid), + kind: ImplItemKind::Method(_, eid), .. - }) => match cx.tcx.hir().body(eid).value.node { + }) => match cx.tcx.hir().body(eid).value.kind { ExprKind::Block(ref block, _) => Some(block), _ => None, }, @@ -657,7 +657,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId) /// Returns the base type for HIR references and pointers. pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty { - match ty.node { + match ty.kind { TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(&mut_ty.ty), _ => ty, } @@ -704,7 +704,7 @@ pub fn is_integer_const(cx: &LateContext<'_, '_>, e: &Expr, value: u128) -> bool /// Checks whether the given expression is a constant literal of the given value. pub fn is_integer_literal(expr: &Expr, value: u128) -> bool { // FIXME: use constant folding - if let ExprKind::Lit(ref spanned) = expr.node { + if let ExprKind::Lit(ref spanned) = expr.kind { if let LitKind::Int(v, _) = spanned.node { return v == value; } @@ -804,8 +804,8 @@ pub fn is_copy<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { /// Checks if an expression is constructing a tuple-like enum variant or struct pub fn is_ctor_function(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { - if let ExprKind::Call(ref fun, _) = expr.node { - if let ExprKind::Path(ref qp) = fun.node { + if let ExprKind::Call(ref fun, _) = expr.kind { + if let ExprKind::Path(ref qp) = fun.kind { return matches!( cx.tables.qpath_res(qp, fun.hir_id), def::Res::Def(DefKind::Variant, ..) | Res::Def(DefKind::Ctor(..), _) @@ -828,7 +828,7 @@ pub fn is_refutable(cx: &LateContext<'_, '_>, pat: &Pat) -> bool { i.any(|pat| is_refutable(cx, pat)) } - match pat.node { + match pat.kind { PatKind::Binding(..) | PatKind::Wild => false, PatKind::Box(ref pat) | PatKind::Ref(ref pat, _) => is_refutable(cx, pat), PatKind::Lit(..) | PatKind::Range(..) => true, @@ -865,7 +865,7 @@ pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool { /// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return /// themselves. pub fn remove_blocks(expr: &Expr) -> &Expr { - if let ExprKind::Block(ref block, _) = expr.node { + if let ExprKind::Block(ref block, _) = expr.kind { if block.stmts.is_empty() { if let Some(ref expr) = block.expr { remove_blocks(expr) @@ -881,7 +881,7 @@ pub fn remove_blocks(expr: &Expr) -> &Expr { } pub fn is_self(slf: &Param) -> bool { - if let PatKind::Binding(.., name, _) = slf.pat.node { + if let PatKind::Binding(.., name, _) = slf.pat.kind { name.name == kw::SelfLower } else { false @@ -890,7 +890,7 @@ pub fn is_self(slf: &Param) -> bool { pub fn is_self_ty(slf: &hir::Ty) -> bool { if_chain! { - if let TyKind::Path(ref qp) = slf.node; + if let TyKind::Path(ref qp) = slf.kind; if let QPath::Resolved(None, ref path) = *qp; if let Res::SelfTy(..) = path.res; then { @@ -909,10 +909,10 @@ pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator Option<&Expr> { fn is_ok(arm: &Arm) -> bool { if_chain! { - if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pat.node; + if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pat.kind; if match_qpath(path, &paths::RESULT_OK[1..]); - if let PatKind::Binding(_, hir_id, _, None) = pat[0].node; - if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node; + if let PatKind::Binding(_, hir_id, _, None) = pat[0].kind; + if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.kind; if let Res::Local(lid) = path.res; if lid == hir_id; then { @@ -923,14 +923,14 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> { } fn is_err(arm: &Arm) -> bool { - if let PatKind::TupleStruct(ref path, _, _) = arm.pat.node { + if let PatKind::TupleStruct(ref path, _, _) = arm.pat.kind { match_qpath(path, &paths::RESULT_ERR[1..]) } else { false } } - if let ExprKind::Match(_, ref arms, ref source) = expr.node { + if let ExprKind::Match(_, ref arms, ref source) = expr.kind { // desugared from a `?` operator if let MatchSource::TryDesugar = *source { return Some(expr); @@ -959,7 +959,7 @@ pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: HirId) -> b } pub fn get_arg_name(pat: &Pat) -> Option { - match pat.node { + match pat.kind { PatKind::Binding(.., ident, None) => Some(ident.name), PatKind::Ref(ref subpat, _) => get_arg_name(subpat), _ => None, @@ -1179,7 +1179,7 @@ pub fn if_sequence(mut expr: &Expr) -> (SmallVec<[&Expr; 1]>, SmallVec<[&Block; while let Some((ref cond, ref then_expr, ref else_expr)) = higher::if_block(&expr) { conds.push(&**cond); - if let ExprKind::Block(ref block, _) = then_expr.node { + if let ExprKind::Block(ref block, _) = then_expr.kind { blocks.push(block); } else { panic!("ExprKind::If node is not an ExprKind::Block"); @@ -1194,7 +1194,7 @@ pub fn if_sequence(mut expr: &Expr) -> (SmallVec<[&Expr; 1]>, SmallVec<[&Block; // final `else {..}` if !blocks.is_empty() { - if let ExprKind::Block(ref block, _) = expr.node { + if let ExprKind::Block(ref block, _) = expr.kind { blocks.push(&**block); } } diff --git a/clippy_lints/src/utils/ptr.rs b/clippy_lints/src/utils/ptr.rs index be7bd0d21f69..32ec4d6c5486 100644 --- a/clippy_lints/src/utils/ptr.rs +++ b/clippy_lints/src/utils/ptr.rs @@ -56,7 +56,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> { if self.abort { return; } - if let ExprKind::MethodCall(ref seg, _, ref args) = expr.node { + if let ExprKind::MethodCall(ref seg, _, ref args) = expr.kind { if args.len() == 1 && match_var(&args[0], self.name) { if seg.ident.name.as_str() == "capacity" { self.abort = true; diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 249df8e0e230..3c31067f7f8a 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -90,7 +90,7 @@ impl<'a> Sugg<'a> { /// Generate a suggestion for an expression with the given snippet. This is used by the `hir_*` /// function variants of `Sugg`, since these use different snippet functions. fn hir_from_snippet(expr: &hir::Expr, snippet: Cow<'a, str>) -> Self { - match expr.node { + match expr.kind { hir::ExprKind::AddrOf(..) | hir::ExprKind::Box(..) | hir::ExprKind::Closure(..) @@ -129,7 +129,7 @@ impl<'a> Sugg<'a> { let snippet = snippet(cx, expr.span, default); - match expr.node { + match expr.kind { ast::ExprKind::AddrOf(..) | ast::ExprKind::Box(..) | ast::ExprKind::Closure(..) diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index bb97f894c064..af874ad1e506 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -33,7 +33,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessVec { if_chain! { if let ty::Ref(_, ty, _) = cx.tables.expr_ty_adjusted(expr).kind; if let ty::Slice(..) = ty.kind; - if let ExprKind::AddrOf(_, ref addressee) = expr.node; + if let ExprKind::AddrOf(_, ref addressee) = expr.kind; if let Some(vec_args) = higher::vec_macro(cx, addressee); then { check_vec_macro(cx, &vec_args, expr.span); diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 7d72a21ac036..989d2f374a84 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -393,7 +393,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O None, ); }; - match &token_expr.node { + match &token_expr.kind { ExprKind::Lit(_) => { let mut all_simple = true; let mut seen = false; @@ -414,8 +414,8 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O idx += 1; }, ExprKind::Assign(lhs, rhs) => { - if let ExprKind::Lit(_) = rhs.node { - if let ExprKind::Path(_, p) = &lhs.node { + if let ExprKind::Lit(_) = rhs.kind { + if let ExprKind::Path(_, p) = &lhs.kind { let mut all_simple = true; let mut seen = false; for arg in &args { diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 1c4c54f26267..f866d76a3819 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -28,7 +28,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ZeroDiv { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // check for instances of 0.0/0.0 if_chain! { - if let ExprKind::Binary(ref op, ref left, ref right) = expr.node; + if let ExprKind::Binary(ref op, ref left, ref right) = expr.kind; if let BinOpKind::Div = op.node; // TODO - constant_simple does not fold many operations involving floats. // That's probably fine for this lint - it's pretty unlikely that someone would diff --git a/tests/ui/author.stdout b/tests/ui/author.stdout index 1d7bf607a146..211d11c7c1aa 100644 --- a/tests/ui/author.stdout +++ b/tests/ui/author.stdout @@ -1,13 +1,13 @@ if_chain! { - if let StmtKind::Local(ref local) = stmt.node; + if let StmtKind::Local(ref local) = stmt.kind; if let Some(ref init) = local.init; - if let ExprKind::Cast(ref expr, ref cast_ty) = init.node; - if let TyKind::Path(ref qp) = cast_ty.node; + if let ExprKind::Cast(ref expr, ref cast_ty) = init.kind; + if let TyKind::Path(ref qp) = cast_ty.kind; if match_qpath(qp, &["char"]); - if let ExprKind::Lit(ref lit) = expr.node; + if let ExprKind::Lit(ref lit) = expr.kind; if let LitKind::Int(69, _) = lit.node; - if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.node; - if name.node.as_str() == "x"; + if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind; + if name.as_str() == "x"; then { // report your lint here } diff --git a/tests/ui/author/blocks.rs b/tests/ui/author/blocks.rs index cabb0cc8c323..6034762d130a 100644 --- a/tests/ui/author/blocks.rs +++ b/tests/ui/author/blocks.rs @@ -1,5 +1,5 @@ #![feature(stmt_expr_attributes)] -#![allow(redundant_semicolon)] +#![allow(redundant_semicolon, clippy::no_effect)] #[rustfmt::skip] fn main() { diff --git a/tests/ui/author/blocks.stderr b/tests/ui/author/blocks.stderr deleted file mode 100644 index 1766663344c4..000000000000 --- a/tests/ui/author/blocks.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: statement with no effect - --> $DIR/blocks.rs:8:9 - | -LL | ;;;; - | ^^^^ - | - = note: `-D clippy::no-effect` implied by `-D warnings` - -error: statement with no effect - --> $DIR/blocks.rs:15:5 - | -LL | -x; - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/author/blocks.stdout b/tests/ui/author/blocks.stdout index f7b78503b1d0..c7127db904a3 100644 --- a/tests/ui/author/blocks.stdout +++ b/tests/ui/author/blocks.stdout @@ -1,9 +1,9 @@ if_chain! { - if let ExprKind::Block(ref block) = expr.node; + if let ExprKind::Block(ref block) = expr.kind; if let Some(trailing_expr) = &block.expr; if block.stmts.len() == 1; - if let StmtKind::Semi(ref e, _) = block.stmts[0].node - if let ExprKind::Tup(ref elements) = e.node; + if let StmtKind::Semi(ref e, _) = block.stmts[0].kind + if let ExprKind::Tup(ref elements) = e.kind; if elements.len() == 0; then { // report your lint here diff --git a/tests/ui/author/call.stdout b/tests/ui/author/call.stdout index 5c8c90c6b4c8..4dccf666631a 100644 --- a/tests/ui/author/call.stdout +++ b/tests/ui/author/call.stdout @@ -1,15 +1,15 @@ if_chain! { - if let StmtKind::Local(ref local) = stmt.node; + if let StmtKind::Local(ref local) = stmt.kind; if let Some(ref init) = local.init; - if let ExprKind::Call(ref func, ref args) = init.node; - if let ExprKind::Path(ref path) = func.node; + if let ExprKind::Call(ref func, ref args) = init.kind; + if let ExprKind::Path(ref path) = func.kind; if match_qpath(path, &["{{root}}", "std", "cmp", "min"]); if args.len() == 2; - if let ExprKind::Lit(ref lit) = args[0].node; + if let ExprKind::Lit(ref lit) = args[0].kind; if let LitKind::Int(3, _) = lit.node; - if let ExprKind::Lit(ref lit1) = args[1].node; + if let ExprKind::Lit(ref lit1) = args[1].kind; if let LitKind::Int(4, _) = lit1.node; - if let PatKind::Wild = local.pat.node; + if let PatKind::Wild = local.pat.kind; then { // report your lint here } diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index d195c7fdb958..0ad5834cd90e 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -1,61 +1,61 @@ if_chain! { - if let ExprKind::DropTemps(ref expr) = expr.node; - if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.node; - if let ExprKind::Call(ref func, ref args) = expr1.node; - if let ExprKind::Path(ref path) = func.node; + if let ExprKind::DropTemps(ref expr) = expr.kind; + if let ExprKind::Match(ref expr1, ref arms, MatchSource::ForLoopDesugar) = expr.kind; + if let ExprKind::Call(ref func, ref args) = expr1.kind; + if let ExprKind::Path(ref path) = func.kind; if match_qpath(path, &["{{root}}", "std", "iter", "IntoIterator", "into_iter"]); if args.len() == 1; - if let ExprKind::Struct(ref path1, ref fields, None) = args[0].node; + if let ExprKind::Struct(ref path1, ref fields, None) = args[0].kind; if match_qpath(path1, &["{{root}}", "std", "ops", "Range"]); if fields.len() == 2; // unimplemented: field checks if arms.len() == 1; - if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.node; + if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind; if let Some(trailing_expr) = &body.expr; if body.stmts.len() == 4; - if let StmtKind::Local(ref local) = body.stmts[0].node; - if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.node; - if name.node.as_str() == "__next"; - if let StmtKind::Expr(ref e, _) = body.stmts[1].node - if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.node; - if let ExprKind::Call(ref func1, ref args1) = expr2.node; - if let ExprKind::Path(ref path2) = func1.node; + if let StmtKind::Local(ref local) = body.stmts[0].kind; + if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind; + if name.as_str() == "__next"; + if let StmtKind::Expr(ref e, _) = body.stmts[1].kind + if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind; + if let ExprKind::Call(ref func1, ref args1) = expr2.kind; + if let ExprKind::Path(ref path2) = func1.kind; if match_qpath(path2, &["{{root}}", "std", "iter", "Iterator", "next"]); if args1.len() == 1; - if let ExprKind::AddrOf(MutMutable, ref inner) = args1[0].node; - if let ExprKind::Path(ref path3) = inner.node; + if let ExprKind::AddrOf(MutMutable, ref inner) = args1[0].kind; + if let ExprKind::Path(ref path3) = inner.kind; if match_qpath(path3, &["iter"]); if arms1.len() == 2; - if let ExprKind::Assign(ref target, ref value) = arms1[0].body.node; - if let ExprKind::Path(ref path4) = target.node; + if let ExprKind::Assign(ref target, ref value) = arms1[0].body.kind; + if let ExprKind::Path(ref path4) = target.kind; if match_qpath(path4, &["__next"]); - if let ExprKind::Path(ref path5) = value.node; + if let ExprKind::Path(ref path5) = value.kind; if match_qpath(path5, &["val"]); - if let PatKind::TupleStruct(ref path6, ref fields1, None) = arms1[0].pat.node; + if let PatKind::TupleStruct(ref path6, ref fields1, None) = arms1[0].pat.kind; if match_qpath(path6, &["{{root}}", "std", "option", "Option", "Some"]); if fields1.len() == 1; // unimplemented: field checks - if let ExprKind::Break(ref destination, None) = arms1[1].body.node; - if let PatKind::Path(ref path7) = arms1[1].pat.node; + if let ExprKind::Break(ref destination, None) = arms1[1].body.kind; + if let PatKind::Path(ref path7) = arms1[1].pat.kind; if match_qpath(path7, &["{{root}}", "std", "option", "Option", "None"]); - if let StmtKind::Local(ref local1) = body.stmts[2].node; + if let StmtKind::Local(ref local1) = body.stmts[2].kind; if let Some(ref init) = local1.init; - if let ExprKind::Path(ref path8) = init.node; + if let ExprKind::Path(ref path8) = init.kind; if match_qpath(path8, &["__next"]); - if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.node; - if name1.node.as_str() == "y"; - if let StmtKind::Expr(ref e1, _) = body.stmts[3].node - if let ExprKind::Block(ref block) = e1.node; + if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind; + if name1.as_str() == "y"; + if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind + if let ExprKind::Block(ref block) = e1.kind; if let Some(trailing_expr1) = &block.expr; if block.stmts.len() == 1; - if let StmtKind::Local(ref local2) = block.stmts[0].node; + if let StmtKind::Local(ref local2) = block.stmts[0].kind; if let Some(ref init1) = local2.init; - if let ExprKind::Path(ref path9) = init1.node; + if let ExprKind::Path(ref path9) = init1.kind; if match_qpath(path9, &["y"]); - if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.node; - if name2.node.as_str() == "z"; - if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.node; - if name3.node.as_str() == "iter"; + if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind; + if name2.as_str() == "z"; + if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind; + if name3.as_str() == "iter"; then { // report your lint here } diff --git a/tests/ui/author/if.stdout b/tests/ui/author/if.stdout index be8260007b21..c18d035953e5 100644 --- a/tests/ui/author/if.stdout +++ b/tests/ui/author/if.stdout @@ -1,30 +1,30 @@ if_chain! { - if let StmtKind::Local(ref local) = stmt.node; + if let StmtKind::Local(ref local) = stmt.kind; if let Some(ref init) = local.init; if let Some((ref cond, ref then, Some(else_))) = higher::if_block(&init); - if let ExprKind::Block(ref block) = else_.node; + if let ExprKind::Block(ref block) = else_.kind; if let Some(trailing_expr) = &block.expr; if block.stmts.len() == 1; - if let StmtKind::Semi(ref e, _) = block.stmts[0].node - if let ExprKind::Binary(ref op, ref left, ref right) = e.node; + if let StmtKind::Semi(ref e, _) = block.stmts[0].kind + if let ExprKind::Binary(ref op, ref left, ref right) = e.kind; if BinOpKind::Eq == op.node; - if let ExprKind::Lit(ref lit) = left.node; + if let ExprKind::Lit(ref lit) = left.kind; if let LitKind::Int(2, _) = lit.node; - if let ExprKind::Lit(ref lit1) = right.node; + if let ExprKind::Lit(ref lit1) = right.kind; if let LitKind::Int(2, _) = lit1.node; - if let ExprKind::Lit(ref lit2) = cond.node; + if let ExprKind::Lit(ref lit2) = cond.kind; if let LitKind::Bool(true) = lit2.node; - if let ExprKind::Block(ref block1) = then.node; + if let ExprKind::Block(ref block1) = then.kind; if let Some(trailing_expr1) = &block1.expr; if block1.stmts.len() == 1; - if let StmtKind::Semi(ref e1, _) = block1.stmts[0].node - if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.node; + if let StmtKind::Semi(ref e1, _) = block1.stmts[0].kind + if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.kind; if BinOpKind::Eq == op1.node; - if let ExprKind::Lit(ref lit3) = left1.node; + if let ExprKind::Lit(ref lit3) = left1.kind; if let LitKind::Int(1, _) = lit3.node; - if let ExprKind::Lit(ref lit4) = right1.node; + if let ExprKind::Lit(ref lit4) = right1.kind; if let LitKind::Int(1, _) = lit4.node; - if let PatKind::Wild = local.pat.node; + if let PatKind::Wild = local.pat.kind; then { // report your lint here } diff --git a/tests/ui/issue_3849.rs b/tests/ui/author/issue_3849.rs similarity index 100% rename from tests/ui/issue_3849.rs rename to tests/ui/author/issue_3849.rs diff --git a/tests/ui/author/issue_3849.stdout b/tests/ui/author/issue_3849.stdout new file mode 100644 index 000000000000..65f93f3cdc06 --- /dev/null +++ b/tests/ui/author/issue_3849.stdout @@ -0,0 +1,14 @@ +if_chain! { + if let StmtKind::Local(ref local) = stmt.kind; + if let Some(ref init) = local.init; + if let ExprKind::Call(ref func, ref args) = init.kind; + if let ExprKind::Path(ref path) = func.kind; + if match_qpath(path, &["std", "mem", "transmute"]); + if args.len() == 1; + if let ExprKind::Path(ref path1) = args[0].kind; + if match_qpath(path1, &["ZPTR"]); + if let PatKind::Wild = local.pat.kind; + then { + // report your lint here + } +} diff --git a/tests/ui/author/matches.rs b/tests/ui/author/matches.rs index e6bf229103ff..674e07ec2d3d 100644 --- a/tests/ui/author/matches.rs +++ b/tests/ui/author/matches.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] +#![allow(clippy::let_and_return)] fn main() { #[clippy::author] diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr deleted file mode 100644 index 74d070dc4b28..000000000000 --- a/tests/ui/author/matches.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: returning the result of a let binding from a block - --> $DIR/matches.rs:9:13 - | -LL | let x = 3; - | ---------- unnecessary let binding -LL | x - | ^ - | - = note: `-D clippy::let-and-return` implied by `-D warnings` -help: return the expression directly - | -LL | -LL | 3 - | - -error: aborting due to previous error - diff --git a/tests/ui/author/matches.stdout b/tests/ui/author/matches.stdout new file mode 100644 index 000000000000..2e8f8227dca1 --- /dev/null +++ b/tests/ui/author/matches.stdout @@ -0,0 +1,33 @@ +if_chain! { + if let StmtKind::Local(ref local) = stmt.kind; + if let Some(ref init) = local.init; + if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.kind; + if let ExprKind::Lit(ref lit) = expr.kind; + if let LitKind::Int(42, _) = lit.node; + if arms.len() == 3; + if let ExprKind::Lit(ref lit1) = arms[0].body.kind; + if let LitKind::Int(5, _) = lit1.node; + if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind + if let ExprKind::Lit(ref lit2) = lit_expr.kind; + if let LitKind::Int(16, _) = lit2.node; + if let ExprKind::Block(ref block) = arms[1].body.kind; + if let Some(trailing_expr) = &block.expr; + if block.stmts.len() == 1; + if let StmtKind::Local(ref local1) = block.stmts[0].kind; + if let Some(ref init1) = local1.init; + if let ExprKind::Lit(ref lit3) = init1.kind; + if let LitKind::Int(3, _) = lit3.node; + if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind; + if name.as_str() == "x"; + if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind + if let ExprKind::Lit(ref lit4) = lit_expr1.kind; + if let LitKind::Int(17, _) = lit4.node; + if let ExprKind::Lit(ref lit5) = arms[2].body.kind; + if let LitKind::Int(1, _) = lit5.node; + if let PatKind::Wild = arms[2].pat.kind; + if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind; + if name1.as_str() == "a"; + then { + // report your lint here + } +} diff --git a/tests/ui/author/matches.stout b/tests/ui/author/matches.stout deleted file mode 100644 index 689ee695b601..000000000000 --- a/tests/ui/author/matches.stout +++ /dev/null @@ -1,38 +0,0 @@ -if_chain! { - if let StmtKind::Decl(ref decl, _) = stmt.node - if let DeclKind::Local(ref local) = decl.node; - if let Some(ref init) = local.init; - if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.node; - if let ExprKind::Lit(ref lit) = expr.node; - if let LitKind::Int(42, _) = lit.node; - if arms.len() == 3; - if let ExprKind::Lit(ref lit1) = arms[0].body.node; - if let LitKind::Int(5, _) = lit1.node; - if arms[0].pats.len() == 1; - if let PatKind::Lit(ref lit_expr) = arms[0].pats[0].node - if let ExprKind::Lit(ref lit2) = lit_expr.node; - if let LitKind::Int(16, _) = lit2.node; - if let ExprKind::Block(ref block) = arms[1].body.node; - if let StmtKind::Decl(ref decl1, _) = block.node - if let DeclKind::Local(ref local1) = decl1.node; - if let Some(ref init1) = local1.init - if let ExprKind::Lit(ref lit3) = init1.node; - if let LitKind::Int(3, _) = lit3.node; - if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.node; - if name.node.as_str() == "x"; - if let ExprKind::Path(ref path) = local1.pat.node; - if match_qpath(path, &["x"]); - if arms[1].pats.len() == 1; - if let PatKind::Lit(ref lit_expr1) = arms[1].pats[0].node - if let ExprKind::Lit(ref lit4) = lit_expr1.node; - if let LitKind::Int(17, _) = lit4.node; - if let ExprKind::Lit(ref lit5) = arms[2].body.node; - if let LitKind::Int(1, _) = lit5.node; - if arms[2].pats.len() == 1; - if let PatKind::Wild = arms[2].pats[0].node; - if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.node; - if name1.node.as_str() == "a"; - then { - // report your lint here - } -} diff --git a/tests/ui/issue_3849.stdout b/tests/ui/issue_3849.stdout deleted file mode 100644 index 126c230ac4cc..000000000000 --- a/tests/ui/issue_3849.stdout +++ /dev/null @@ -1,14 +0,0 @@ -if_chain! { - if let StmtKind::Local(ref local) = stmt.node; - if let Some(ref init) = local.init; - if let ExprKind::Call(ref func, ref args) = init.node; - if let ExprKind::Path(ref path) = func.node; - if match_qpath(path, &["std", "mem", "transmute"]); - if args.len() == 1; - if let ExprKind::Path(ref path1) = args[0].node; - if match_qpath(path1, &["ZPTR"]); - if let PatKind::Wild = local.pat.node; - then { - // report your lint here - } -} diff --git a/tests/ui/trailing_zeros.rs b/tests/ui/trailing_zeros.rs index 4ee5ecffb876..1cef8c2cfc99 100644 --- a/tests/ui/trailing_zeros.rs +++ b/tests/ui/trailing_zeros.rs @@ -1,10 +1,8 @@ -#![feature(stmt_expr_attributes)] #![allow(unused_parens)] fn main() { let x: i32 = 42; - let _ = #[clippy::author] - (x & 0b1111 == 0); // suggest trailing_zeros + let _ = (x & 0b1111 == 0); // suggest trailing_zeros let _ = x & 0b1_1111 == 0; // suggest trailing_zeros let _ = x & 0b1_1010 == 0; // do not lint let _ = x & 1 == 0; // do not lint diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 61289b244714..320d9cc3f643 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,13 +1,13 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:7:5 + --> $DIR/trailing_zeros.rs:5:13 | -LL | (x & 0b1111 == 0); // suggest trailing_zeros - | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` +LL | let _ = (x & 0b1111 == 0); // suggest trailing_zeros + | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:8:13 + --> $DIR/trailing_zeros.rs:6:13 | LL | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` diff --git a/tests/ui/trailing_zeros.stdout b/tests/ui/trailing_zeros.stdout deleted file mode 100644 index b311604c0c87..000000000000 --- a/tests/ui/trailing_zeros.stdout +++ /dev/null @@ -1,15 +0,0 @@ -if_chain! { - if let ExprKind::Binary(ref op, ref left, ref right) = expr.node; - if BinOpKind::Eq == op.node; - if let ExprKind::Binary(ref op1, ref left1, ref right1) = left.node; - if BinOpKind::BitAnd == op1.node; - if let ExprKind::Path(ref path) = left1.node; - if match_qpath(path, &["x"]); - if let ExprKind::Lit(ref lit) = right1.node; - if let LitKind::Int(15, _) = lit.node; - if let ExprKind::Lit(ref lit1) = right.node; - if let LitKind::Int(0, _) = lit1.node; - then { - // report your lint here - } -}