From 6992937002ee9217be90832569a0b37cb6980916 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 16 Jul 2018 15:07:39 +0200 Subject: [PATCH] Update for hir renamings in rustc --- clippy_lints/src/assign_ops.rs | 30 +++++++-------- clippy_lints/src/attrs.rs | 6 +-- clippy_lints/src/derive.rs | 2 +- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_glob_use.rs | 2 +- clippy_lints/src/escape.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 4 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/functions.rs | 2 +- clippy_lints/src/inherent_impl.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/len_zero.rs | 4 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/lifetimes.rs | 6 +-- clippy_lints/src/loops.rs | 8 ++-- clippy_lints/src/methods.rs | 8 ++-- clippy_lints/src/misc.rs | 4 +- clippy_lints/src/missing_doc.rs | 32 ++++++++-------- clippy_lints/src/missing_inline.rs | 32 ++++++++-------- clippy_lints/src/needless_pass_by_value.rs | 6 +-- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/non_copy_const.rs | 4 +- .../src/overflow_check_conditional.rs | 4 +- clippy_lints/src/partialeq_ne_impl.rs | 2 +- clippy_lints/src/ptr.rs | 4 +- clippy_lints/src/serde_api.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 29 +++++++++++--- clippy_lints/src/swap.rs | 4 +- .../src/trivially_copy_pass_by_ref.rs | 4 +- clippy_lints/src/types.rs | 14 +++---- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/utils/author.rs | 14 +++---- clippy_lints/src/utils/higher.rs | 6 +-- clippy_lints/src/utils/hir_utils.rs | 4 +- clippy_lints/src/utils/inspector.rs | 38 +++++++++---------- clippy_lints/src/utils/internal_lints.rs | 3 +- clippy_lints/src/utils/mod.rs | 2 +- clippy_lints/src/utils/sugg.rs | 32 ++++++++++------ clippy_lints/src/write.rs | 2 +- 41 files changed, 181 insertions(+), 153 deletions(-) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 53b4904fa96..272b6c5a84d 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -142,9 +142,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { $cx:expr, $ty:expr, $rty:expr, - $($trait_name:ident:$full_trait_name:ident),+) => { + $($trait_name:ident),+) => { match $op { - $(hir::$full_trait_name => { + $(hir::BinOpKind::$trait_name => { let [krate, module] = crate::utils::paths::OPS_MODULE; let path = [krate, module, concat!(stringify!($trait_name), "Assign")]; let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) { @@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { if_chain! { if parent_impl != ast::CRATE_NODE_ID; if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl); - if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = + if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; if trait_ref.path.def.def_id() == trait_id; then { return; } @@ -175,18 +175,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { cx, ty, rty.into(), - Add: BinOpKind::Add, - Sub: BinOpKind::Sub, - Mul: BinOpKind::Mul, - Div: BinOpKind::Div, - Rem: BinOpKind::Rem, - And: BinOpKind::And, - Or: BinOpKind::Or, - BitAnd: BinOpKind::BitAnd, - BitOr: BinOpKind::BitOr, - BitXor: BinOpKind::BitXor, - Shr: BinOpKind::Shr, - Shl: BinOpKind::Shl + Add, + Sub, + Mul, + Div, + Rem, + And, + Or, + BitAnd, + BitOr, + BitXor, + Shr, + Shl ) { span_lint_and_then( cx, diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 0523e4d4680..5d5e2f964b0 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { check_attrs(cx, item.span, item.name, &item.attrs) } match item.node { - ItemExternCrate(_) | ItemUse(_, _) => { + ItemKind::ExternCrate(_) | ItemKind::Use(_, _) => { for attr in &item.attrs { if let Some(ref lint_list) = attr.meta_item_list() { match &*attr.name().as_str() { @@ -162,7 +162,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { // whitelist `unused_imports` and `deprecated` for lint in lint_list { if is_word(lint, "unused_imports") || is_word(lint, "deprecated") { - if let ItemUse(_, _) = item.node { + if let ItemKind::Use(_, _) = item.node { return; } } @@ -207,7 +207,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { } fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool { - if let ItemFn(_, _, _, eid) = item.node { + if let ItemKind::Fn(_, _, _, eid) = item.node { is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value) } else { true diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 364c019c486..0d0eb27fb7d 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -70,7 +70,7 @@ impl LintPass for Derive { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id)); let is_automatically_derived = is_automatically_derived(&*item.attrs); diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index 3265338ce12..1ca32cf2263 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -34,7 +34,7 @@ impl LintPass for EmptyEnum { 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.id); - if let ItemEnum(..) = item.node { + if let ItemKind::Enum(..) = item.node { 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/enum_clike.rs b/clippy_lints/src/enum_clike.rs index f191150f3e7..6584bc6ffa9 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { if cx.tcx.data_layout.pointer_size.bits() != 64 { return; } - if let ItemEnum(ref def, _) = item.node { + if let ItemKind::Enum(ref def, _) = item.node { for var in &def.variants { let variant = &var.node; if let Some(ref anon_const) = variant.disr_expr { diff --git a/clippy_lints/src/enum_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index e90dc6f693a..042a96a21c8 100644 --- a/clippy_lints/src/enum_glob_use.rs +++ b/clippy_lints/src/enum_glob_use.rs @@ -47,7 +47,7 @@ impl EnumGlobUse { if item.vis.node.is_pub() { return; // re-exports are fine } - if let ItemUse(ref path, UseKind::Glob) = item.node { + if let ItemKind::Use(ref path, UseKind::Glob) = item.node { if let Def::Enum(_) = path.def { span_lint( cx, diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 0ca6808b12d..a03dc7b6269 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -111,7 +111,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { let id = map.hir_to_node_id(cmt.hir_id); if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) { if let StmtKind::Decl(ref decl, _) = st.node { - if let DeclLocal(ref loc) = decl.node { + if let DeclKind::Local(ref loc) = decl.node { if let Some(ref ex) = loc.init { if let ExprKind::Box(..) = ex.node { if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) { diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index d2ac597b6c5..58436bd897b 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { match stmt.node { StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e), - StmtKind::Decl(ref d, _) => if let DeclLocal(ref local) = d.node { + StmtKind::Decl(ref d, _) => if let DeclKind::Local(ref local) = d.node { if let Local { init: Some(ref e), .. } = **local @@ -267,7 +267,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St // If the declaration is of a local variable, check its initializer // expression if it has one. Otherwise, keep going. let local = match decl.node { - DeclLocal(ref local) => Some(local), + DeclKind::Local(ref local) => Some(local), _ => None, }; local diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 62e2ba7a2de..1ea000d3611 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -39,7 +39,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.id); if_chain! { - if let hir::ItemImpl(.., ref impl_items) = item.node; + if let hir::ItemKind::Impl(.., ref impl_items) = item.node; if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id); if match_def_path(cx.tcx, impl_trait_ref.def_id, &FROM_TRAIT); then { diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 8a480a0286e..16438092315 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { use rustc::hir::map::Node::*; let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) { - matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _)) + matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _)) } else { false }; diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 637ea917a8f..9fb9a162cde 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -56,7 +56,7 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let Item_::ItemImpl(_, _, _, ref generics, None, _, _) = item.node { + if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.node { // Remember for each inherent implementation encoutered its span and generics self.impls .insert(item.hir_id.owner_def_id(), (item.span, generics.clone())); diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index ca136f06aec..926e3a3033f 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -49,7 +49,7 @@ impl LintPass for LargeEnumVariant { 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.id); - if let ItemEnum(ref def, _) = item.node { + if let ItemKind::Enum(ref def, _) = item.node { 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 3b73e78d1a7..bd02eb5c81f 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -68,8 +68,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero { } match item.node { - ItemTrait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items), - ItemImpl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items), + 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), _ => (), } } diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 8661e9eec90..a72e09f9fdf 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { if_chain! { if let Some(expr) = it.peek(); if let hir::StmtKind::Decl(ref decl, _) = stmt.node; - if let hir::DeclLocal(ref decl) = decl.node; + if let hir::DeclKind::Local(ref decl) = decl.node; if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node; if let hir::StmtKind::Expr(ref if_, _) = expr.node; if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node; diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 7ef477baa65..1b371a8141e 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -59,7 +59,7 @@ impl LintPass for LifetimePass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemFn(ref decl, _, ref generics, id) = item.node { + if let ItemKind::Fn(ref decl, _, ref generics, id) = item.node { check_fn_inner(cx, decl, Some(id), generics, item.span); } } @@ -345,7 +345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { if let QPath::Resolved(_, ref path) = *path { if let Def::Existential(def_id) = path.def { let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap(); - if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node { + if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node { for bound in &exist_ty.bounds { if let GenericBound::Outlives(_) = *bound { self.record(&None); @@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { } self.collect_anonymous_lifetimes(path, ty); } - TyTraitObject(ref bounds, ref lt) => { + TyKind::TraitObject(ref bounds, ref lt) => { if !lt.is_elided() { self.abort = true; } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 936d4f6f4cd..e7da7bde30f 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -591,7 +591,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> { fn decl_to_expr(decl: &Decl) -> Option<&Expr> { match decl.node { - DeclLocal(ref local) => local.init.as_ref().map(|p| &**p), + DeclKind::Local(ref local) => local.init.as_ref().map(|p| &**p), _ => None, } } @@ -771,7 +771,7 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: let offset = match idx.node { ExprKind::Binary(op, ref lhs, ref rhs) => match op.node { - BinOpKindAdd => { + BinOpKind::Add => { let offset_opt = if same_var(cx, lhs, var) { extract_offset(cx, rhs, var) } else if same_var(cx, rhs, var) { @@ -1810,7 +1810,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> { return None; } if let StmtKind::Decl(ref decl, _) = block.stmts[0].node { - if let DeclLocal(ref local) = decl.node { + if let DeclKind::Local(ref local) = decl.node { if let Some(ref expr) = local.init { Some(expr) } else { @@ -1931,7 +1931,7 @@ struct InitializeVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { fn visit_decl(&mut self, decl: &'tcx Decl) { // Look for declarations of the variable - if let DeclLocal(ref local) = decl.node { + if let DeclKind::Local(ref local) = decl.node { if local.pat.id == self.var_id { if let PatKind::Binding(_, _, ident, _) = local.pat.node { self.name = Some(ident.name); diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index d341dc21779..26a0b66094f 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -813,7 +813,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if let hir::ImplItemKind::Method(ref sig, id) = implitem.node; if let Some(first_arg_ty) = sig.decl.inputs.get(0); if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next(); - if let hir::ItemImpl(_, _, _, _, None, ref self_ty, _) = item.node; + if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node; then { if cx.access_levels.is_exported(implitem.id) { // check missing trait implementations @@ -1140,7 +1140,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t } hir::map::NodeStmt(stmt) => { if let hir::StmtKind::Decl(ref decl, _) = stmt.node { - if let hir::DeclLocal(ref loc) = decl.node { + if let hir::DeclKind::Local(ref loc) = decl.node { if let hir::PatKind::Ref(..) = loc.pat.node { // let ref y = *x borrows x, let ref y = x.clone() does not return; @@ -1338,7 +1338,7 @@ fn lint_unnecessary_fold(cx: &LateContext, expr: &hir::Expr, fold_args: &[hir::E cx, fold_args, hir::BinOpKind::And, "all", true ), ast::LitKind::Int(0, _) => check_fold_with_op( - cx, fold_args, hir::BinOpKindAdd, "sum", false + cx, fold_args, hir::BinOpKind::Add, "sum", false ), ast::LitKind::Int(1, _) => check_fold_with_op( cx, fold_args, hir::BinOpKind::Mul, "product", false @@ -2175,7 +2175,7 @@ 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::TyTup(vec![].into())); + let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyKind::Tup(vec![].into())); match (self, ty) { (OutType::Unit, &hir::DefaultReturn(_)) => true, (OutType::Unit, &hir::Return(ref ty)) if is_unit(ty) => true, diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index c76ece55e2b..c5440420fc1 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -270,7 +270,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) { if_chain! { if let StmtKind::Decl(ref d, _) = s.node; - if let DeclLocal(ref l) = d.node; + if let DeclKind::Local(ref l) = d.node; if let PatKind::Binding(an, _, i, None) = l.pat.node; if let Some(ref init) = l.init; then { @@ -520,7 +520,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) { let parent_impl = cx.tcx.hir.get_parent(parent_fn); if parent_impl != CRATE_NODE_ID { if let map::NodeItem(item) = cx.tcx.hir.get(parent_impl) { - if let ItemImpl(.., Some(ref trait_ref), _, _) = item.node { + if let ItemKind::Impl(.., Some(ref trait_ref), _, _) = item.node { if trait_ref.path.def.def_id() == partial_eq_trait_id { // we are implementing PartialEq, don't suggest not doing `to_owned`, otherwise // we go into diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index ebb3869f48c..eb4dfe8ba1c 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -122,9 +122,9 @@ 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 { - hir::ItemConst(..) => "a constant", - hir::ItemEnum(..) => "an enum", - hir::ItemFn(..) => { + hir::ItemKind::Const(..) => "a constant", + hir::ItemKind::Enum(..) => "an enum", + hir::ItemKind::Fn(..) => { // ignore main() if it.name == "main" { let def_id = cx.tcx.hir.local_def_id(it.id); @@ -135,19 +135,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } "a function" }, - hir::ItemMod(..) => "a module", - hir::ItemStatic(..) => "a static", - hir::ItemStruct(..) => "a struct", - hir::ItemTrait(..) => "a trait", - hir::ItemTraitAlias(..) => "a trait alias", - hir::ItemGlobalAsm(..) => "an assembly blob", - hir::ItemTy(..) => "a type alias", - hir::ItemUnion(..) => "a union", - hir::ItemExistential(..) => "an existential type", - hir::ItemExternCrate(..) | - hir::ItemForeignMod(..) | - hir::ItemImpl(..) | - hir::ItemUse(..) => return, + hir::ItemKind::Mod(..) => "a module", + hir::ItemKind::Static(..) => "a static", + hir::ItemKind::Struct(..) => "a struct", + hir::ItemKind::Trait(..) => "a trait", + hir::ItemKind::TraitAlias(..) => "a trait alias", + hir::ItemKind::GlobalAsm(..) => "an assembly blob", + hir::ItemKind::Ty(..) => "a type alias", + hir::ItemKind::Union(..) => "a union", + hir::ItemKind::Existential(..) => "an existential type", + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Use(..) => return, }; self.check_missing_docs_attrs(cx, &it.attrs, it.span, desc); diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 6987eaa71d9..0ca1c53d696 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -108,11 +108,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { return; } match it.node { - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { let desc = "a function"; check_missing_inline_attrs(cx, &it.attrs, it.span, desc); }, - hir::ItemTrait(ref _is_auto, ref _unsafe, ref _generics, + hir::ItemKind::Trait(ref _is_auto, ref _unsafe, ref _generics, ref _bounds, ref trait_items) => { // note: we need to check if the trait is exported so we can't use // `LateLintPass::check_trait_item` here. @@ -134,20 +134,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { } } } - hir::ItemConst(..) | - hir::ItemEnum(..) | - hir::ItemMod(..) | - hir::ItemStatic(..) | - hir::ItemStruct(..) | - hir::ItemTraitAlias(..) | - hir::ItemGlobalAsm(..) | - hir::ItemTy(..) | - hir::ItemUnion(..) | - hir::ItemExistential(..) | - hir::ItemExternCrate(..) | - hir::ItemForeignMod(..) | - hir::ItemImpl(..) | - hir::ItemUse(..) => {}, + hir::ItemKind::Const(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Use(..) => {}, }; } diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 5a44431e1a3..fa0586c1548 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -88,8 +88,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Exclude non-inherent impls if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { - if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | - ItemTrait(..)) + if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | + ItemKind::Trait(..)) { return; } @@ -351,7 +351,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { // `let = x;` if_chain! { if let StmtKind::Decl(ref decl, _) = s.node; - if let DeclLocal(ref local) = decl.node; + if let DeclKind::Local(ref local) = decl.node; then { self.spans_need_deref .entry(vid) diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 3f7cbaa6ca1..6be340a99f4 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -89,7 +89,7 @@ impl LintPass for NewWithoutDefault { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { - if let hir::ItemImpl(_, _, _, _, None, _, ref items) = item.node { + if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.node { for assoc_item in items { if let hir::AssociatedItemKind::Method { has_self: false } = assoc_item.kind { let impl_item = cx.tcx.hir.impl_item(assoc_item.id); diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 4e3142e4517..981451947bf 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -164,7 +164,7 @@ impl LintPass for NonCopyConst { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx Item) { - if let ItemConst(hir_ty, ..) = &it.node { + if let ItemKind::Const(hir_ty, ..) = &it.node { let ty = hir_ty_to_ty(cx.tcx, hir_ty); verify_ty_bound(cx, ty, Source::Item { item: it.span }); } @@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { let item_node_id = cx.tcx.hir.get_parent_node(impl_item.id); let item = cx.tcx.hir.expect_item(item_node_id); // ensure the impl is an inherent impl. - if let ItemImpl(_, _, _, _, None, _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node { let ty = hir_ty_to_ty(cx.tcx, hir_ty); verify_ty_bound(cx, ty, Source::Assoc { ty: hir_ty.span, item: impl_item.span }); } diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 4887edea2f3..8783055b31e 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional { if cx.tables.expr_ty(ident2).is_integral(); then { if let BinOpKind::Lt = op.node { - if let BinOpKindAdd = op2.node { + if let BinOpKind::Add = op2.node { span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust."); } @@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional { if cx.tables.expr_ty(ident2).is_integral(); then { if let BinOpKind::Gt = op.node { - if let BinOpKindAdd = op2.node { + if let BinOpKind::Add = op2.node { span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust."); } diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 1d9260e2aa7..2d283b96f86 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -38,7 +38,7 @@ impl LintPass for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { if_chain! { - if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node; + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node; if !is_automatically_derived(&*item.attrs); if let Some(eq_trait) = cx.tcx.lang_items().eq_trait(); if trait_ref.path.def.def_id() == eq_trait; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index bc3bc27f5d9..22804764d8a 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -103,7 +103,7 @@ impl LintPass for PointerPass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemFn(ref decl, _, _, body_id) = item.node { + if let ItemKind::Fn(ref decl, _, _, body_id) = item.node { check_fn(cx, decl, item.id, Some(body_id)); } } @@ -111,7 +111,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { 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 Some(NodeItem(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) { - if let ItemImpl(_, _, _, _, Some(_), _, _) = it.node { + if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node { return; // ignore trait impls } } diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index a4bdd89a037..55c51307e04 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -29,7 +29,7 @@ impl LintPass for Serde { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.node { let did = trait_ref.path.def.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 d400e5bf7a7..cc08e1ee816 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -127,7 +127,7 @@ fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: if higher::is_from_for_desugar(decl) { return; } - if let DeclLocal(ref local) = decl.node { + if let DeclKind::Local(ref local) = decl.node { let Local { ref pat, ref ty, diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index ce2ef951a43..10db53cc782 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -59,10 +59,15 @@ impl LintPass for SuspiciousImpl { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { - use rustc::hir::BinOpKind::*; if let hir::ExprKind::Binary(binop, _, _) = expr.node { match binop.node { - BinOpKind::Eq | BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ne | BinOpKind::Ge | BinOpKind::Gt => return, + | hir::BinOpKind::Eq + | hir::BinOpKind::Lt + | hir::BinOpKind::Le + | hir::BinOpKind::Ne + | hir::BinOpKind::Ge + | hir::BinOpKind::Gt + => return, _ => {}, } // Check if the binary expression is part of another bi/unary expression @@ -94,7 +99,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { expr, binop.node, &["Add", "Sub", "Mul", "Div"], - &[BinOpKind::Add, BinOpKind::Sub, BinOpKind::Mul, BinOpKind::Div], + &[ + hir::BinOpKind::Add, + hir::BinOpKind::Sub, + hir::BinOpKind::Mul, + hir::BinOpKind::Div, + ], ) { span_lint( cx, @@ -124,7 +134,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { "ShrAssign", ], &[ - BinOpKind::Add, BinOpKind::Sub, BinOpKind::Mul, BinOpKind::Div, BinOpKind::BitAnd, BinOpKind::BitOr, BinOpKind::BitXor, BinOpKind::Rem, BinOpKind::Shl, BinOpKind::Shr + hir::BinOpKind::Add, + hir::BinOpKind::Sub, + hir::BinOpKind::Mul, + hir::BinOpKind::Div, + hir::BinOpKind::BitAnd, + hir::BinOpKind::BitOr, + hir::BinOpKind::BitXor, + hir::BinOpKind::Rem, + hir::BinOpKind::Shl, + hir::BinOpKind::Shr, ], ) { span_lint( @@ -167,7 +186,7 @@ fn check_binop<'a>( if_chain! { if parent_impl != ast::CRATE_NODE_ID; if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl); - if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; + if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; if let Some(idx) = trait_ids.iter().position(|&tid| tid == trait_ref.path.def.def_id()); if binop != expected_ops[idx]; then{ diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 6ce7b480250..dfcc9c39348 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -62,7 +62,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) { if_chain! { // let t = foo(); if let StmtKind::Decl(ref tmp, _) = w[0].node; - if let DeclLocal(ref tmp) = tmp.node; + if let DeclKind::Local(ref tmp) = tmp.node; if let Some(ref tmp_init) = tmp.init; if let PatKind::Binding(_, _, ident, None) = tmp.pat.node; @@ -90,7 +90,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) { if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) { let ty = walk_ptrs_ty(cx.tables.expr_ty(lhs1)); - if matches!(ty.sty, ty::TyKind::Slice(_)) || + if matches!(ty.sty, ty::TySlice(_)) || matches!(ty.sty, ty::TyArray(_, _)) || match_type(cx, ty, &paths::VEC) || match_type(cx, ty, &paths::VEC_DEQUE) { diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index e8ee73520ef..18c85cd05ab 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -100,8 +100,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { // Exclude non-inherent impls if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { - if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | - ItemTrait(..)) + if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | + ItemKind::Trait(..)) { return; } diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 98889aaa33c..ae4f579a6f2 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass { fn check_fn(&mut self, cx: &LateContext, _: FnKind, decl: &FnDecl, _: &Body, _: Span, id: NodeId) { // skip trait implementations, see #605 if let Some(map::NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) { - if let ItemImpl(_, _, _, _, Some(..), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { return; } } @@ -343,7 +343,7 @@ fn check_ty_rptr(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool, lt: &Lifeti // Returns true if given type is `Any` trait. fn is_any_trait(t: &hir::Ty) -> bool { if_chain! { - if let TyTraitObject(ref traits, _) = t.node; + if let TyKind::TraitObject(ref traits, _) = t.node; if traits.len() >= 1; // Only Send/Sync can be used as additional traits, so it is enough to // check only the first trait. @@ -377,7 +377,7 @@ declare_clippy_lint! { } fn check_let_unit(cx: &LateContext, decl: &Decl) { - if let DeclLocal(ref local) = decl.node { + if let DeclKind::Local(ref local) = decl.node { if is_unit(cx.tables.pat_ty(&local.pat)) { if in_external_macro(cx, decl.span) || in_macro(local.pat.span) { return; @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { match item.node { - ItemStatic(ref ty, _, _) | ItemConst(ref ty, _) => self.check_type(cx, ty), + ItemKind::Static(ref ty, _, _) | ItemKind::Const(ref ty, _) => self.check_type(cx, ty), // functions, enums, structs, impls and traits are covered _ => (), } @@ -1222,7 +1222,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor { // function types bring a lot of overhead TyKind::BareFn(..) => (50 * self.nest, 1), - TyTraitObject(ref param_bounds, _) => { + TyKind::TraitObject(ref param_bounds, _) => { let has_lifetime_parameters = param_bounds .iter() .any(|bound| bound.bound_generic_params.iter().any(|gen| match gen.kind { @@ -1797,7 +1797,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher { } match item.node { - ItemImpl(_, _, _, ref generics, _, ref ty, ref items) => { + ItemKind::Impl(_, _, _, ref generics, _, ref ty, ref items) => { let mut vis = ImplicitHasherTypeVisitor::new(cx); vis.visit_ty(ty); @@ -1829,7 +1829,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher { ); } }, - ItemFn(ref decl, .., ref generics, body_id) => { + ItemKind::Fn(ref decl, .., ref generics, body_id) => { let body = cx.tcx.hir.body(body_id); for ty in &decl.inputs { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 1af8fe83e8b..230d5fdca2c 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf { return; } if_chain! { - if let ItemImpl(.., ref item_type, ref refs) = item.node; + if let ItemKind::Impl(.., ref item_type, ref refs) = item.node; if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.node; then { let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index e61367fb0b6..9a848c8a805 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -588,20 +588,20 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { } fn visit_stmt(&mut self, s: &Stmt) { - print!(" if let Stmt_::"); + print!(" if let StmtKind::"); let current = format!("{}.node", self.current); match s.node { // Could be an item or a local (let) binding: StmtKind::Decl(ref decl, _) => { let decl_pat = self.next("decl"); - println!("StmtKind::Decl(ref {}, _) = {}", decl_pat, current); - print!(" if let Decl_::"); + println!("Decl(ref {}, _) = {}", decl_pat, current); + print!(" if let DeclKind::"); let current = format!("{}.node", decl_pat); match decl.node { // A local (let) binding: DeclKind::Local(ref local) => { let local_pat = self.next("local"); - println!("DeclLocal(ref {}) = {};", local_pat, current); + println!("Local(ref {}) = {};", local_pat, current); if let Some(ref init) = local.init { let init_pat = self.next("init"); println!(" if let Some(ref {}) = {}.init", init_pat, local_pat); @@ -613,7 +613,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { }, // An item binding: DeclKind::Item(_) => { - println!("DeclItem(item_id) = {};", current); + println!("Item(item_id) = {};", current); }, } } @@ -621,7 +621,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { // Expr without trailing semi-colon (must have unit type): StmtKind::Expr(ref e, _) => { let e_pat = self.next("e"); - println!("StmtKind::Expr(ref {}, _) = {}", e_pat, current); + println!("Expr(ref {}, _) = {}", e_pat, current); self.current = e_pat; self.visit_expr(e); }, @@ -629,7 +629,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { // Expr with trailing semi-colon (may have any type): StmtKind::Semi(ref e, _) => { let e_pat = self.next("e"); - println!("StmtKind::Semi(ref {}, _) = {}", e_pat, current); + println!("Semi(ref {}, _) = {}", e_pat, current); self.current = e_pat; self.visit_expr(e); }, diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 72b39000ce5..3f0243a91c0 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -154,7 +154,7 @@ pub fn is_from_for_desugar(decl: &hir::Decl) -> bool { // } // ``` if_chain! { - if let hir::DeclLocal(ref loc) = decl.node; + if let hir::DeclKind::Local(ref loc) = decl.node; if let Some(ref expr) = loc.init; if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.node; then { @@ -171,7 +171,7 @@ pub fn is_from_for_desugar(decl: &hir::Decl) -> bool { // } // ``` if_chain! { - if let hir::DeclLocal(ref loc) = decl.node; + if let hir::DeclKind::Local(ref loc) = decl.node; if let hir::LocalSource::ForLoopDesugar = loc.source; then { return true; @@ -192,7 +192,7 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> if block.expr.is_none(); if let [ _, _, ref let_stmt, ref body ] = *block.stmts; if let hir::StmtKind::Decl(ref decl, _) = let_stmt.node; - if let hir::DeclLocal(ref decl) = decl.node; + if let hir::DeclKind::Local(ref decl) = decl.node; if let hir::StmtKind::Expr(ref expr, _) = body.node; then { return Some((&*decl.pat, &iterargs[0], expr)); diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 2cec0b2da08..2c5995f1327 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool { match (&left.node, &right.node) { (&StmtKind::Decl(ref l, _), &StmtKind::Decl(ref r, _)) => { - if let (&DeclLocal(ref l), &DeclLocal(ref r)) = (&l.node, &r.node) { + if let (&DeclKind::Local(ref l), &DeclKind::Local(ref r)) = (&l.node, &r.node) { both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) && both(&l.init, &r.init, |l, r| self.eq_expr(l, r)) } else { false @@ -617,7 +617,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { let c: fn(_, _) -> _ = StmtKind::Decl; c.hash(&mut self.s); - if let DeclLocal(ref local) = decl.node { + if let DeclKind::Local(ref local) = decl.node { if let Some(ref init) = local.init { self.hash_expr(init); } diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 1faab372028..b2b99da3c59 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -141,7 +141,7 @@ fn has_attr(attrs: &[Attribute]) -> bool { fn print_decl(cx: &LateContext, decl: &hir::Decl) { match decl.node { - hir::DeclLocal(ref local) => { + hir::DeclKind::Local(ref local) => { println!("local variable of type {}", cx.tables.node_id_to_type(local.hir_id)); println!("pattern:"); print_pat(cx, &local.pat, 0); @@ -150,7 +150,7 @@ fn print_decl(cx: &LateContext, decl: &hir::Decl) { print_expr(cx, e, 0); } }, - hir::DeclItem(_) => println!("item decl"), + hir::DeclKind::Item(_) => println!("item decl"), } } @@ -353,7 +353,7 @@ fn print_item(cx: &LateContext, item: &hir::Item) { hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"), } match item.node { - hir::ItemExternCrate(ref _renamed_from) => { + hir::ItemKind::ExternCrate(ref _renamed_from) => { let def_id = cx.tcx.hir.local_def_id(item.id); if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(def_id) { let source = cx.tcx.used_crate_source(crate_id); @@ -367,32 +367,32 @@ fn print_item(cx: &LateContext, item: &hir::Item) { println!("weird extern crate without a crate id"); } }, - hir::ItemUse(ref path, ref kind) => println!("{:?}, {:?}", path, kind), - hir::ItemStatic(..) => println!("static item of type {:#?}", cx.tcx.type_of(did)), - hir::ItemConst(..) => println!("const item of type {:#?}", cx.tcx.type_of(did)), - hir::ItemFn(..) => { + hir::ItemKind::Use(ref path, ref kind) => println!("{:?}, {:?}", path, kind), + hir::ItemKind::Static(..) => println!("static item of type {:#?}", cx.tcx.type_of(did)), + hir::ItemKind::Const(..) => println!("const item of type {:#?}", cx.tcx.type_of(did)), + hir::ItemKind::Fn(..) => { let item_ty = cx.tcx.type_of(did); println!("function of type {:#?}", item_ty); }, - hir::ItemMod(..) => println!("module"), - hir::ItemForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi), - hir::ItemGlobalAsm(ref asm) => println!("global asm: {:?}", asm), - hir::ItemTy(..) => { + hir::ItemKind::Mod(..) => println!("module"), + hir::ItemKind::ForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi), + hir::ItemKind::GlobalAsm(ref asm) => println!("global asm: {:?}", asm), + hir::ItemKind::Ty(..) => { println!("type alias for {:?}", cx.tcx.type_of(did)); }, - hir::ItemExistential(..) => { + hir::ItemKind::Existential(..) => { println!("existential type with real type {:?}", cx.tcx.type_of(did)); }, - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { println!("enum definition of type {:?}", cx.tcx.type_of(did)); }, - hir::ItemStruct(..) => { + hir::ItemKind::Struct(..) => { println!("struct definition of type {:?}", cx.tcx.type_of(did)); }, - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { println!("union definition of type {:?}", cx.tcx.type_of(did)); }, - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { println!("trait decl"); if cx.tcx.trait_is_auto(did) { println!("trait is auto"); @@ -400,13 +400,13 @@ fn print_item(cx: &LateContext, item: &hir::Item) { println!("trait is not auto"); } }, - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { println!("trait alias"); } - hir::ItemImpl(_, _, _, _, Some(ref _trait_ref), _, _) => { + hir::ItemKind::Impl(_, _, _, _, Some(ref _trait_ref), _, _) => { println!("trait impl"); }, - hir::ItemImpl(_, _, _, _, None, _, _) => { + hir::ItemKind::Impl(_, _, _, _, None, _, _) => { println!("impl"); }, } diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 10d46d8894e..a348df83a9d 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,5 +1,6 @@ use rustc::lint::*; use rustc::hir::*; +use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use crate::utils::{match_qpath, paths, span_lint}; use syntax::symbol::LocalInternedString; @@ -117,7 +118,7 @@ impl LintPass for LintWithoutLintPass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { - if let ItemStatic(ref ty, MutImmutable, body_id) = item.node { + if let hir::ItemKind::Static(ref ty, MutImmutable, body_id) = item.node { if is_lint_ref_type(ty) { self.declared_lints.insert(item.name, item.span); } else if is_lint_array_type(ty) && item.name == "ARRAY" { diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 8a94ae34382..c38a925efed 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -524,7 +524,7 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI match node { Node::NodeBlock(block) => Some(block), Node::NodeItem(&Item { - node: ItemFn(_, _, _, eid), + node: ItemKind::Fn(_, _, _, eid), .. }) | Node::NodeImplItem(&ImplItem { node: ImplItemKind::Method(_, eid), diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 27362bd9be9..ff9424289c5 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -382,21 +382,29 @@ fn associativity(op: &AssocOp) -> Associativity { /// Convert a `hir::BinOp` to the corresponding assigning binary operator. fn hirbinop2assignop(op: hir::BinOp) -> AssocOp { - use rustc::hir::BinOpKind::*; use syntax::parse::token::BinOpToken::*; AssocOp::AssignOp(match op.node { - BinOpKind::Add => Plus, - BinOpKind::BitAnd => And, - BinOpKind::BitOr => Or, - BinOpKind::BitXor => Caret, - BinOpKind::Div => Slash, - BinOpKind::Mul => Star, - BinOpKind::Rem => Percent, - BinOpKind::Shl => Shl, - BinOpKind::Shr => Shr, - BinOpKind::Sub => Minus, - BinOpKind::And | BinOpKind::Eq | BinOpKind::Ge | BinOpKind::Gt | BinOpKind::Le | BinOpKind::Lt | BinOpKind::Ne | BinOpKind::Or => panic!("This operator does not exist"), + hir::BinOpKind::Add => Plus, + hir::BinOpKind::BitAnd => And, + hir::BinOpKind::BitOr => Or, + hir::BinOpKind::BitXor => Caret, + hir::BinOpKind::Div => Slash, + hir::BinOpKind::Mul => Star, + hir::BinOpKind::Rem => Percent, + hir::BinOpKind::Shl => Shl, + hir::BinOpKind::Shr => Shr, + hir::BinOpKind::Sub => Minus, + + | hir::BinOpKind::And + | hir::BinOpKind::Eq + | hir::BinOpKind::Ge + | hir::BinOpKind::Gt + | hir::BinOpKind::Le + | hir::BinOpKind::Lt + | hir::BinOpKind::Ne + | hir::BinOpKind::Or + => panic!("This operator does not exist"), }) } diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 0adbb36b5ff..556d128bca7 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -448,7 +448,7 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool { if let Some(NodeImplItem(item)) = map.find(map.get_parent(expr.id)) { // `Debug` impl if let Some(NodeItem(item)) = map.find(map.get_parent(item.id)) { - if let ItemImpl(_, _, _, _, Some(ref tr), _, _) = item.node { + if let ItemKind::Impl(_, _, _, _, Some(ref tr), _, _) = item.node { return match_path(&tr.path, &["Debug"]); } }