]> git.lizzy.rs Git - rust.git/commitdiff
Update to serde 1.0
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 9 May 2017 13:23:10 +0000 (15:23 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 9 May 2017 13:23:10 +0000 (15:23 +0200)
Cargo.toml
clippy_lints/src/lib.rs
clippy_lints/src/serde.rs [deleted file]
clippy_lints/src/serde_api.rs [new file with mode: 0644]
tests/ui/serde.rs

index 96eb3fac3c33bf7204ef99c8df7b88d2d98065f5..f830aeabe6f7402a61f0963efd1a8ba79ee3429b 100644 (file)
@@ -32,15 +32,15 @@ test = false
 # begin automatic update
 clippy_lints = { version = "0.0.131", path = "clippy_lints" }
 # end automatic update
-cargo_metadata = "0.1.1"
+cargo_metadata = "0.2"
 
 [dev-dependencies]
 compiletest_rs = "0.2.5"
-lazy_static = "0.1.15"
+lazy_static = "0.2"
 regex = "0.2"
-serde_derive = "0.9.1"
+serde_derive = "1.0"
 clippy-mini-macro-test = { version = "0.1", path = "mini-macro" }
-serde = "0.9.1"
+serde = "1.0"
 
 [features]
 debugging = []
index 29ecf105b65b02a61a7b5396d103fe5a17296eb9..79c05b5e01a46f3f2957f358e30b729e94334124 100644 (file)
@@ -124,7 +124,7 @@ macro_rules! declare_restriction_lint {
 pub mod reference;
 pub mod regex;
 pub mod returns;
-pub mod serde;
+pub mod serde_api;
 pub mod shadow;
 pub mod should_assert_eq;
 pub mod strings;
@@ -202,7 +202,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
     );
     // end deprecated lints, do not remove this comment, it’s used in `update_lints`
 
-    reg.register_late_lint_pass(box serde::Serde);
+    reg.register_late_lint_pass(box serde_api::Serde);
     reg.register_early_lint_pass(box utils::internal_lints::Clippy);
     reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
     reg.register_late_lint_pass(box utils::inspector::Pass);
diff --git a/clippy_lints/src/serde.rs b/clippy_lints/src/serde.rs
deleted file mode 100644 (file)
index df80347..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-use rustc::lint::*;
-use rustc::hir::*;
-use utils::{span_lint, get_trait_def_id, paths};
-
-/// **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_lint! {
-    pub SERDE_API_MISUSE,
-    Warn,
-    "various things that will negatively affect your serde experience"
-}
-
-
-#[derive(Copy, Clone)]
-pub struct Serde;
-
-impl LintPass for Serde {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(SERDE_API_MISUSE)
-    }
-}
-
-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 {
-            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 {
-                    let mut seen_str = None;
-                    let mut seen_string = None;
-                    for item in items {
-                        match &*item.name.as_str() {
-                            "visit_str" => seen_str = Some(item.span),
-                            "visit_string" => seen_string = Some(item.span),
-                            _ => {},
-                        }
-                    }
-                    if let Some(span) = seen_string {
-                        if seen_str.is_none() {
-                            span_lint(cx,
-                                      SERDE_API_MISUSE,
-                                      span,
-                                      "you should not implement `visit_string` without also implementing `visit_str`");
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs
new file mode 100644 (file)
index 0000000..df80347
--- /dev/null
@@ -0,0 +1,56 @@
+use rustc::lint::*;
+use rustc::hir::*;
+use utils::{span_lint, get_trait_def_id, paths};
+
+/// **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_lint! {
+    pub SERDE_API_MISUSE,
+    Warn,
+    "various things that will negatively affect your serde experience"
+}
+
+
+#[derive(Copy, Clone)]
+pub struct Serde;
+
+impl LintPass for Serde {
+    fn get_lints(&self) -> LintArray {
+        lint_array!(SERDE_API_MISUSE)
+    }
+}
+
+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 {
+            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 {
+                    let mut seen_str = None;
+                    let mut seen_string = None;
+                    for item in items {
+                        match &*item.name.as_str() {
+                            "visit_str" => seen_str = Some(item.span),
+                            "visit_string" => seen_string = Some(item.span),
+                            _ => {},
+                        }
+                    }
+                    if let Some(span) = seen_string {
+                        if seen_str.is_none() {
+                            span_lint(cx,
+                                      SERDE_API_MISUSE,
+                                      span,
+                                      "you should not implement `visit_string` without also implementing `visit_str`");
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
index 78aabf352bb05ae1de23074e9e0be9419dfb5982..83150638ac1044229c99f4321b7af2de41f86bd4 100644 (file)
@@ -7,7 +7,7 @@
 
 struct A;
 
-impl serde::de::Visitor for A {
+impl<'de> serde::de::Visitor<'de> for A {
     type Value = ();
 
     fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
@@ -29,7 +29,7 @@ fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
 
 struct B;
 
-impl serde::de::Visitor for B {
+impl<'de> serde::de::Visitor<'de> for B {
     type Value = ();
 
     fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {