]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/missing_inline.rs
Auto merge of #5334 - flip1995:backport_remerge, r=flip1995
[rust.git] / clippy_lints / src / missing_inline.rs
index 00ccd853cc35200e779fd46efe46b71aeb5e9432..22b56c28b6bc1aa018c2ae15dccef612f998ba12 100644 (file)
@@ -1,10 +1,9 @@
 use crate::utils::span_lint;
-use rustc::declare_lint_pass;
-use rustc::hir;
-use rustc::lint::{self, LateContext, LateLintPass, LintArray, LintContext, LintPass};
-use rustc_session::declare_tool_lint;
-use syntax::ast;
-use syntax::source_map::Span;
+use rustc_ast::ast;
+use rustc_hir as hir;
+use rustc_lint::{self, LateContext, LateLintPass, LintContext};
+use rustc_session::{declare_lint_pass, declare_tool_lint};
+use rustc_span::source_map::Span;
 
 declare_clippy_lint! {
     /// **What it does:** it lints if an exported function, method, trait method with default impl,
@@ -54,7 +53,7 @@
     /// ```
     pub MISSING_INLINE_IN_PUBLIC_ITEMS,
     restriction,
-    "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)"
+    "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)"
 }
 
 fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute], sp: Span, desc: &'static str) {
@@ -70,7 +69,7 @@ fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute]
 }
 
 fn is_executable(cx: &LateContext<'_, '_>) -> bool {
-    use rustc::session::config::CrateType;
+    use rustc_session::config::CrateType;
 
     cx.tcx.sess.crate_types.get().iter().any(|t: &CrateType| match t {
         CrateType::Executable => true,
@@ -82,7 +81,7 @@ fn is_executable(cx: &LateContext<'_, '_>) -> bool {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
     fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item<'_>) {
-        if lint::in_external_macro(cx.sess(), it.span) || is_executable(cx) {
+        if rustc::lint::in_external_macro(cx.sess(), it.span) || is_executable(cx) {
             return;
         }
 
@@ -94,14 +93,14 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item<'_>) {
                 let desc = "a function";
                 check_missing_inline_attrs(cx, &it.attrs, it.span, desc);
             },
-            hir::ItemKind::Trait(ref _is_auto, ref _unsafe, ref _generics, ref _bounds, ref trait_items) => {
+            hir::ItemKind::Trait(ref _is_auto, ref _unsafe, ref _generics, ref _bounds, trait_items) => {
                 // note: we need to check if the trait is exported so we can't use
                 // `LateLintPass::check_trait_item` here.
                 for tit in trait_items {
                     let tit_ = cx.tcx.hir().trait_item(tit.id);
                     match tit_.kind {
                         hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
-                        hir::TraitItemKind::Method(..) => {
+                        hir::TraitItemKind::Fn(..) => {
                             if tit.defaultness.has_value() {
                                 // trait method with default body needs inline in case
                                 // an impl is not provided
@@ -125,14 +124,14 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item<'_>) {
             | hir::ItemKind::OpaqueTy(..)
             | hir::ItemKind::ExternCrate(..)
             | hir::ItemKind::ForeignMod(..)
-            | hir::ItemKind::Impl(..)
+            | hir::ItemKind::Impl { .. }
             | hir::ItemKind::Use(..) => {},
         };
     }
 
     fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
         use rustc::ty::{ImplContainer, TraitContainer};
-        if lint::in_external_macro(cx.sess(), impl_item.span) || is_executable(cx) {
+        if rustc::lint::in_external_macro(cx.sess(), impl_item.span) || is_executable(cx) {
             return;
         }
 
@@ -142,7 +141,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::
         }
 
         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,
         };