Merge pull request #16 from tomprogrammer/rust-head

Follow changes in std / rustc
This commit is contained in:
Erick Tryzelaar 2015-01-02 21:31:11 -05:00
commit f1929ca86d
4 changed files with 25 additions and 27 deletions

View File

@ -1,4 +1,4 @@
#![feature(plugin_registrar, quote)]
#![feature(plugin_registrar, quote, unboxed_closures)]
extern crate syntax;
extern crate rustc;
@ -62,8 +62,7 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
sp: Span,
mitem: &MetaItem,
item: &Item,
push: |P<ast::Item>|) //where
//F: FnOnce(P<ast::Item>)
mut push: Box<FnMut(P<ast::Item>)>)
{
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
let attrs = vec!(cx.attribute(sp, inline));
@ -80,12 +79,11 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
generics: LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec![
("__S", None, vec![]),
("__R", None, vec![]),
("__E", None, vec![]),
("__S", vec![]),
("__R", vec![]),
("__E", vec![]),
(
"__V",
None,
vec![
Path::new_(
vec!["serde2", "ser", "Visitor"],
@ -130,7 +128,7 @@ fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
]
};
trait_def.expand(cx, mitem, item, |item| push(item))
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
}
fn serialize_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {

View File

@ -1,7 +1,7 @@
use std::f64;
use std::io::{mod, ByRefWriter, IoError};
use std::num::{Float, FPNaN, FPInfinite};
use std::str::Utf8Error;
use std::num::{Float, FpCategory};
use std::string::FromUtf8Error;
use ser;
use ser::Serializer;
@ -225,7 +225,7 @@ pub fn escape_char<W: io::Writer>(wr: &mut W, value: char) -> Result<(), IoError
fn fmt_f64_or_null<W: io::Writer>(wr: &mut W, value: f64) -> Result<(), IoError> {
match value.classify() {
FPNaN | FPInfinite => wr.write_str("null"),
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
_ => wr.write_str(f64::to_str_digits(value, 6).as_slice()),
}
}
@ -252,7 +252,7 @@ pub fn to_vec<
#[inline]
pub fn to_string<
T: ser::Serialize,
>(value: &T) -> Result<Result<String, (Vec<u8>, Utf8Error)>, IoError> {
>(value: &T) -> Result<Result<String, FromUtf8Error>, IoError> {
let vec = try!(to_vec(value));
Ok(String::from_utf8(vec))
}

View File

@ -1,7 +1,7 @@
#![crate_name = "serde_macros"]
#![crate_type = "dylib"]
#![feature(plugin_registrar, quote)]
#![feature(plugin_registrar, quote, unboxed_closures)]
extern crate syntax;
extern crate rustc;
@ -70,7 +70,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
sp: Span,
mitem: &MetaItem,
item: &Item,
push: |P<ast::Item>|) {
mut push: Box<FnMut(P<ast::Item>)>) {
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
let attrs = vec!(cx.attribute(sp, inline));
@ -83,10 +83,10 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
additional_bounds: Vec::new(),
generics: LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("__S", None, vec!(Path::new_(
bounds: vec!(("__S", vec!(Path::new_(
vec!("serde", "ser", "Serializer"), None,
vec!(box Literal(Path::new_local("__E"))), true))),
("__E", None, vec!()))
("__E", vec!()))
},
methods: vec!(
MethodDef {
@ -113,7 +113,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
})
};
trait_def.expand(cx, mitem, item, |item| push(item))
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
}
fn serialize_substructure(cx: &ExtCtxt,
@ -199,7 +199,7 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: |P<Item>|) {
mut push: Box<FnMut(P<Item>)>) {
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
@ -209,10 +209,10 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
additional_bounds: Vec::new(),
generics: LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("__D", None, vec!(Path::new_(
bounds: vec!(("__D", vec!(Path::new_(
vec!("serde", "de", "Deserializer"), None,
vec!(box Literal(Path::new_local("__E"))), true))),
("__E", None, vec!()))
("__E", vec!()))
},
methods: vec!(
MethodDef {
@ -244,7 +244,7 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
})
};
trait_def.expand(cx, mitem, item, |item| push(item))
trait_def.expand(cx, mitem, item, |item| push.call_mut((item,)))
}
fn deserialize_substructure(cx: &mut ExtCtxt,

View File

@ -1,8 +1,8 @@
use std::f32;
use std::f64;
use std::num::{Float, FPNaN, FPInfinite};
use std::num::{Float, FpCategory};
use std::io::{IoError, IoResult};
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use ser::Serialize;
use ser;
@ -52,14 +52,14 @@ fn escape_char<W: Writer>(wr: &mut W, v: char) -> IoResult<()> {
fn fmt_f32_or_null<W: Writer>(wr: &mut W, v: f32) -> IoResult<()> {
match v.classify() {
FPNaN | FPInfinite => wr.write_str("null"),
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
_ => wr.write_str(f32::to_str_digits(v, 6).as_slice()),
}
}
fn fmt_f64_or_null<W: Writer>(wr: &mut W, v: f64) -> IoResult<()> {
match v.classify() {
FPNaN | FPInfinite => wr.write_str("null"),
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
_ => wr.write_str(f64::to_str_digits(v, 6).as_slice()),
}
}
@ -600,7 +600,7 @@ pub fn to_vec<
#[inline]
pub fn to_string<
T: Serialize<Serializer<Vec<u8>>, IoError>
>(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
>(value: &T) -> Result<String, FromUtf8Error> {
let buf = to_vec(value);
String::from_utf8(buf)
}
@ -629,7 +629,7 @@ pub fn to_pretty_vec<
/// Encode the specified struct into a json `String` buffer.
pub fn to_pretty_string<
T: Serialize<PrettySerializer<Vec<u8>>, IoError>
>(value: &T) -> Result<String, (Vec<u8>, Utf8Error)> {
>(value: &T) -> Result<String, FromUtf8Error> {
let buf = to_pretty_vec(value);
String::from_utf8(buf)
}