]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/serde_api.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / serde_api.rs
index 8090ed7fbcff4caabcb3efa82f2b1e15c7e8a42a..bb4ebf63066b3e20ee520c7fd93e72d6e4fddf6c 100644 (file)
@@ -1,40 +1,29 @@
 use crate::utils::{get_trait_def_id, paths, span_lint};
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc::{declare_lint_pass, declare_tool_lint};
 
-/// **What it does:** Checks for mis-uses of the serde API.
-///
-/// **Why is this bad?** Serde is very finnicky about how its API should be
-/// used, but the type system can't be used to enforce it (yet?).
-///
-/// **Known problems:** None.
-///
-/// **Example:** Implementing `Visitor::visit_string` but not
-/// `Visitor::visit_str`.
 declare_clippy_lint! {
+    /// **What it does:** Checks for mis-uses of the serde API.
+    ///
+    /// **Why is this bad?** Serde is very finnicky about how its API should be
+    /// used, but the type system can't be used to enforce it (yet?).
+    ///
+    /// **Known problems:** None.
+    ///
+    /// **Example:** Implementing `Visitor::visit_string` but not
+    /// `Visitor::visit_str`.
     pub SERDE_API_MISUSE,
     correctness,
     "various things that will negatively affect your serde experience"
 }
 
-#[derive(Copy, Clone)]
-pub struct Serde;
+declare_lint_pass!(SerdeAPI => [SERDE_API_MISUSE]);
 
-impl LintPass for Serde {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(SERDE_API_MISUSE)
-    }
-
-    fn name(&self) -> &'static str {
-        "SerdeAPI"
-    }
-}
-
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde {
+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 {
-            let did = trait_ref.path.def.def_id();
+            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 {
                     let mut seen_str = None;