From 85d0c8e4e8b5944f98ffae9bcb403ce8cae921bb Mon Sep 17 00:00:00 2001 From: Thomas Bahn Date: Tue, 30 Dec 2014 14:38:39 +0100 Subject: [PATCH 1/4] Rename FP* to FpCategory::* following std changes --- serde2/src/json/ser.rs | 4 ++-- src/json/ser.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/serde2/src/json/ser.rs b/serde2/src/json/ser.rs index 57fa3c3e..dae76117 100644 --- a/serde2/src/json/ser.rs +++ b/serde2/src/json/ser.rs @@ -1,6 +1,6 @@ use std::f64; use std::io::{mod, ByRefWriter, IoError}; -use std::num::{Float, FPNaN, FPInfinite}; +use std::num::{Float, FpCategory}; use std::str::Utf8Error; use ser; @@ -225,7 +225,7 @@ pub fn escape_char(wr: &mut W, value: char) -> Result<(), IoError fn fmt_f64_or_null(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()), } } diff --git a/src/json/ser.rs b/src/json/ser.rs index ac07b677..c5d56693 100644 --- a/src/json/ser.rs +++ b/src/json/ser.rs @@ -1,6 +1,6 @@ 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; @@ -52,14 +52,14 @@ fn escape_char(wr: &mut W, v: char) -> IoResult<()> { fn fmt_f32_or_null(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(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()), } } From ae665a1c05d4e3e4313b34c50419cfa1ffce9ab0 Mon Sep 17 00:00:00 2001 From: Thomas Bahn Date: Thu, 1 Jan 2015 14:10:50 +0100 Subject: [PATCH 2/4] Syntax extension internals in rust changed See https://github.com/rust-lang/rust/commit/e656081b700b949bc914fedd6ad29b1ca3197660 --- serde2/serde2_macros/src/lib.rs | 7 +++---- serde_macros/src/lib.rs | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/serde2/serde2_macros/src/lib.rs b/serde2/serde2_macros/src/lib.rs index 04bf2564..280d6459 100644 --- a/serde2/serde2_macros/src/lib.rs +++ b/serde2/serde2_macros/src/lib.rs @@ -80,12 +80,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"], diff --git a/serde_macros/src/lib.rs b/serde_macros/src/lib.rs index 863dc7a4..a1450d7b 100644 --- a/serde_macros/src/lib.rs +++ b/serde_macros/src/lib.rs @@ -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 { @@ -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 { From 814c0570b89a952d68fa6a44ae44f348b70dd699 Mon Sep 17 00:00:00 2001 From: Thomas Bahn Date: Thu, 1 Jan 2015 14:19:21 +0100 Subject: [PATCH 3/4] Fix: String::from_utf8 became stable and changed signature --- serde2/src/json/ser.rs | 4 ++-- src/json/ser.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/serde2/src/json/ser.rs b/serde2/src/json/ser.rs index dae76117..52895fe3 100644 --- a/serde2/src/json/ser.rs +++ b/serde2/src/json/ser.rs @@ -1,7 +1,7 @@ use std::f64; use std::io::{mod, ByRefWriter, IoError}; use std::num::{Float, FpCategory}; -use std::str::Utf8Error; +use std::string::FromUtf8Error; use ser; use ser::Serializer; @@ -252,7 +252,7 @@ pub fn to_vec< #[inline] pub fn to_string< T: ser::Serialize, ->(value: &T) -> Result, Utf8Error)>, IoError> { +>(value: &T) -> Result, IoError> { let vec = try!(to_vec(value)); Ok(String::from_utf8(vec)) } diff --git a/src/json/ser.rs b/src/json/ser.rs index c5d56693..2478c813 100644 --- a/src/json/ser.rs +++ b/src/json/ser.rs @@ -2,7 +2,7 @@ use std::f32; use std::f64; use std::num::{Float, FpCategory}; use std::io::{IoError, IoResult}; -use std::str::Utf8Error; +use std::string::FromUtf8Error; use ser::Serialize; use ser; @@ -600,7 +600,7 @@ pub fn to_vec< #[inline] pub fn to_string< T: Serialize>, IoError> ->(value: &T) -> Result, Utf8Error)> { +>(value: &T) -> Result { 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>, IoError> ->(value: &T) -> Result, Utf8Error)> { +>(value: &T) -> Result { let buf = to_pretty_vec(value); String::from_utf8(buf) } From d09b9eb72c9633f145ebf5e37b02a2733fdf189f Mon Sep 17 00:00:00 2001 From: Thomas Bahn Date: Fri, 2 Jan 2015 13:32:54 +0100 Subject: [PATCH 4/4] Unboxed closures: function signature of expand* changed --- serde2/serde2_macros/src/lib.rs | 7 +++---- serde_macros/src/lib.rs | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/serde2/serde2_macros/src/lib.rs b/serde2/serde2_macros/src/lib.rs index 280d6459..12f00078 100644 --- a/serde2/serde2_macros/src/lib.rs +++ b/serde2/serde2_macros/src/lib.rs @@ -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|) //where - //F: FnOnce(P) + mut push: Box)>) { let inline = cx.meta_word(sp, token::InternedString::new("inline")); let attrs = vec!(cx.attribute(sp, inline)); @@ -129,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 { diff --git a/serde_macros/src/lib.rs b/serde_macros/src/lib.rs index a1450d7b..4aef1ab5 100644 --- a/serde_macros/src/lib.rs +++ b/serde_macros/src/lib.rs @@ -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|) { + mut push: Box)>) { let inline = cx.meta_word(sp, token::InternedString::new("inline")); let attrs = vec!(cx.attribute(sp, inline)); @@ -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|) { + mut push: Box)>) { let trait_def = TraitDef { span: span, attributes: Vec::new(), @@ -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,