Cleanup code, fix some incompatibilites with rust head

This commit is contained in:
Erick Tryzelaar 2015-02-13 09:40:47 -08:00
parent 5bce95f3e7
commit b70d77b5c9
3 changed files with 23 additions and 25 deletions

View File

@ -9,7 +9,6 @@ use syntax::ast::{
Item, Item,
Expr, Expr,
MutMutable, MutMutable,
//LitNil,
}; };
use syntax::ast; use syntax::ast;
use syntax::codemap::{Span, respan}; use syntax::codemap::{Span, respan};
@ -34,7 +33,6 @@ use syntax::ext::deriving::generic::ty::{
LifetimeBounds, LifetimeBounds,
Ty, Ty,
Path, Path,
//Tuple,
borrowed_explicit_self, borrowed_explicit_self,
}; };
use syntax::parse::token; use syntax::parse::token;

View File

@ -30,20 +30,6 @@ pub trait Visitor {
type Value; type Value;
type Error; type Error;
fn visit_unit(&mut self) -> Result<Self::Value, Self::Error>;
#[inline]
fn visit_named_unit(&mut self, _name: &str) -> Result<Self::Value, Self::Error> {
self.visit_unit()
}
#[inline]
fn visit_enum_unit(&mut self,
_name: &str,
_variant: &str) -> Result<Self::Value, Self::Error> {
self.visit_unit()
}
fn visit_bool(&mut self, v: bool) -> Result<Self::Value, Self::Error>; fn visit_bool(&mut self, v: bool) -> Result<Self::Value, Self::Error>;
#[inline] #[inline]
@ -109,6 +95,20 @@ pub trait Visitor {
fn visit_str(&mut self, value: &str) -> Result<Self::Value, Self::Error>; fn visit_str(&mut self, value: &str) -> Result<Self::Value, Self::Error>;
fn visit_unit(&mut self) -> Result<Self::Value, Self::Error>;
#[inline]
fn visit_named_unit(&mut self, _name: &str) -> Result<Self::Value, Self::Error> {
self.visit_unit()
}
#[inline]
fn visit_enum_unit(&mut self,
_name: &str,
_variant: &str) -> Result<Self::Value, Self::Error> {
self.visit_unit()
}
fn visit_none(&mut self) -> Result<Self::Value, Self::Error>; fn visit_none(&mut self) -> Result<Self::Value, Self::Error>;
fn visit_some<V>(&mut self, value: V) -> Result<Self::Value, Self::Error> fn visit_some<V>(&mut self, value: V) -> Result<Self::Value, Self::Error>

View File

@ -1,7 +1,7 @@
#![crate_name = "serde_macros"] #![crate_name = "serde_macros"]
#![crate_type = "dylib"] #![crate_type = "dylib"]
#![feature(plugin_registrar, quote, unboxed_closures, rustc_private)] #![feature(core, plugin_registrar, quote, unboxed_closures, rustc_private)]
extern crate syntax; extern crate syntax;
extern crate rustc; extern crate rustc;
@ -143,7 +143,7 @@ fn serialize_substructure(cx: &ExtCtxt,
let name = match (serial_name, name) { let name = match (serial_name, name) {
(Some(serial), _) => serial.clone(), (Some(serial), _) => serial.clone(),
(None, Some(id)) => token::get_ident(id), (None, Some(id)) => token::get_ident(id),
(None, None) => token::intern_and_get_ident(&format!("_field{}", i)), (None, None) => token::intern_and_get_ident(&format!("_field{}", i)[]),
}; };
let name = cx.expr_str(span, name); let name = cx.expr_str(span, name);
@ -261,7 +261,7 @@ fn deserialize_substructure(cx: &mut ExtCtxt,
cx, cx,
span, span,
substr.type_ident, substr.type_ident,
&definition.fields, &definition.fields[],
fields, fields,
deserializer.clone(), deserializer.clone(),
token) token)
@ -271,8 +271,8 @@ fn deserialize_substructure(cx: &mut ExtCtxt,
cx, cx,
span, span,
substr.type_ident, substr.type_ident,
&definition.variants, &definition.variants[],
&fields, &fields[],
deserializer, deserializer,
token) token)
} }
@ -300,7 +300,7 @@ fn deserialize_struct(
let field_idents: Vec<ast::Ident> = fields.iter() let field_idents: Vec<ast::Ident> = fields.iter()
.enumerate() .enumerate()
.map(|(idx, _)| { .map(|(idx, _)| {
cx.ident_of(&format!("field{}", idx)) cx.ident_of(&format!("field{}", idx)[])
}) })
.collect(); .collect();
@ -415,7 +415,7 @@ fn deserialize_enum(
cx, cx,
span, span,
path, path,
&serial_names, &serial_names[],
parts, parts,
|&: cx, _, _| { |&: cx, _, _| {
quote_expr!(cx, try!($deserializer.expect_enum_elt())) quote_expr!(cx, try!($deserializer.expect_enum_elt()))
@ -461,7 +461,7 @@ fn deserialize_static_fields<F>(
getarg( getarg(
cx, cx,
span, span,
token::intern_and_get_ident(&format!("_field{}", i)) token::intern_and_get_ident(&format!("_field{}", i)[])
) )
}).collect(); }).collect();
@ -488,7 +488,7 @@ fn deserialize_static_fields<F>(
} }
} }
fn find_serial_name<'a, I>(iterator: I) -> Option<token::InternedString> where fn find_serial_name<'a, I>(mut iterator: I) -> Option<token::InternedString> where
I: Iterator<Item=&'a Attribute> I: Iterator<Item=&'a Attribute>
{ {
for at in iterator { for at in iterator {