More cleanup

This commit is contained in:
Erick Tryzelaar
2015-03-14 00:08:23 -07:00
parent 13fcf1ad5b
commit a3b2f00c92
+10 -14
View File
@@ -706,6 +706,10 @@ fn deserialize_struct(
visitor_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>,
) -> P<ast::Expr> {
let value_ty = builder.ty().path()
.segment(type_ident).with_generics(trait_generics.clone()).build()
.build();
match *fields {
Unnamed(ref fields) => {
if fields.is_empty() {
@@ -720,7 +724,6 @@ fn deserialize_struct(
deserialize_struct_unnamed_fields(
cx,
builder,
type_ident,
struct_ident,
struct_path,
&fields,
@@ -729,6 +732,7 @@ fn deserialize_struct(
visitor_item,
visitor_ty,
visitor_expr,
value_ty,
)
}
}
@@ -737,7 +741,6 @@ fn deserialize_struct(
cx,
span,
builder,
type_ident,
struct_ident,
struct_path,
&fields,
@@ -747,6 +750,7 @@ fn deserialize_struct(
visitor_item,
visitor_ty,
visitor_expr,
value_ty,
)
}
}
@@ -804,7 +808,6 @@ fn deserialize_struct_empty_fields(
fn deserialize_struct_unnamed_fields(
cx: &ExtCtxt,
builder: &aster::AstBuilder,
type_ident: Ident,
struct_ident: Ident,
struct_path: ast::Path,
fields: &[Span],
@@ -813,6 +816,7 @@ fn deserialize_struct_unnamed_fields(
visitor_item: P<ast::Item>,
visitor_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>,
value_ty: P<ast::Ty>,
) -> P<ast::Expr> {
let where_clause = &trait_generics.where_clause;
@@ -829,10 +833,6 @@ fn deserialize_struct_unnamed_fields(
let struct_name = builder.expr().str(struct_ident);
let value_ty = builder.ty().path()
.segment(type_ident).with_generics(trait_generics.clone()).build()
.build();
quote_expr!(cx, {
$visitor_item
@@ -899,7 +899,6 @@ fn deserialize_struct_named_fields(
cx: &ExtCtxt,
span: Span,
builder: &aster::AstBuilder,
type_ident: Ident,
struct_ident: Ident,
struct_path: ast::Path,
fields: &[(Ident, Span)],
@@ -909,6 +908,7 @@ fn deserialize_struct_named_fields(
visitor_item: P<ast::Item>,
visitor_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>,
value_ty: P<ast::Ty>,
) -> P<ast::Expr> {
let where_clause = &trait_generics.where_clause;
@@ -917,12 +917,6 @@ fn deserialize_struct_named_fields(
.map(|i| token::str_to_ident(&format!("__field{}", i)))
.collect();
let struct_name = builder.expr().str(struct_ident);
let value_ty = builder.ty().path()
.segment(type_ident).with_generics(trait_generics.clone()).build()
.build();
let field_devisitor = declare_map_field_devisitor(
cx,
span,
@@ -941,6 +935,8 @@ fn deserialize_struct_named_fields(
struct_def
);
let struct_name = builder.expr().str(struct_ident);
quote_expr!(cx, {
$field_devisitor