diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 833739f1bd3c..35cde05e7f57 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -12,7 +12,7 @@ use rustc_ast::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_errors::Applicability; use rustc_hir::{ - Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitItem, TraitItemKind, TraitMethod, + Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind, }; use rustc_lint::{CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -372,15 +372,15 @@ fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item<'_>) -> bool { fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) -> bool { match item.kind { - ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value), + ImplItemKind::Fn(_, 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.kind { - TraitItemKind::Fn(_, TraitMethod::Required(_)) => true, - TraitItemKind::Fn(_, TraitMethod::Provided(eid)) => { + TraitItemKind::Fn(_, TraitFn::Required(_)) => true, + TraitItemKind::Fn(_, TraitFn::Provided(eid)) => { is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) }, _ => false, diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index ed870850a8c4..9b028cd0f76b 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -191,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown { if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) { return; } - if let hir::ImplItemKind::Method(ref sig, body_id) = item.kind { + if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind { lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id)); } } diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 5ed7fd49f472..06608772c8af 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -93,7 +93,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it for impl_item in impl_items { if_chain! { if impl_item.ident.name == sym!(from); - if let ImplItemKind::Method(_, body_id) = + if let ImplItemKind::Fn(_, body_id) = cx.tcx.hir().impl_item(impl_item.id).kind; then { // check the body for `begin_panic` or `unwrap` diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 23e3371c5fb6..01ced205af48 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -250,7 +250,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) { - if let hir::ImplItemKind::Method(ref sig, ref body_id) = item.kind { + if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind { let attr = must_use_attr(&item.attrs); if let Some(attr) = attr { let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); @@ -284,7 +284,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr); } - if let hir::TraitMethod::Provided(eid) = *eid { + if let hir::TraitFn::Provided(eid) = *eid { let body = cx.tcx.hir().body(eid); Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id); diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 24c0b1cb80e6..ca8e834e347c 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.kind; + if let ImplItemKind::Fn(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 32032c4da885..08fc6287b776 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -4,7 +4,7 @@ use crate::utils::span_lint_and_then; use crate::utils::sugg::DiagnosticBuilderExt; use rustc_ast::ast::{Attribute, Name}; use rustc_errors::Applicability; -use rustc_hir::{TraitItem, TraitItemKind, TraitMethod}; +use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -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::Fn(_, TraitMethod::Required(_)) = item.kind { + if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind { check_attrs(cx, item.ident.name, &item.attrs); } } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 30ad32c8ed16..85d3e9029dff 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -9,7 +9,7 @@ use rustc_hir::intravisit::{ use rustc_hir::FnRetTy::Return; use rustc_hir::{ BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem, ImplItemKind, Item, - ItemKind, Lifetime, LifetimeName, ParamName, QPath, TraitBoundModifier, TraitItem, TraitItemKind, TraitMethod, Ty, + ItemKind, Lifetime, LifetimeName, ParamName, QPath, TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WhereClause, WherePredicate, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) { - if let ImplItemKind::Method(ref sig, id) = item.kind { + if let ImplItemKind::Fn(ref sig, id) = item.kind { let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none(); check_fn_inner( cx, @@ -102,8 +102,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) { if let TraitItemKind::Fn(ref sig, ref body) = item.kind { let body = match *body { - TraitMethod::Required(_) => None, - TraitMethod::Provided(id) => Some(id), + TraitFn::Required(_) => None, + TraitFn::Provided(id) => Some(id), }; check_fn_inner(cx, &sig.decl, body, &item.generics, item.span, true); } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index ab51ecfb1b5d..8bba56c675ff 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1410,7 +1410,7 @@ 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.kind; + if let hir::ImplItemKind::Fn(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{ of_trait: None, .. } = item.kind; @@ -1469,7 +1469,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { } } - if let hir::ImplItemKind::Method(_, _) = impl_item.kind { + if let hir::ImplItemKind::Fn(_, _) = 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) diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 88467f3057f5..96750cb3b466 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -185,7 +185,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { let desc = match impl_item.kind { hir::ImplItemKind::Const(..) => "an associated constant", - hir::ImplItemKind::Method(..) => "a method", + hir::ImplItemKind::Fn(..) => "a method", hir::ImplItemKind::TyAlias(_) => "an associated type", hir::ImplItemKind::OpaqueTy(_) => "an existential type", }; diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index fad4d6d0fe2e..0f871d29c2f3 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -141,7 +141,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { } let desc = match impl_item.kind { - hir::ImplItemKind::Method(..) => "a method", + hir::ImplItemKind::Fn(..) => "a method", hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) | hir::ImplItemKind::OpaqueTy(_) => return, }; diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 61f514a740a5..adaf82c70748 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableKeyType { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'tcx>) { - if let hir::ImplItemKind::Method(ref sig, ..) = item.kind { + if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind { if trait_ref_of_method(cx, item.hir_id).is_none() { check_sig(cx, item.hir_id, &sig.decl); } diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 303ba1e68087..adc93909677d 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { if in_external_macro(cx.sess(), impl_item.span) { return; } - if let hir::ImplItemKind::Method(ref sig, _) = impl_item.kind { + if let hir::ImplItemKind::Fn(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/ptr.rs b/clippy_lints/src/ptr.rs index a6d62406aa76..3d420cf8cecf 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -10,7 +10,7 @@ use rustc::ty; use rustc_errors::Applicability; use rustc_hir::{ BinOpKind, BodyId, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind, - Lifetime, MutTy, Mutability, Node, PathSegment, QPath, TraitItem, TraitItemKind, TraitMethod, Ty, TyKind, + Lifetime, MutTy, Mutability, Node, PathSegment, QPath, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, }; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -109,7 +109,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr { } fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) { - if let ImplItemKind::Method(ref sig, body_id) = item.kind { + if let ImplItemKind::Fn(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 { of_trait: Some(_), .. } = it.kind { @@ -122,7 +122,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::Fn(ref sig, ref trait_method) = item.kind { - let body_id = if let TraitMethod::Provided(b) = *trait_method { + let body_id = if let TraitFn::Provided(b) = *trait_method { Some(b) } else { None diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index d44aa492508a..26d425cf2416 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -15,8 +15,8 @@ use rustc_hir as hir; use rustc_hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor}; use rustc_hir::{ BinOpKind, Body, Expr, ExprKind, FnDecl, FnRetTy, FnSig, GenericArg, GenericParamKind, HirId, ImplItem, - ImplItemKind, Item, ItemKind, Lifetime, Local, MatchSource, MutTy, Mutability, QPath, Stmt, StmtKind, TraitItem, - TraitItemKind, TraitMethod, TyKind, UnOp, + ImplItemKind, Item, ItemKind, Lifetime, Local, MatchSource, MutTy, Mutability, QPath, Stmt, StmtKind, TraitFn, + TraitItem, TraitItemKind, TyKind, UnOp, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; @@ -1457,7 +1457,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) { match item.kind { TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty), - TraitItemKind::Fn(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl), + TraitItemKind::Fn(FnSig { ref decl, .. }, TraitFn::Required(_)) => self.check_fndecl(cx, decl), // methods with default impl are covered by check_fn _ => (), } diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 8579fd73fbb7..a45b4a6869c5 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -58,7 +58,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf { kind: AssocItemKind::Method { has_self: true }, .. } = impl_item_ref; - if let ImplItemKind::Method(_, body_id) = &impl_item.kind; + if let ImplItemKind::Fn(_, body_id) = &impl_item.kind; let body = cx.tcx.hir().body(*body_id); if !body.params.is_empty(); then { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index e1316fa0a3db..73a986b79011 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -195,7 +195,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf { if let Some(impl_trait_ref) = impl_trait_ref { for impl_item_ref in refs { let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id); - if let ImplItemKind::Method(FnSig{ decl: impl_decl, .. }, impl_body_id) + if let ImplItemKind::Fn(FnSig{ decl: impl_decl, .. }, impl_body_id) = &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); diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index a2a4dc4201b0..d79f6d525fcf 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector { println!("associated constant"); print_expr(cx, &cx.tcx.hir().body(body_id).value, 1); }, - hir::ImplItemKind::Method(..) => println!("method"), + hir::ImplItemKind::Fn(..) => println!("method"), hir::ImplItemKind::TyAlias(_) => println!("associated type"), hir::ImplItemKind::OpaqueTy(_) => println!("existential type"), } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 2a8e172663d2..280e8e2f32e6 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -101,7 +101,7 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool { .. }) | Node::ImplItem(&ImplItem { - kind: ImplItemKind::Method(ref sig, _), + kind: ImplItemKind::Fn(ref sig, _), .. }) => sig.header.constness == Constness::Const, _ => false, @@ -758,7 +758,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId) .. }) | Node::ImplItem(&ImplItem { - kind: ImplItemKind::Method(_, eid), + kind: ImplItemKind::Fn(_, eid), .. }) => match cx.tcx.hir().body(eid).value.kind { ExprKind::Block(ref block, _) => Some(block),