Skip to content

Commit

Permalink
Bump syntex to 0.43
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 31, 2016
1 parent 7014c10 commit 4bb9279
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 39 deletions.
2 changes: 1 addition & 1 deletion serde/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde"
version = "0.8.4"
version = "0.8.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A generic serialization/deserialization framework"
Expand Down
18 changes: 9 additions & 9 deletions serde_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_codegen"
version = "0.8.4"
version = "0.8.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Macros to auto-generate implementations for the serde framework"
Expand All @@ -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 }
6 changes: 3 additions & 3 deletions serde_codegen_internals/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_codegen_internals"
version = "0.7.0"
version = "0.8.0"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "AST representation used by Serde codegen. Unstable."
Expand All @@ -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 }
58 changes: 39 additions & 19 deletions serde_codegen_internals/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)));
}
}
}
Expand Down Expand Up @@ -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)));
}
}
}
Expand Down Expand Up @@ -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)));
}
}
}
Expand Down Expand Up @@ -454,7 +453,7 @@ type SerAndDe<T> = (Option<Spanned<T>>, Option<Spanned<T>>);
fn get_ser_and_de<T, F>(
cx: &ExtCtxt,
attribute: &'static str,
items: &[P<ast::MetaItem>],
items: &[ast::NestedMetaItem],
f: F
) -> Result<SerAndDe<T>, ()>
where F: Fn(&ExtCtxt, &str, &ast::Lit) -> Result<T, ()>,
Expand All @@ -464,15 +463,29 @@ fn get_ser_and_de<T, F>(

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);
}
}

_ => {
cx.span_err(
item.span,
&format!("unknown {} attribute `{}`",
attribute,
meta_item_to_string(meta_item)));

ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"deserialize" => {
if let Ok(v) = f(cx, name, lit) {
de_item.set(item.span, v);
return Err(());
}
}
}

Expand All @@ -481,7 +494,7 @@ fn get_ser_and_de<T, F>(
item.span,
&format!("unknown {} attribute `{}`",
attribute,
meta_item_to_string(item)));
meta_list_item_to_string(item)));

return Err(());
}
Expand All @@ -493,23 +506,30 @@ fn get_ser_and_de<T, F>(

fn get_renames(
cx: &ExtCtxt,
items: &[P<ast::MetaItem>],
items: &[ast::NestedMetaItem],
) -> Result<SerAndDe<InternedString>, ()> {
get_ser_and_de(cx, "rename", items, get_str_from_lit)
}

fn get_where_predicates(
cx: &ExtCtxt,
items: &[P<ast::MetaItem>],
items: &[ast::NestedMetaItem],
) -> Result<SerAndDe<Vec<ast::WherePredicate>>, ()> {
get_ser_and_de(cx, "bound", items, parse_lit_into_where)
}

pub fn get_serde_meta_items(attr: &ast::Attribute) -> Option<&[P<ast::MetaItem>]> {
pub fn get_serde_meta_items(attr: &ast::Attribute) -> Option<Vec<ast::MetaItem>> {
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
}
Expand Down
8 changes: 4 additions & 4 deletions serde_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_macros"
version = "0.8.4"
version = "0.8.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Macros to auto-generate implementations for the serde framework"
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions serde_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_test"
version = "0.8.4"
version = "0.8.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Token De/Serializer for testing De/Serialize implementations"
Expand All @@ -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" }
2 changes: 1 addition & 1 deletion testing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_testing"
version = "0.8.4"
version = "0.8.5"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A generic serialization/deserialization framework"
Expand Down

0 comments on commit 4bb9279

Please sign in to comment.