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_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>, visitor_expr: P<ast::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 { match *fields {
Unnamed(ref fields) => { Unnamed(ref fields) => {
if fields.is_empty() { if fields.is_empty() {
@@ -720,7 +724,6 @@ fn deserialize_struct(
deserialize_struct_unnamed_fields( deserialize_struct_unnamed_fields(
cx, cx,
builder, builder,
type_ident,
struct_ident, struct_ident,
struct_path, struct_path,
&fields, &fields,
@@ -729,6 +732,7 @@ fn deserialize_struct(
visitor_item, visitor_item,
visitor_ty, visitor_ty,
visitor_expr, visitor_expr,
value_ty,
) )
} }
} }
@@ -737,7 +741,6 @@ fn deserialize_struct(
cx, cx,
span, span,
builder, builder,
type_ident,
struct_ident, struct_ident,
struct_path, struct_path,
&fields, &fields,
@@ -747,6 +750,7 @@ fn deserialize_struct(
visitor_item, visitor_item,
visitor_ty, visitor_ty,
visitor_expr, visitor_expr,
value_ty,
) )
} }
} }
@@ -804,7 +808,6 @@ fn deserialize_struct_empty_fields(
fn deserialize_struct_unnamed_fields( fn deserialize_struct_unnamed_fields(
cx: &ExtCtxt, cx: &ExtCtxt,
builder: &aster::AstBuilder, builder: &aster::AstBuilder,
type_ident: Ident,
struct_ident: Ident, struct_ident: Ident,
struct_path: ast::Path, struct_path: ast::Path,
fields: &[Span], fields: &[Span],
@@ -813,6 +816,7 @@ fn deserialize_struct_unnamed_fields(
visitor_item: P<ast::Item>, visitor_item: P<ast::Item>,
visitor_ty: P<ast::Ty>, visitor_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>, visitor_expr: P<ast::Expr>,
value_ty: P<ast::Ty>,
) -> P<ast::Expr> { ) -> P<ast::Expr> {
let where_clause = &trait_generics.where_clause; 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 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, { quote_expr!(cx, {
$visitor_item $visitor_item
@@ -899,7 +899,6 @@ fn deserialize_struct_named_fields(
cx: &ExtCtxt, cx: &ExtCtxt,
span: Span, span: Span,
builder: &aster::AstBuilder, builder: &aster::AstBuilder,
type_ident: Ident,
struct_ident: Ident, struct_ident: Ident,
struct_path: ast::Path, struct_path: ast::Path,
fields: &[(Ident, Span)], fields: &[(Ident, Span)],
@@ -909,6 +908,7 @@ fn deserialize_struct_named_fields(
visitor_item: P<ast::Item>, visitor_item: P<ast::Item>,
visitor_ty: P<ast::Ty>, visitor_ty: P<ast::Ty>,
visitor_expr: P<ast::Expr>, visitor_expr: P<ast::Expr>,
value_ty: P<ast::Ty>,
) -> P<ast::Expr> { ) -> P<ast::Expr> {
let where_clause = &trait_generics.where_clause; 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))) .map(|i| token::str_to_ident(&format!("__field{}", i)))
.collect(); .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( let field_devisitor = declare_map_field_devisitor(
cx, cx,
span, span,
@@ -941,6 +935,8 @@ fn deserialize_struct_named_fields(
struct_def struct_def
); );
let struct_name = builder.expr().str(struct_ident);
quote_expr!(cx, { quote_expr!(cx, {
$field_devisitor $field_devisitor