Cleanup code, fix some incompatibilites with rust head
This commit is contained in:
parent
5bce95f3e7
commit
b70d77b5c9
@ -9,7 +9,6 @@ use syntax::ast::{
|
||||
Item,
|
||||
Expr,
|
||||
MutMutable,
|
||||
//LitNil,
|
||||
};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{Span, respan};
|
||||
@ -34,7 +33,6 @@ use syntax::ext::deriving::generic::ty::{
|
||||
LifetimeBounds,
|
||||
Ty,
|
||||
Path,
|
||||
//Tuple,
|
||||
borrowed_explicit_self,
|
||||
};
|
||||
use syntax::parse::token;
|
||||
|
@ -30,20 +30,6 @@ pub trait Visitor {
|
||||
type Value;
|
||||
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>;
|
||||
|
||||
#[inline]
|
||||
@ -109,6 +95,20 @@ pub trait Visitor {
|
||||
|
||||
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_some<V>(&mut self, value: V) -> Result<Self::Value, Self::Error>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![crate_name = "serde_macros"]
|
||||
#![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 rustc;
|
||||
@ -143,7 +143,7 @@ fn serialize_substructure(cx: &ExtCtxt,
|
||||
let name = match (serial_name, name) {
|
||||
(Some(serial), _) => serial.clone(),
|
||||
(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);
|
||||
@ -261,7 +261,7 @@ fn deserialize_substructure(cx: &mut ExtCtxt,
|
||||
cx,
|
||||
span,
|
||||
substr.type_ident,
|
||||
&definition.fields,
|
||||
&definition.fields[],
|
||||
fields,
|
||||
deserializer.clone(),
|
||||
token)
|
||||
@ -271,8 +271,8 @@ fn deserialize_substructure(cx: &mut ExtCtxt,
|
||||
cx,
|
||||
span,
|
||||
substr.type_ident,
|
||||
&definition.variants,
|
||||
&fields,
|
||||
&definition.variants[],
|
||||
&fields[],
|
||||
deserializer,
|
||||
token)
|
||||
}
|
||||
@ -300,7 +300,7 @@ fn deserialize_struct(
|
||||
let field_idents: Vec<ast::Ident> = fields.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, _)| {
|
||||
cx.ident_of(&format!("field{}", idx))
|
||||
cx.ident_of(&format!("field{}", idx)[])
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -415,7 +415,7 @@ fn deserialize_enum(
|
||||
cx,
|
||||
span,
|
||||
path,
|
||||
&serial_names,
|
||||
&serial_names[],
|
||||
parts,
|
||||
|&: cx, _, _| {
|
||||
quote_expr!(cx, try!($deserializer.expect_enum_elt()))
|
||||
@ -461,7 +461,7 @@ fn deserialize_static_fields<F>(
|
||||
getarg(
|
||||
cx,
|
||||
span,
|
||||
token::intern_and_get_ident(&format!("_field{}", i))
|
||||
token::intern_and_get_ident(&format!("_field{}", i)[])
|
||||
)
|
||||
}).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>
|
||||
{
|
||||
for at in iterator {
|
||||
|
Loading…
x
Reference in New Issue
Block a user