Update for rustc 1.0.0-nightly (8903c21d6 2015-01-15 22:42:58 +0000)

This commit is contained in:
Dan Burkert
2015-01-17 16:32:29 -08:00
parent 8715a41158
commit 460dbce8cc
19 changed files with 160 additions and 147 deletions
+37 -36
View File
@@ -9,6 +9,7 @@
// except according to those terms.
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet};
use std::collections::hash_map::Hasher;
use std::hash::Hash;
use std::iter::FromIterator;
use std::num::{self, FromPrimitive};
@@ -706,7 +707,7 @@ impl<
> Deserialize<D, E> for Box<T> {
#[inline]
fn deserialize_token(d: &mut D, token: Token) -> Result<Box<T>, E> {
Ok(box try!(Deserialize::deserialize_token(d, token)))
Ok(Box::new(try!(Deserialize::deserialize_token(d, token))))
}
}
@@ -763,7 +764,7 @@ impl<
impl<
D: Deserializer<E>,
E,
K: Deserialize<D, E> + Eq + Hash,
K: Deserialize<D, E> + Eq + Hash<Hasher>,
V: Deserialize<D, E>
> Deserialize<D, E> for HashMap<K, V> {
#[inline]
@@ -789,7 +790,7 @@ impl<
impl<
D: Deserializer<E>,
E,
T: Deserialize<D, E> + Eq + Hash
T: Deserialize<D, E> + Eq + Hash<Hasher>
> Deserialize<D, E> for HashSet<T> {
#[inline]
fn deserialize_token(d: &mut D, token: Token) -> Result<HashSet<T>, E> {
@@ -1253,7 +1254,7 @@ mod tests {
//////////////////////////////////////////////////////////////////////////////
macro_rules! test_value {
($name:ident, [$($tokens:expr => $value:expr: $ty:ty),*]) => {
($name:ident, [$($tokens:expr => $value:expr, $ty:ty),*]) => {
#[test]
fn $name() {
$(
@@ -1267,31 +1268,31 @@ mod tests {
}
test_value!(test_primitives, [
vec!(Token::Null) => (): (),
vec!(Token::Bool(true)) => true: bool,
vec!(Token::Bool(false)) => false: bool,
vec!(Token::Int(5)) => 5: int,
vec!(Token::I8(5)) => 5: i8,
vec!(Token::I16(5)) => 5: i16,
vec!(Token::I32(5)) => 5: i32,
vec!(Token::I64(5)) => 5: i64,
vec!(Token::Uint(5)) => 5: uint,
vec!(Token::U8(5)) => 5: u8,
vec!(Token::U16(5)) => 5: u16,
vec!(Token::U32(5)) => 5: u32,
vec!(Token::U64(5)) => 5: u64,
vec!(Token::F32(5.0)) => 5.0: f32,
vec!(Token::F64(5.0)) => 5.0: f64,
vec!(Token::Char('c')) => 'c': char,
vec!(Token::Str("abc")) => "abc": &str,
vec!(Token::String("abc".to_string())) => "abc".to_string(): string::String
vec!(Token::Null) => (), (),
vec!(Token::Bool(true)) => true, bool,
vec!(Token::Bool(false)) => false, bool,
vec!(Token::Int(5)) => 5, int,
vec!(Token::I8(5)) => 5, i8,
vec!(Token::I16(5)) => 5, i16,
vec!(Token::I32(5)) => 5, i32,
vec!(Token::I64(5)) => 5, i64,
vec!(Token::Uint(5)) => 5, uint,
vec!(Token::U8(5)) => 5, u8,
vec!(Token::U16(5)) => 5, u16,
vec!(Token::U32(5)) => 5, u32,
vec!(Token::U64(5)) => 5, u64,
vec!(Token::F32(5.0)) => 5.0, f32,
vec!(Token::F64(5.0)) => 5.0, f64,
vec!(Token::Char('c')) => 'c', char,
vec!(Token::Str("abc")) => "abc", &str,
vec!(Token::String("abc".to_string())) => "abc".to_string(), string::String
]);
test_value!(test_tuples, [
vec!(
Token::TupleStart(0),
Token::End,
) => (): (),
) => (), (),
vec!(
Token::TupleStart(2),
@@ -1299,7 +1300,7 @@ mod tests {
Token::Str("a"),
Token::End,
) => (5, "a"): (int, &'static str),
) => (5, "a"), (int, &'static str),
vec!(
Token::TupleStart(3),
@@ -1314,16 +1315,16 @@ mod tests {
Token::Str("a"),
Token::End,
Token::End,
) => ((), (), (5, "a")): ((), (), (int, &'static str))
) => ((), (), (5, "a")), ((), (), (int, &'static str))
]);
test_value!(test_options, [
vec!(Token::Option(false)) => None: option::Option<int>,
vec!(Token::Option(false)) => None, option::Option<int>,
vec!(
Token::Option(true),
Token::Int(5),
) => Some(5): option::Option<int>
) => Some(5), option::Option<int>
]);
test_value!(test_structs, [
@@ -1333,7 +1334,7 @@ mod tests {
Token::SeqStart(0),
Token::End,
Token::End,
) => Outer { inner: vec!() }: Outer,
) => Outer { inner: vec!() }, Outer,
vec!(
Token::StructStart("Outer", 1),
@@ -1364,28 +1365,28 @@ mod tests {
c: treemap!("abc".to_string() => Some('c')),
},
),
}: Outer
}, Outer
]);
test_value!(test_enums, [
vec!(
Token::EnumStart("Animal", "Dog", 0),
Token::End,
) => Animal::Dog: Animal,
) => Animal::Dog, Animal,
vec!(
Token::EnumStart("Animal", "Frog", 2),
Token::String("Henry".to_string()),
Token::Int(349),
Token::End,
) => Animal::Frog("Henry".to_string(), 349): Animal
) => Animal::Frog("Henry".to_string(), 349), Animal
]);
test_value!(test_vecs, [
vec!(
Token::SeqStart(0),
Token::End,
) => vec!(): Vec<int>,
) => vec!(), Vec<int>,
vec!(
Token::SeqStart(3),
@@ -1395,7 +1396,7 @@ mod tests {
Token::Int(7),
Token::End,
) => vec!(5, 6, 7): Vec<int>,
) => vec!(5, 6, 7), Vec<int>,
vec!(
@@ -1418,14 +1419,14 @@ mod tests {
Token::Int(6),
Token::End,
Token::End,
) => vec!(vec!(1), vec!(2, 3), vec!(4, 5, 6)): Vec<Vec<int>>
) => vec!(vec!(1), vec!(2, 3), vec!(4, 5, 6)), Vec<Vec<int>>
]);
test_value!(test_treemaps, [
vec!(
Token::MapStart(0),
Token::End,
) => treemap!(): BTreeMap<int, string::String>,
) => treemap!(), BTreeMap<int, string::String>,
vec!(
Token::MapStart(2),
@@ -1435,7 +1436,7 @@ mod tests {
Token::Int(6),
Token::String("b".to_string()),
Token::End,
) => treemap!(5i => "a".to_string(), 6i => "b".to_string()): BTreeMap<int, string::
) => treemap!(5i => "a".to_string(), 6i => "b".to_string()), BTreeMap<int, string::
String>
]);
}
+7 -7
View File
@@ -43,7 +43,7 @@ pub enum ErrorCode {
impl fmt::Show for ErrorCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ErrorCode::ConversionError(ref token) => write!(f, "failed to convert {}", token),
ErrorCode::ConversionError(ref token) => write!(f, "failed to convert {:?}", token),
ErrorCode::EOFWhileParsingList => "EOF While parsing list".fmt(f),
ErrorCode::EOFWhileParsingObject => "EOF While parsing object".fmt(f),
ErrorCode::EOFWhileParsingString => "EOF While parsing string".fmt(f),
@@ -60,7 +60,7 @@ impl fmt::Show for ErrorCode {
ErrorCode::ExpectedObjectCommaOrEnd => "expected `,` or `}`".fmt(f),
ErrorCode::ExpectedSomeIdent => "expected ident".fmt(f),
ErrorCode::ExpectedSomeValue => "expected value".fmt(f),
ErrorCode::ExpectedTokens(ref token, tokens) => write!(f, "expected {}, found {}", tokens, token),
ErrorCode::ExpectedTokens(ref token, tokens) => write!(f, "expected {:?}, found {:?}", tokens, token),
ErrorCode::InvalidEscape => "invalid escape".fmt(f),
ErrorCode::InvalidNumber => "invalid number".fmt(f),
ErrorCode::InvalidUnicodeCodePoint => "invalid unicode code point".fmt(f),
@@ -71,7 +71,7 @@ impl fmt::Show for ErrorCode {
ErrorCode::NotUtf8 => "contents not utf-8".fmt(f),
ErrorCode::TrailingCharacters => "trailing characters".fmt(f),
ErrorCode::UnexpectedEndOfHexEscape => "unexpected end of hex escape".fmt(f),
ErrorCode::UnexpectedName(ref name) => write!(f, "unexpected name {}", name),
ErrorCode::UnexpectedName(ref name) => write!(f, "unexpected name {:?}", name),
ErrorCode::UnknownVariant => "unknown variant".fmt(f),
ErrorCode::UnrecognizedHex => "invalid \\u escape (unrecognized hex)".fmt(f),
}
@@ -102,17 +102,17 @@ impl error::Error for Error {
fn detail(&self) -> Option<String> {
match *self {
Error::SyntaxError(ref code, line, col) => {
Some(format!("{} at line {} column {}", code, line, col))
Some(format!("{:?} at line {:?} column {:?}", code, line, col))
}
Error::IoError(ref error) => error.detail(),
Error::ExpectedError(ref expected, ref found) => {
Some(format!("expected {}, found {}", expected, found))
Some(format!("expected {:?}, found {:?}", expected, found))
}
Error::MissingFieldError(ref field) => {
Some(format!("missing field {}", field))
Some(format!("missing field {:?}", field))
}
Error::UnknownVariantError(ref variant) => {
Some(format!("unknown variant {}", variant))
Some(format!("unknown variant {:?}", variant))
}
}
}
+4 -4
View File
@@ -84,7 +84,7 @@ fn main() {
let mut serializer = json::Serializer::new(wr.by_ref());
match to_serialize_object.serialize(&mut serializer) {
Ok(()) => (),
Err(e) => panic!("json serialization error: {}", e),
Err(e) => panic!("json serialization error: {:?}", e),
}
}
}
@@ -192,7 +192,7 @@ fn main() {
let mut parser = json::Parser::new(json_str_to_deserialize.bytes());
let deserialized_object: MyStruct = match Deserialize::deserialize(&mut parser) {
Ok(v) => v,
Err(e) => panic!("Decoding error: {}", e)
Err(e) => panic!("Decoding error: {:?}", e)
};
}
```
@@ -234,7 +234,7 @@ fn main() {
let deserialized_object: TestStruct1 = match json::from_str(serialized_str.as_slice()) {
Ok(deserialized_object) => deserialized_object,
Err(e) => panic!("json deserialization error: {}", e),
Err(e) => panic!("json deserialization error: {:?}", e),
};
}
```
@@ -1918,7 +1918,7 @@ mod bench {
match parser.next() {
None => return,
Some(Ok(_)) => { }
Some(Err(err)) => { panic!("error: {}", err); }
Some(Err(err)) => { panic!("error: {:?}", err); }
}
}
});
+12 -3
View File
@@ -3,6 +3,7 @@ use std::fmt;
use std::io::{ByRefWriter, IoResult};
use std::io;
use std::str;
use std::string::ToString;
use std::vec;
use de::{self, Token, TokenKind};
@@ -207,6 +208,14 @@ impl Value {
}
}
impl ToString for Value {
fn to_string(&self) -> String {
let mut wr = Vec::new();
self.to_writer(wr.by_ref()).unwrap();
str::from_utf8(wr.as_slice()).unwrap().to_string()
}
}
struct WriterFormatter<'a, 'b: 'a> {
inner: &'a mut fmt::Formatter<'b>,
}
@@ -449,7 +458,7 @@ impl de::Deserializer<Error> for Deserializer {
return Err(
Error::ExpectedError(
"Array".to_string(),
format!("{} => {}", key, value)
format!("{:?} => {:?}", key, value)
)
);
}
@@ -464,7 +473,7 @@ impl de::Deserializer<Error> for Deserializer {
return Err(
Error::ExpectedError(
"None".to_string(),
format!("{} => {}", key, value)
format!("{:?} => {:?}", key, value)
)
);
}
@@ -483,7 +492,7 @@ impl de::Deserializer<Error> for Deserializer {
return Err(
Error::ExpectedError(
"String or Object".to_string(),
format!("{}", token)
format!("{:?}", token)
)
);
}
+1
View File
@@ -1,4 +1,5 @@
#![feature(plugin)]
#![allow(unstable)]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
+3 -2
View File
@@ -9,6 +9,7 @@
// except according to those terms.
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet};
use std::collections::hash_map::Hasher;
use std::hash::Hash;
use std::rc::Rc;
use std::sync::Arc;
@@ -225,7 +226,7 @@ impl<
impl<
S: Serializer<E>,
E,
K: Serialize<S, E> + Eq + Hash,
K: Serialize<S, E> + Eq + Hash<Hasher>,
V: Serialize<S, E>
> Serialize<S, E> for HashMap<K, V> {
#[inline]
@@ -251,7 +252,7 @@ impl<
impl<
S: Serializer<E>,
E,
T: Serialize<S, E> + Eq + Hash
T: Serialize<S, E> + Eq + Hash<Hasher>
> Serialize<S, E> for HashSet<T> {
#[inline]
fn serialize(&self, s: &mut S) -> Result<(), E> {