Skip to content

Commit 5831122

Browse files
committed
rollup merge of #19980: erickt/cleanup-serialize
This brings over some changes from [rustc-serialize](https://github.com/rust-lang/rustc-serialize). It makes sense to keep the two in sync until we finally remove libserialize, just to make sure they don't diverge from each other.
2 parents ca521fb + d729c96 commit 5831122

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

src/libserialize/json.rs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,6 @@ macro_rules! read_primitive {
20122012

20132013
impl ::Decoder<DecoderError> for Decoder {
20142014
fn read_nil(&mut self) -> DecodeResult<()> {
2015-
debug!("read_nil");
20162015
expect!(self.pop(), Null)
20172016
}
20182017

@@ -2030,7 +2029,6 @@ impl ::Decoder<DecoderError> for Decoder {
20302029
fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) }
20312030

20322031
fn read_f64(&mut self) -> DecodeResult<f64> {
2033-
debug!("read_f64");
20342032
match self.pop() {
20352033
Json::I64(f) => Ok(f as f64),
20362034
Json::U64(f) => Ok(f as f64),
@@ -2049,7 +2047,6 @@ impl ::Decoder<DecoderError> for Decoder {
20492047
}
20502048

20512049
fn read_bool(&mut self) -> DecodeResult<bool> {
2052-
debug!("read_bool");
20532050
expect!(self.pop(), Boolean)
20542051
}
20552052

@@ -2067,22 +2064,19 @@ impl ::Decoder<DecoderError> for Decoder {
20672064
}
20682065

20692066
fn read_str(&mut self) -> DecodeResult<string::String> {
2070-
debug!("read_str");
20712067
expect!(self.pop(), String)
20722068
}
20732069

2074-
fn read_enum<T, F>(&mut self, name: &str, f: F) -> DecodeResult<T> where
2070+
fn read_enum<T, F>(&mut self, _name: &str, f: F) -> DecodeResult<T> where
20752071
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
20762072
{
2077-
debug!("read_enum({})", name);
20782073
f(self)
20792074
}
20802075

20812076
fn read_enum_variant<T, F>(&mut self, names: &[&str],
20822077
mut f: F) -> DecodeResult<T>
20832078
where F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
20842079
{
2085-
debug!("read_enum_variant(names={})", names);
20862080
let name = match self.pop() {
20872081
Json::String(s) => s,
20882082
Json::Object(mut o) => {
@@ -2122,49 +2116,44 @@ impl ::Decoder<DecoderError> for Decoder {
21222116
f(self, idx)
21232117
}
21242118

2125-
fn read_enum_variant_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
2119+
fn read_enum_variant_arg<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
21262120
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
21272121
{
2128-
debug!("read_enum_variant_arg(idx={})", idx);
21292122
f(self)
21302123
}
21312124

21322125
fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where
21332126
F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
21342127
{
2135-
debug!("read_enum_struct_variant(names={})", names);
21362128
self.read_enum_variant(names, f)
21372129
}
21382130

21392131

21402132
fn read_enum_struct_variant_field<T, F>(&mut self,
2141-
name: &str,
2133+
_name: &str,
21422134
idx: uint,
21432135
f: F)
21442136
-> DecodeResult<T> where
21452137
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
21462138
{
2147-
debug!("read_enum_struct_variant_field(name={}, idx={})", name, idx);
21482139
self.read_enum_variant_arg(idx, f)
21492140
}
21502141

2151-
fn read_struct<T, F>(&mut self, name: &str, len: uint, f: F) -> DecodeResult<T> where
2142+
fn read_struct<T, F>(&mut self, _name: &str, _len: uint, f: F) -> DecodeResult<T> where
21522143
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
21532144
{
2154-
debug!("read_struct(name={}, len={})", name, len);
21552145
let value = try!(f(self));
21562146
self.pop();
21572147
Ok(value)
21582148
}
21592149

21602150
fn read_struct_field<T, F>(&mut self,
21612151
name: &str,
2162-
idx: uint,
2152+
_idx: uint,
21632153
f: F)
21642154
-> DecodeResult<T> where
21652155
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
21662156
{
2167-
debug!("read_struct_field(name={}, idx={})", name, idx);
21682157
let mut obj = try!(expect!(self.pop(), Object));
21692158

21702159
let value = match obj.remove(&name.to_string()) {
@@ -2189,7 +2178,6 @@ impl ::Decoder<DecoderError> for Decoder {
21892178
fn read_tuple<T, F>(&mut self, tuple_len: uint, f: F) -> DecodeResult<T> where
21902179
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
21912180
{
2192-
debug!("read_tuple()");
21932181
self.read_seq(move |d, len| {
21942182
if len == tuple_len {
21952183
f(d)
@@ -2202,18 +2190,16 @@ impl ::Decoder<DecoderError> for Decoder {
22022190
fn read_tuple_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
22032191
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22042192
{
2205-
debug!("read_tuple_arg(idx={})", idx);
22062193
self.read_seq_elt(idx, f)
22072194
}
22082195

22092196
fn read_tuple_struct<T, F>(&mut self,
2210-
name: &str,
2197+
_name: &str,
22112198
len: uint,
22122199
f: F)
22132200
-> DecodeResult<T> where
22142201
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22152202
{
2216-
debug!("read_tuple_struct(name={})", name);
22172203
self.read_tuple(len, f)
22182204
}
22192205

@@ -2223,14 +2209,12 @@ impl ::Decoder<DecoderError> for Decoder {
22232209
-> DecodeResult<T> where
22242210
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22252211
{
2226-
debug!("read_tuple_struct_arg(idx={})", idx);
22272212
self.read_tuple_arg(idx, f)
22282213
}
22292214

22302215
fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where
22312216
F: FnMut(&mut Decoder, bool) -> DecodeResult<T>,
22322217
{
2233-
debug!("read_option()");
22342218
match self.pop() {
22352219
Json::Null => f(self, false),
22362220
value => { self.stack.push(value); f(self, true) }
@@ -2240,7 +2224,6 @@ impl ::Decoder<DecoderError> for Decoder {
22402224
fn read_seq<T, F>(&mut self, f: F) -> DecodeResult<T> where
22412225
F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
22422226
{
2243-
debug!("read_seq()");
22442227
let array = try!(expect!(self.pop(), Array));
22452228
let len = array.len();
22462229
for v in array.into_iter().rev() {
@@ -2249,17 +2232,15 @@ impl ::Decoder<DecoderError> for Decoder {
22492232
f(self, len)
22502233
}
22512234

2252-
fn read_seq_elt<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
2235+
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
22532236
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22542237
{
2255-
debug!("read_seq_elt(idx={})", idx);
22562238
f(self)
22572239
}
22582240

22592241
fn read_map<T, F>(&mut self, f: F) -> DecodeResult<T> where
22602242
F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
22612243
{
2262-
debug!("read_map()");
22632244
let obj = try!(expect!(self.pop(), Object));
22642245
let len = obj.len();
22652246
for (key, value) in obj.into_iter() {
@@ -2269,17 +2250,15 @@ impl ::Decoder<DecoderError> for Decoder {
22692250
f(self, len)
22702251
}
22712252

2272-
fn read_map_elt_key<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
2253+
fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
22732254
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22742255
{
2275-
debug!("read_map_elt_key(idx={})", idx);
22762256
f(self)
22772257
}
22782258

2279-
fn read_map_elt_val<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
2259+
fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
22802260
F: FnOnce(&mut Decoder) -> DecodeResult<T>,
22812261
{
2282-
debug!("read_map_elt_val(idx={})", idx);
22832262
f(self)
22842263
}
22852264

@@ -2441,9 +2420,7 @@ mod tests {
24412420
use super::ParserError::*;
24422421
use super::DecoderError::*;
24432422
use super::JsonEvent::*;
2444-
use super::ParserState::*;
24452423
use super::StackElement::*;
2446-
use super::InternalStackElement::*;
24472424
use super::{PrettyEncoder, Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser,
24482425
StackElement, Stack, Encoder, Decoder};
24492426
use std::{i64, u64, f32, f64, io};
@@ -2678,8 +2655,6 @@ mod tests {
26782655
}
26792656

26802657
fn with_str_writer<F>(f: F) -> string::String where F: FnOnce(&mut io::Writer){
2681-
use std::str;
2682-
26832658
let mut m = Vec::new();
26842659
f(&mut m as &mut io::Writer);
26852660
string::String::from_utf8(m).unwrap()

0 commit comments

Comments
 (0)