Store deprecated status of i/u-suffixed literals.

This commit is contained in:
Huon Wilson
2015-01-08 20:13:14 +11:00
committed by Niko Matsakis
parent 2f99a41fe1
commit e95779554e
18 changed files with 112 additions and 79 deletions

View File

@@ -1075,15 +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,
}
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)
@@ -1099,27 +1113,41 @@ 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,
}
}