fix(cargo): Update aster, quasi, and syntex
This commit is contained in:
parent
ddc33ee747
commit
f872b3fb4b
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
@ -10,8 +10,7 @@ readme = "../README.md"
|
||||
keywords = ["serde", "serialization"]
|
||||
|
||||
[dependencies]
|
||||
num = "*"
|
||||
num = "^0.1.27"
|
||||
|
||||
[features]
|
||||
nightly = []
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_codegen"
|
||||
version = "0.5.3"
|
||||
version = "0.6.1"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros to auto-generate implementations for the serde framework"
|
||||
@ -15,12 +15,12 @@ nightly = ["quasi_macros"]
|
||||
with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"]
|
||||
|
||||
[build-dependencies]
|
||||
quasi_codegen = { verision = "*", optional = true }
|
||||
syntex = { version = "*", optional = true }
|
||||
quasi_codegen = { verision = "^0.3.4", optional = true }
|
||||
syntex = { version = "^0.18.0", optional = true }
|
||||
|
||||
[dependencies]
|
||||
aster = { version = "*", default-features = false }
|
||||
quasi = { verision = "*", default-features = false }
|
||||
quasi_macros = { version = "*", optional = true }
|
||||
syntex = { version = "*", optional = true }
|
||||
syntex_syntax = { version = "*", optional = true }
|
||||
aster = { version = "^0.5.0", default-features = false }
|
||||
quasi = { verision = "^0.3.5", default-features = false }
|
||||
quasi_macros = { version = "^0.3.5", optional = true }
|
||||
syntex = { version = "^0.17.0", optional = true }
|
||||
syntex_syntax = { version = "^0.18.0", optional = true }
|
||||
|
@ -4,12 +4,11 @@ use aster;
|
||||
|
||||
use syntax::ast::{
|
||||
self,
|
||||
Ident,
|
||||
MetaItem,
|
||||
Item,
|
||||
Expr,
|
||||
StructDef,
|
||||
EnumDef,
|
||||
Expr,
|
||||
Ident,
|
||||
Item,
|
||||
MetaItem,
|
||||
};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
@ -87,14 +86,14 @@ fn deserialize_body(
|
||||
ty: P<ast::Ty>,
|
||||
) -> P<ast::Expr> {
|
||||
match item.node {
|
||||
ast::ItemStruct(ref struct_def, _) => {
|
||||
ast::ItemStruct(ref variant_data, _) => {
|
||||
deserialize_item_struct(
|
||||
cx,
|
||||
builder,
|
||||
item,
|
||||
impl_generics,
|
||||
ty,
|
||||
struct_def,
|
||||
variant_data,
|
||||
)
|
||||
}
|
||||
ast::ItemEnum(ref enum_def, _) => {
|
||||
@ -117,27 +116,17 @@ fn deserialize_item_struct(
|
||||
item: &Item,
|
||||
impl_generics: &ast::Generics,
|
||||
ty: P<ast::Ty>,
|
||||
struct_def: &ast::StructDef,
|
||||
variant_data: &ast::VariantData,
|
||||
) -> P<ast::Expr> {
|
||||
let mut named_fields = vec![];
|
||||
let mut unnamed_fields = 0;
|
||||
|
||||
for field in struct_def.fields.iter() {
|
||||
match field.node.kind {
|
||||
ast::NamedField(name, _) => { named_fields.push(name); }
|
||||
ast::UnnamedField(_) => { unnamed_fields += 1; }
|
||||
}
|
||||
}
|
||||
|
||||
match (named_fields.is_empty(), unnamed_fields) {
|
||||
(true, 0) => {
|
||||
match *variant_data {
|
||||
ast::VariantData::Unit(_) => {
|
||||
deserialize_unit_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
)
|
||||
}
|
||||
(true, 1) => {
|
||||
ast::VariantData::Tuple(ref fields, _) if fields.len() == 1 => {
|
||||
deserialize_newtype_struct(
|
||||
cx,
|
||||
&builder,
|
||||
@ -146,29 +135,34 @@ fn deserialize_item_struct(
|
||||
ty,
|
||||
)
|
||||
}
|
||||
(true, _) => {
|
||||
ast::VariantData::Tuple(ref fields, _) => {
|
||||
if fields.iter().any(|field| !field.node.kind.is_unnamed()) {
|
||||
cx.bug("tuple struct has named fields")
|
||||
}
|
||||
|
||||
deserialize_tuple_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
impl_generics,
|
||||
ty,
|
||||
unnamed_fields,
|
||||
fields.len(),
|
||||
)
|
||||
}
|
||||
(false, 0) => {
|
||||
ast::VariantData::Struct(ref fields, _) => {
|
||||
if fields.iter().any(|field| field.node.kind.is_unnamed()) {
|
||||
cx.bug("struct has unnamed fields")
|
||||
}
|
||||
|
||||
deserialize_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
impl_generics,
|
||||
ty,
|
||||
struct_def,
|
||||
fields,
|
||||
)
|
||||
}
|
||||
(false, _) => {
|
||||
cx.bug("struct has named and unnamed fields")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,9 +416,9 @@ fn deserialize_struct_as_seq(
|
||||
cx: &ExtCtxt,
|
||||
builder: &aster::AstBuilder,
|
||||
struct_path: ast::Path,
|
||||
struct_def: &StructDef,
|
||||
fields: &[ast::StructField],
|
||||
) -> P<ast::Expr> {
|
||||
let let_values: Vec<P<ast::Stmt>> = (0 .. struct_def.fields.len())
|
||||
let let_values: Vec<P<ast::Stmt>> = (0 .. fields.len())
|
||||
.map(|i| {
|
||||
let name = builder.id(format!("__field{}", i));
|
||||
quote_stmt!(cx,
|
||||
@ -440,13 +434,13 @@ fn deserialize_struct_as_seq(
|
||||
|
||||
let result = builder.expr().struct_path(struct_path)
|
||||
.with_id_exprs(
|
||||
struct_def.fields.iter()
|
||||
fields.iter()
|
||||
.enumerate()
|
||||
.map(|(i, field)| {
|
||||
(
|
||||
match field.node.kind {
|
||||
ast::NamedField(name, _) => name.clone(),
|
||||
ast::UnnamedField(_) => panic!("struct contains unnamed fields"),
|
||||
ast::UnnamedField(_) => cx.bug("struct contains unnamed fields"),
|
||||
},
|
||||
builder.expr().id(format!("__field{}", i)),
|
||||
)
|
||||
@ -469,7 +463,7 @@ fn deserialize_struct(
|
||||
type_ident: Ident,
|
||||
impl_generics: &ast::Generics,
|
||||
ty: P<ast::Ty>,
|
||||
struct_def: &StructDef,
|
||||
fields: &[ast::StructField],
|
||||
) -> P<ast::Expr> {
|
||||
let where_clause = &impl_generics.where_clause;
|
||||
|
||||
@ -486,14 +480,14 @@ fn deserialize_struct(
|
||||
cx,
|
||||
builder,
|
||||
type_path.clone(),
|
||||
struct_def
|
||||
fields,
|
||||
);
|
||||
|
||||
let (field_visitor, fields_stmt, visit_map_expr) = deserialize_struct_visitor(
|
||||
cx,
|
||||
builder,
|
||||
struct_def,
|
||||
type_path.clone()
|
||||
type_path.clone(),
|
||||
fields,
|
||||
);
|
||||
|
||||
let type_name = builder.expr().str(type_ident);
|
||||
@ -628,20 +622,20 @@ fn deserialize_variant(
|
||||
) -> P<ast::Expr> {
|
||||
let variant_ident = variant.node.name;
|
||||
|
||||
match variant.node.kind {
|
||||
ast::TupleVariantKind(ref args) if args.is_empty() => {
|
||||
match *variant.node.data {
|
||||
ast::VariantData::Unit(_) => {
|
||||
quote_expr!(cx, {
|
||||
try!(visitor.visit_unit());
|
||||
Ok($type_ident::$variant_ident)
|
||||
})
|
||||
}
|
||||
ast::TupleVariantKind(ref args) if args.len() == 1 => {
|
||||
ast::VariantData::Tuple(ref args, _) if args.len() == 1 => {
|
||||
quote_expr!(cx, {
|
||||
let val = try!(visitor.visit_newtype());
|
||||
Ok($type_ident::$variant_ident(val))
|
||||
})
|
||||
}
|
||||
ast::TupleVariantKind(ref args) => {
|
||||
ast::VariantData::Tuple(ref fields, _) => {
|
||||
deserialize_tuple_variant(
|
||||
cx,
|
||||
builder,
|
||||
@ -649,10 +643,10 @@ fn deserialize_variant(
|
||||
variant_ident,
|
||||
generics,
|
||||
ty,
|
||||
args.len(),
|
||||
fields.len(),
|
||||
)
|
||||
}
|
||||
ast::StructVariantKind(ref struct_def) => {
|
||||
ast::VariantData::Struct(ref fields, _) => {
|
||||
deserialize_struct_variant(
|
||||
cx,
|
||||
builder,
|
||||
@ -660,7 +654,7 @@ fn deserialize_variant(
|
||||
variant_ident,
|
||||
generics,
|
||||
ty,
|
||||
struct_def,
|
||||
fields,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -716,7 +710,7 @@ fn deserialize_struct_variant(
|
||||
variant_ident: ast::Ident,
|
||||
generics: &ast::Generics,
|
||||
ty: P<ast::Ty>,
|
||||
struct_def: &ast::StructDef,
|
||||
fields: &[ast::StructField],
|
||||
) -> P<ast::Expr> {
|
||||
let where_clause = &generics.where_clause;
|
||||
|
||||
@ -729,14 +723,14 @@ fn deserialize_struct_variant(
|
||||
cx,
|
||||
builder,
|
||||
type_path.clone(),
|
||||
struct_def
|
||||
fields,
|
||||
);
|
||||
|
||||
let (field_visitor, fields_stmt, field_expr) = deserialize_struct_visitor(
|
||||
cx,
|
||||
builder,
|
||||
struct_def,
|
||||
type_path
|
||||
type_path,
|
||||
fields,
|
||||
);
|
||||
|
||||
let (visitor_item, visitor_ty, visitor_expr, visitor_generics) =
|
||||
@ -791,7 +785,7 @@ fn deserialize_field_visitor(
|
||||
.enum_("__Field")
|
||||
.with_variants(
|
||||
field_idents.iter().map(|field_ident| {
|
||||
builder.variant(field_ident).tuple().build()
|
||||
builder.variant(field_ident).unit()
|
||||
})
|
||||
)
|
||||
.build();
|
||||
@ -927,25 +921,25 @@ fn deserialize_field_visitor(
|
||||
fn deserialize_struct_visitor(
|
||||
cx: &ExtCtxt,
|
||||
builder: &aster::AstBuilder,
|
||||
struct_def: &ast::StructDef,
|
||||
struct_path: ast::Path,
|
||||
fields: &[ast::StructField],
|
||||
) -> (Vec<P<ast::Item>>, P<ast::Stmt>, P<ast::Expr>) {
|
||||
let field_visitor = deserialize_field_visitor(
|
||||
cx,
|
||||
builder,
|
||||
field::struct_field_attrs(cx, builder, struct_def),
|
||||
field::struct_field_attrs(cx, builder, fields),
|
||||
);
|
||||
|
||||
let visit_map_expr = deserialize_map(
|
||||
cx,
|
||||
builder,
|
||||
struct_path,
|
||||
struct_def,
|
||||
fields,
|
||||
);
|
||||
|
||||
let fields_expr = builder.expr().addr_of().slice()
|
||||
.with_exprs(
|
||||
struct_def.fields.iter()
|
||||
fields.iter()
|
||||
.map(|field| {
|
||||
match field.node.kind {
|
||||
ast::NamedField(name, _) => builder.expr().str(name),
|
||||
@ -966,10 +960,10 @@ fn deserialize_map(
|
||||
cx: &ExtCtxt,
|
||||
builder: &aster::AstBuilder,
|
||||
struct_path: ast::Path,
|
||||
struct_def: &StructDef,
|
||||
fields: &[ast::StructField],
|
||||
) -> P<ast::Expr> {
|
||||
// Create the field names for the fields.
|
||||
let field_names: Vec<ast::Ident> = (0 .. struct_def.fields.len())
|
||||
let field_names: Vec<ast::Ident> = (0 .. fields.len())
|
||||
.map(|i| builder.id(format!("__field{}", i)))
|
||||
.collect();
|
||||
|
||||
@ -990,7 +984,7 @@ fn deserialize_map(
|
||||
.collect();
|
||||
|
||||
let extract_values: Vec<P<ast::Stmt>> = field_names.iter()
|
||||
.zip(field::struct_field_attrs(cx, builder, struct_def).iter())
|
||||
.zip(field::struct_field_attrs(cx, builder, fields).iter())
|
||||
.map(|(field_name, field_attr)| {
|
||||
let missing_expr = if field_attr.use_default() {
|
||||
quote_expr!(cx, ::std::default::Default::default())
|
||||
@ -1027,7 +1021,7 @@ fn deserialize_map(
|
||||
|
||||
let result = builder.expr().struct_path(struct_path)
|
||||
.with_id_exprs(
|
||||
struct_def.fields.iter()
|
||||
fields.iter()
|
||||
.zip(field_names.iter())
|
||||
.map(|(field, field_name)| {
|
||||
(
|
||||
|
@ -7,9 +7,9 @@ use attr::{FieldAttrs, FieldAttrsBuilder};
|
||||
pub fn struct_field_attrs(
|
||||
_cx: &ExtCtxt,
|
||||
builder: &aster::AstBuilder,
|
||||
struct_def: &ast::StructDef,
|
||||
fields: &[ast::StructField],
|
||||
) -> Vec<FieldAttrs> {
|
||||
struct_def.fields.iter()
|
||||
fields.iter()
|
||||
.map(|field| {
|
||||
FieldAttrsBuilder::new(builder).field(field).build()
|
||||
})
|
||||
|
@ -5,7 +5,6 @@ use syntax::ast::{
|
||||
MetaItem,
|
||||
Item,
|
||||
Expr,
|
||||
StructDef,
|
||||
};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
@ -82,14 +81,14 @@ fn serialize_body(
|
||||
ty: P<ast::Ty>,
|
||||
) -> P<ast::Expr> {
|
||||
match item.node {
|
||||
ast::ItemStruct(ref struct_def, _) => {
|
||||
ast::ItemStruct(ref variant_data, _) => {
|
||||
serialize_item_struct(
|
||||
cx,
|
||||
builder,
|
||||
item,
|
||||
impl_generics,
|
||||
ty,
|
||||
struct_def,
|
||||
variant_data,
|
||||
)
|
||||
}
|
||||
ast::ItemEnum(ref enum_def, _) => {
|
||||
@ -112,57 +111,51 @@ fn serialize_item_struct(
|
||||
item: &Item,
|
||||
impl_generics: &ast::Generics,
|
||||
ty: P<ast::Ty>,
|
||||
struct_def: &ast::StructDef,
|
||||
variant_data: &ast::VariantData,
|
||||
) -> P<ast::Expr> {
|
||||
let mut named_fields = vec![];
|
||||
let mut unnamed_fields = 0;
|
||||
|
||||
for field in struct_def.fields.iter() {
|
||||
match field.node.kind {
|
||||
ast::NamedField(name, _) => { named_fields.push(name); }
|
||||
ast::UnnamedField(_) => { unnamed_fields += 1; }
|
||||
}
|
||||
}
|
||||
|
||||
match (named_fields.is_empty(), unnamed_fields) {
|
||||
(true, 0) => {
|
||||
match *variant_data {
|
||||
ast::VariantData::Unit(_) => {
|
||||
serialize_unit_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
)
|
||||
}
|
||||
(true, 1) => {
|
||||
ast::VariantData::Tuple(ref fields, _) if fields.len() == 1 => {
|
||||
serialize_newtype_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
)
|
||||
}
|
||||
(true, _) => {
|
||||
ast::VariantData::Tuple(ref fields, _) => {
|
||||
if fields.iter().any(|field| !field.node.kind.is_unnamed()) {
|
||||
cx.bug("tuple struct has named fields")
|
||||
}
|
||||
|
||||
serialize_tuple_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
impl_generics,
|
||||
ty,
|
||||
unnamed_fields,
|
||||
fields.len(),
|
||||
)
|
||||
}
|
||||
(false, 0) => {
|
||||
ast::VariantData::Struct(ref fields, _) => {
|
||||
if fields.iter().any(|field| field.node.kind.is_unnamed()) {
|
||||
cx.bug("struct has unnamed fields")
|
||||
}
|
||||
|
||||
serialize_struct(
|
||||
cx,
|
||||
&builder,
|
||||
item.ident,
|
||||
impl_generics,
|
||||
ty,
|
||||
struct_def,
|
||||
named_fields,
|
||||
fields,
|
||||
)
|
||||
}
|
||||
(false, _) => {
|
||||
cx.bug("struct has named and unnamed fields")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,8 +218,7 @@ fn serialize_struct(
|
||||
type_ident: Ident,
|
||||
impl_generics: &ast::Generics,
|
||||
ty: P<ast::Ty>,
|
||||
struct_def: &StructDef,
|
||||
fields: Vec<Ident>,
|
||||
fields: &[ast::StructField],
|
||||
) -> P<ast::Expr> {
|
||||
let (visitor_struct, visitor_impl) = serialize_struct_visitor(
|
||||
cx,
|
||||
@ -236,9 +228,12 @@ fn serialize_struct(
|
||||
.ref_()
|
||||
.lifetime("'__a")
|
||||
.build_ty(ty.clone()),
|
||||
struct_def,
|
||||
fields,
|
||||
impl_generics,
|
||||
fields.iter().map(|field| quote_expr!(cx, &self.value.$field)),
|
||||
fields.iter().map(|field| {
|
||||
let name = field.node.ident().expect("struct has unnamed field");
|
||||
quote_expr!(cx, &self.value.$name)
|
||||
})
|
||||
);
|
||||
|
||||
let type_name = builder.expr().str(type_ident);
|
||||
@ -297,8 +292,8 @@ fn serialize_variant(
|
||||
let variant_ident = variant.node.name;
|
||||
let variant_name = builder.expr().str(variant_ident);
|
||||
|
||||
match variant.node.kind {
|
||||
ast::TupleVariantKind(ref args) if args.is_empty() => {
|
||||
match *variant.node.data {
|
||||
ast::VariantData::Unit(_) => {
|
||||
let pat = builder.pat().enum_()
|
||||
.id(type_ident).id(variant_ident).build()
|
||||
.build();
|
||||
@ -314,7 +309,7 @@ fn serialize_variant(
|
||||
}
|
||||
)
|
||||
},
|
||||
ast::TupleVariantKind(ref args) if args.len() == 1 => {
|
||||
ast::VariantData::Tuple(ref fields, _) if fields.len() == 1 => {
|
||||
let field = builder.id("__simple_value");
|
||||
let field = builder.pat().ref_id(field);
|
||||
let pat = builder.pat().enum_()
|
||||
@ -333,14 +328,17 @@ fn serialize_variant(
|
||||
}
|
||||
)
|
||||
},
|
||||
ast::TupleVariantKind(ref args) => {
|
||||
let fields: Vec<ast::Ident> = (0 .. args.len())
|
||||
ast::VariantData::Tuple(ref fields, _) => {
|
||||
let field_names: Vec<ast::Ident> = (0 .. fields.len())
|
||||
.map(|i| builder.id(format!("__field{}", i)))
|
||||
.collect();
|
||||
|
||||
let pat = builder.pat().enum_()
|
||||
.id(type_ident).id(variant_ident).build()
|
||||
.with_pats(fields.iter().map(|field| builder.pat().ref_id(field)))
|
||||
.with_pats(
|
||||
field_names.iter()
|
||||
.map(|field| builder.pat().ref_id(field))
|
||||
)
|
||||
.build();
|
||||
|
||||
let expr = serialize_tuple_variant(
|
||||
@ -351,22 +349,22 @@ fn serialize_variant(
|
||||
variant_name,
|
||||
generics,
|
||||
ty,
|
||||
args,
|
||||
fields,
|
||||
field_names,
|
||||
);
|
||||
|
||||
quote_arm!(cx, $pat => { $expr })
|
||||
}
|
||||
ast::StructVariantKind(ref struct_def) => {
|
||||
let fields: Vec<_> = (0 .. struct_def.fields.len())
|
||||
ast::VariantData::Struct(ref fields, _) => {
|
||||
let field_names: Vec<_> = (0 .. fields.len())
|
||||
.map(|i| builder.id(format!("__field{}", i)))
|
||||
.collect();
|
||||
|
||||
let pat = builder.pat().struct_()
|
||||
.id(type_ident).id(variant_ident).build()
|
||||
.with_pats(
|
||||
fields.iter()
|
||||
.zip(struct_def.fields.iter())
|
||||
field_names.iter()
|
||||
.zip(fields.iter())
|
||||
.map(|(id, field)| {
|
||||
let name = match field.node.kind {
|
||||
ast::NamedField(name, _) => name,
|
||||
@ -388,8 +386,8 @@ fn serialize_variant(
|
||||
variant_name,
|
||||
generics,
|
||||
ty,
|
||||
struct_def,
|
||||
fields,
|
||||
field_names,
|
||||
);
|
||||
|
||||
quote_arm!(cx, $pat => { $expr })
|
||||
@ -405,16 +403,16 @@ fn serialize_tuple_variant(
|
||||
variant_name: P<ast::Expr>,
|
||||
generics: &ast::Generics,
|
||||
structure_ty: P<ast::Ty>,
|
||||
args: &[ast::VariantArg],
|
||||
fields: Vec<Ident>,
|
||||
fields: &[ast::StructField],
|
||||
field_names: Vec<Ident>,
|
||||
) -> P<ast::Expr> {
|
||||
let variant_ty = builder.ty().tuple()
|
||||
.with_tys(
|
||||
args.iter().map(|arg| {
|
||||
fields.iter().map(|field| {
|
||||
builder.ty()
|
||||
.ref_()
|
||||
.lifetime("'__a")
|
||||
.build_ty(arg.ty.clone())
|
||||
.build_ty(field.node.ty.clone())
|
||||
})
|
||||
)
|
||||
.build();
|
||||
@ -424,13 +422,13 @@ fn serialize_tuple_variant(
|
||||
builder,
|
||||
structure_ty.clone(),
|
||||
variant_ty,
|
||||
args.len(),
|
||||
fields.len(),
|
||||
generics,
|
||||
);
|
||||
|
||||
let value_expr = builder.expr().tuple()
|
||||
.with_exprs(
|
||||
fields.iter().map(|field| {
|
||||
field_names.iter().map(|field| {
|
||||
builder.expr().id(field)
|
||||
})
|
||||
)
|
||||
@ -455,12 +453,12 @@ fn serialize_struct_variant(
|
||||
variant_name: P<ast::Expr>,
|
||||
generics: &ast::Generics,
|
||||
structure_ty: P<ast::Ty>,
|
||||
struct_def: &ast::StructDef,
|
||||
fields: Vec<Ident>,
|
||||
fields: &[ast::StructField],
|
||||
field_names: Vec<Ident>,
|
||||
) -> P<ast::Expr> {
|
||||
let value_ty = builder.ty().tuple()
|
||||
.with_tys(
|
||||
struct_def.fields.iter().map(|field| {
|
||||
fields.iter().map(|field| {
|
||||
builder.ty()
|
||||
.ref_()
|
||||
.lifetime("'__a")
|
||||
@ -471,7 +469,7 @@ fn serialize_struct_variant(
|
||||
|
||||
let value_expr = builder.expr().tuple()
|
||||
.with_exprs(
|
||||
fields.iter().map(|field| {
|
||||
field_names.iter().map(|field| {
|
||||
builder.expr().id(field)
|
||||
})
|
||||
)
|
||||
@ -482,9 +480,9 @@ fn serialize_struct_variant(
|
||||
builder,
|
||||
structure_ty.clone(),
|
||||
value_ty,
|
||||
struct_def,
|
||||
fields,
|
||||
generics,
|
||||
(0 .. fields.len()).map(|i| {
|
||||
(0 .. field_names.len()).map(|i| {
|
||||
builder.expr()
|
||||
.tup_field(i)
|
||||
.field("value").self_()
|
||||
@ -574,7 +572,7 @@ fn serialize_struct_visitor<I>(
|
||||
builder: &aster::AstBuilder,
|
||||
structure_ty: P<ast::Ty>,
|
||||
variant_ty: P<ast::Ty>,
|
||||
struct_def: &StructDef,
|
||||
fields: &[ast::StructField],
|
||||
generics: &ast::Generics,
|
||||
value_exprs: I,
|
||||
) -> (P<ast::Item>, P<ast::Item>)
|
||||
@ -582,7 +580,7 @@ fn serialize_struct_visitor<I>(
|
||||
{
|
||||
let value_exprs = value_exprs.collect::<Vec<_>>();
|
||||
|
||||
let field_attrs = struct_field_attrs(cx, builder, struct_def);
|
||||
let field_attrs = struct_field_attrs(cx, builder, fields);
|
||||
|
||||
let arms: Vec<ast::Arm> = field_attrs.iter()
|
||||
.zip(value_exprs.iter())
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_macros"
|
||||
version = "0.5.3"
|
||||
version = "0.6.1"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros to auto-generate implementations for the serde framework"
|
||||
@ -16,6 +16,6 @@ plugin = true
|
||||
serde_codegen = { version = "*", path = "../serde_codegen", default-features = false, features = ["nightly"] }
|
||||
|
||||
[dev-dependencies]
|
||||
num = "*"
|
||||
rustc-serialize = "*"
|
||||
num = "^0.1.27"
|
||||
rustc-serialize = "^0.3.16"
|
||||
serde = { version = "*", path = "../serde", features = ["nightly"] }
|
||||
|
Loading…
Reference in New Issue
Block a user