diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 59ffaf2a..95064905 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde" -version = "0.8.4" +version = "0.8.5" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "A generic serialization/deserialization framework" diff --git a/serde_codegen/Cargo.toml b/serde_codegen/Cargo.toml index 36f705a5..9bf5a783 100644 --- a/serde_codegen/Cargo.toml +++ b/serde_codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_codegen" -version = "0.8.4" +version = "0.8.5" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "Macros to auto-generate implementations for the serde framework" @@ -25,14 +25,14 @@ with-syntex = [ ] [build-dependencies] -quasi_codegen = { version = "^0.18.0", optional = true } -syntex = { version = "^0.42.2", optional = true } +quasi_codegen = { version = "^0.19.0", optional = true } +syntex = { version = "^0.43.0", optional = true } [dependencies] -aster = { version = "^0.25.0", default-features = false } +aster = { version = "^0.26.0", default-features = false } clippy = { version = "^0.*", optional = true } -quasi = { version = "^0.18.0", default-features = false } -quasi_macros = { version = "^0.18.0", optional = true } -serde_codegen_internals = { version = "=0.7.0", default-features = false, path = "../serde_codegen_internals" } -syntex = { version = "^0.42.2", optional = true } -syntex_syntax = { version = "^0.42.0", optional = true } +quasi = { version = "^0.19.0", default-features = false } +quasi_macros = { version = "^0.19.0", optional = true } +serde_codegen_internals = { version = "=0.8.0", default-features = false, path = "../serde_codegen_internals" } +syntex = { version = "^0.43.0", optional = true } +syntex_syntax = { version = "^0.43.0", optional = true } diff --git a/serde_codegen_internals/Cargo.toml b/serde_codegen_internals/Cargo.toml index 95750d3e..3219579d 100644 --- a/serde_codegen_internals/Cargo.toml +++ b/serde_codegen_internals/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_codegen_internals" -version = "0.7.0" +version = "0.8.0" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "AST representation used by Serde codegen. Unstable." @@ -17,5 +17,5 @@ with-syntex = ["syntex_syntax", "syntex_errors"] [dependencies] clippy = { version = "^0.*", optional = true } -syntex_syntax = { version = "^0.42.0", optional = true } -syntex_errors = { version = "^0.42.0", optional = true } +syntex_syntax = { version = "^0.43.0", optional = true } +syntex_errors = { version = "^0.43.0", optional = true } diff --git a/serde_codegen_internals/src/attr.rs b/serde_codegen_internals/src/attr.rs index 8d8d595b..a4dd2ce3 100644 --- a/serde_codegen_internals/src/attr.rs +++ b/serde_codegen_internals/src/attr.rs @@ -8,8 +8,7 @@ use syntax::fold::Folder; use syntax::parse::parser::{Parser, PathStyle}; use syntax::parse::token::{self, InternedString}; use syntax::parse; -use syntax::print::pprust::{lit_to_string, meta_item_to_string}; -use syntax::ptr::P; +use syntax::print::pprust::{lit_to_string, meta_item_to_string, meta_list_item_to_string}; use syntax::tokenstream::{self, TokenTree}; // This module handles parsing of `#[serde(...)]` attributes. The entrypoints @@ -165,7 +164,7 @@ impl Item { cx.span_err( meta_item.span, &format!("unknown serde container attribute `{}`", - meta_item_to_string(meta_item))); + meta_item_to_string(&meta_item))); } } } @@ -236,7 +235,7 @@ impl Variant { cx.span_err( meta_item.span, &format!("unknown serde variant attribute `{}`", - meta_item_to_string(meta_item))); + meta_item_to_string(&meta_item))); } } } @@ -384,7 +383,7 @@ impl Field { cx.span_err( meta_item.span, &format!("unknown serde field attribute `{}`", - meta_item_to_string(meta_item))); + meta_item_to_string(&meta_item))); } } } @@ -454,7 +453,7 @@ type SerAndDe = (Option>, Option>); fn get_ser_and_de( cx: &ExtCtxt, attribute: &'static str, - items: &[P], + items: &[ast::NestedMetaItem], f: F ) -> Result, ()> where F: Fn(&ExtCtxt, &str, &ast::Lit) -> Result, @@ -464,15 +463,29 @@ fn get_ser_and_de( for item in items { match item.node { - ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"serialize" => { - if let Ok(v) = f(cx, name, lit) { - ser_item.set(item.span, v); - } - } + ast::NestedMetaItemKind::MetaItem(ref meta_item) => { + match meta_item.node { + ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"serialize" => { + if let Ok(v) = f(cx, name, lit) { + ser_item.set(item.span, v); + } + } - ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"deserialize" => { - if let Ok(v) = f(cx, name, lit) { - de_item.set(item.span, v); + ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"deserialize" => { + if let Ok(v) = f(cx, name, lit) { + de_item.set(item.span, v); + } + } + + _ => { + cx.span_err( + item.span, + &format!("unknown {} attribute `{}`", + attribute, + meta_item_to_string(meta_item))); + + return Err(()); + } } } @@ -481,7 +494,7 @@ fn get_ser_and_de( item.span, &format!("unknown {} attribute `{}`", attribute, - meta_item_to_string(item))); + meta_list_item_to_string(item))); return Err(()); } @@ -493,23 +506,30 @@ fn get_ser_and_de( fn get_renames( cx: &ExtCtxt, - items: &[P], + items: &[ast::NestedMetaItem], ) -> Result, ()> { get_ser_and_de(cx, "rename", items, get_str_from_lit) } fn get_where_predicates( cx: &ExtCtxt, - items: &[P], + items: &[ast::NestedMetaItem], ) -> Result>, ()> { get_ser_and_de(cx, "bound", items, parse_lit_into_where) } -pub fn get_serde_meta_items(attr: &ast::Attribute) -> Option<&[P]> { +pub fn get_serde_meta_items(attr: &ast::Attribute) -> Option> { match attr.node.value.node { ast::MetaItemKind::List(ref name, ref items) if name == &"serde" => { attr::mark_used(attr); - Some(items) + Some(items.iter().filter_map(|item| { + match item.node { + ast::NestedMetaItemKind::MetaItem(ref meta_item) => { + Some((*meta_item.clone()).clone()) + } + _ => None, + } + }).collect()) } _ => None } diff --git a/serde_macros/Cargo.toml b/serde_macros/Cargo.toml index f9c832d2..805c8647 100644 --- a/serde_macros/Cargo.toml +++ b/serde_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_macros" -version = "0.8.4" +version = "0.8.5" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "Macros to auto-generate implementations for the serde framework" @@ -23,14 +23,14 @@ unstable-testing = [ [dependencies] clippy = { version = "^0.*", optional = true } -serde_codegen = { version = "=0.8.4", default-features = false, features = ["unstable"], path = "../serde_codegen" } +serde_codegen = { version = "=0.8.5", default-features = false, features = ["unstable"], path = "../serde_codegen" } [dev-dependencies] compiletest_rs = "^0.2.0" fnv = "1.0" rustc-serialize = "^0.3.16" -serde = { version = "0.8.4", path = "../serde" } -serde_test = { version = "0.8.4", path = "../serde_test" } +serde = { version = "0.8.5", path = "../serde" } +serde_test = { version = "0.8.5", path = "../serde_test" } [[test]] name = "test" diff --git a/serde_test/Cargo.toml b/serde_test/Cargo.toml index 878164e5..5ebf58a1 100644 --- a/serde_test/Cargo.toml +++ b/serde_test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_test" -version = "0.8.4" +version = "0.8.5" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "Token De/Serializer for testing De/Serialize implementations" @@ -12,4 +12,4 @@ keywords = ["serde", "serialization"] include = ["Cargo.toml", "src/**/*.rs"] [dependencies] -serde = { version = "0.8.4", path = "../serde" } +serde = { version = "0.8.5", path = "../serde" } diff --git a/testing/Cargo.toml b/testing/Cargo.toml index 9f9fe69e..b21f8889 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_testing" -version = "0.8.4" +version = "0.8.5" authors = ["Erick Tryzelaar "] license = "MIT/Apache-2.0" description = "A generic serialization/deserialization framework"