diff options
Diffstat (limited to 'src/libsyntax/ast.rs')
| -rw-r--r-- | src/libsyntax/ast.rs | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6766127a5f1..630f7768885 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -100,7 +100,6 @@ impl Ident { } } -//NOTE(stage0): remove after snapshot impl fmt::Show for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}#{}", self.name, self.ctxt) @@ -203,7 +202,7 @@ impl Encodable for Ident { impl Decodable for Ident { fn decode<D: Decoder>(d: &mut D) -> Result<Ident, D::Error> { - Ok(str_to_ident(try!(d.read_str()).index(&FullRange))) + Ok(str_to_ident(&try!(d.read_str())[])) } } @@ -1076,16 +1075,29 @@ pub struct Typedef { pub typ: P<Ty>, } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum IntTy { - TyIs, + TyIs(bool /* is this deprecated `int`? */), TyI8, TyI16, TyI32, TyI64, } -//NOTE(stage0): remove after snapshot +impl PartialEq for IntTy { + fn eq(&self, other: &IntTy) -> bool { + match (*self, *other) { + // true/false need to compare the same, so this can't be derived + (TyIs(_), TyIs(_)) | + (TyI8, TyI8) | + (TyI16, TyI16) | + (TyI32, TyI32) | + (TyI64, TyI64) => true, + _ => false + } + } +} + impl fmt::Show for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::String::fmt(self, f) @@ -1101,33 +1113,46 @@ impl fmt::String for IntTy { impl IntTy { pub fn suffix_len(&self) -> uint { match *self { - TyIs => 1, - TyI8 => 2, + TyIs(true) /* i */ => 1, + TyIs(false) /* is */ | TyI8 => 2, TyI16 | TyI32 | TyI64 => 3, } } } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum UintTy { - TyUs, + TyUs(bool /* is this deprecated uint? */), TyU8, TyU16, TyU32, TyU64, } +impl PartialEq for UintTy { + fn eq(&self, other: &UintTy) -> bool { + match (*self, *other) { + // true/false need to compare the same, so this can't be derived + (TyUs(_), TyUs(_)) | + (TyU8, TyU8) | + (TyU16, TyU16) | + (TyU32, TyU32) | + (TyU64, TyU64) => true, + _ => false + } + } +} + impl UintTy { pub fn suffix_len(&self) -> uint { match *self { - TyUs => 1, - TyU8 => 2, + TyUs(true) /* u */ => 1, + TyUs(false) /* us */ | TyU8 => 2, TyU16 | TyU32 | TyU64 => 3, } } } -//NOTE(stage0): remove after snapshot impl fmt::Show for UintTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::String::fmt(self, f) @@ -1146,7 +1171,6 @@ pub enum FloatTy { TyF64, } -//NOTE(stage0): remove after snapshot impl fmt::Show for FloatTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::String::fmt(self, f) @@ -1734,11 +1758,8 @@ pub struct MacroDef { #[cfg(test)] mod test { - use serialize::json; use serialize; - use codemap::*; use super::*; - use std::fmt; // are ASTs encodable? #[test] |
