diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 1e741936..30b89fbc 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -18,7 +18,7 @@ std = [] unstable = [] alloc = ["unstable"] collections = ["alloc"] -unstable-testing = ["unstable", "std"] +unstable-testing = ["clippy", "unstable", "std"] [dependencies] clippy = { version = "^0.*", optional = true } diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index f8e98bf8..9a74f9e0 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -128,7 +128,7 @@ impl fmt::Display for Error { write!(formatter, "Unknown variant: {}", variant) } Error::UnknownField(ref field) => write!(formatter, "Unknown field: {}", field), - Error::MissingField(ref field) => write!(formatter, "Missing field: {}", field), + Error::MissingField(field) => write!(formatter, "Missing field: {}", field), } } } diff --git a/serde_codegen/Cargo.toml b/serde_codegen/Cargo.toml index f5b20603..1395ca4f 100644 --- a/serde_codegen/Cargo.toml +++ b/serde_codegen/Cargo.toml @@ -14,7 +14,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/lib.rs.in"] [features] default = ["with-syntex"] unstable = ["quasi_macros"] -unstable-testing = [] +unstable-testing = ["clippy"] with-syntex = [ "quasi/with-syntex", "quasi_codegen", diff --git a/serde_codegen_internals/Cargo.toml b/serde_codegen_internals/Cargo.toml index 3181eb19..62b24f2e 100644 --- a/serde_codegen_internals/Cargo.toml +++ b/serde_codegen_internals/Cargo.toml @@ -12,7 +12,7 @@ include = ["Cargo.toml", "src/**/*.rs"] [features] default = ["with-syntex"] -unstable-testing = [] +unstable-testing = ["clippy"] with-syntex = ["syntex_syntax", "syntex_errors"] [dependencies] diff --git a/serde_codegen_internals/src/attr.rs b/serde_codegen_internals/src/attr.rs index 0b2ebf72..8d8d595b 100644 --- a/serde_codegen_internals/src/attr.rs +++ b/serde_codegen_internals/src/attr.rs @@ -449,12 +449,14 @@ impl Field { } } +type SerAndDe = (Option>, Option>); + fn get_ser_and_de( cx: &ExtCtxt, attribute: &'static str, items: &[P], f: F -) -> Result<(Option>, Option>), ()> +) -> Result, ()> where F: Fn(&ExtCtxt, &str, &ast::Lit) -> Result, { let mut ser_item = Attr::none(cx, attribute); @@ -492,21 +494,21 @@ fn get_ser_and_de( fn get_renames( cx: &ExtCtxt, items: &[P], -) -> Result<(Option>, Option>), ()> { +) -> Result, ()> { get_ser_and_de(cx, "rename", items, get_str_from_lit) } fn get_where_predicates( cx: &ExtCtxt, items: &[P], -) -> Result<(Option>>, Option>>), ()> { +) -> Result>, ()> { get_ser_and_de(cx, "bound", items, parse_lit_into_where) } pub fn get_serde_meta_items(attr: &ast::Attribute) -> Option<&[P]> { match attr.node.value.node { ast::MetaItemKind::List(ref name, ref items) if name == &"serde" => { - attr::mark_used(&attr); + attr::mark_used(attr); Some(items) } _ => None @@ -570,7 +572,7 @@ fn get_str_from_lit(cx: &ExtCtxt, name: &str, lit: &ast::Lit) -> Result