]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/trivially_copy_pass_by_ref.rs
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / clippy_lints / src / trivially_copy_pass_by_ref.rs
index f28527dc71fbca0c887f9275bf38518bdc4ed858..8e0cb94317affc2ce1bf3c0e81d3407fda751bf9 100644 (file)
@@ -2,16 +2,14 @@
 
 use crate::utils::{is_copy, is_self_ty, snippet, span_lint_and_sugg};
 use if_chain::if_chain;
-use matches::matches;
-use rustc::hir::intravisit::FnKind;
-use rustc::impl_lint_pass;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::session::config::Config as SessionConfig;
-use rustc::ty;
 use rustc_errors::Applicability;
 use rustc_hir as hir;
-use rustc_hir::*;
-use rustc_session::declare_tool_lint;
+use rustc_hir::intravisit::FnKind;
+use rustc_hir::{Body, FnDecl, HirId, ItemKind, MutTy, Mutability, Node};
+use rustc_lint::{LateContext, LateLintPass};
+use rustc_middle::ty;
+use rustc_session::config::Config as SessionConfig;
+use rustc_session::{declare_tool_lint, impl_lint_pass};
 use rustc_span::Span;
 use rustc_target::abi::LayoutOf;
 use rustc_target::spec::abi::Abi;
@@ -51,7 +49,7 @@
     /// fn foo(v: u32) {}
     /// ```
     pub TRIVIALLY_COPY_PASS_BY_REF,
-    perf,
+    pedantic,
     "functions taking small copyable arguments by reference"
 }
 
@@ -133,7 +131,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Trai
             return;
         }
 
-        if let hir::TraitItemKind::Method(method_sig, _) = &item.kind {
+        if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind {
             self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None);
         }
     }
@@ -163,12 +161,12 @@ fn check_fn(
                 }
             },
             FnKind::Method(..) => (),
-            _ => return,
+            FnKind::Closure(..) => return,
         }
 
         // 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.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
+            if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. } |
                 ItemKind::Trait(..))
             {
                 return;