1
Fork 0

[breaking-change] remove the sign from integer literals in the ast

This commit is contained in:
Oliver Schneider 2016-02-11 09:52:55 +01:00
parent 625e78b700
commit bfa66bb389
10 changed files with 55 additions and 82 deletions

View file

@ -21,7 +21,6 @@ pub use self::Mutability::*;
pub use self::Pat_::*;
pub use self::PathListItem_::*;
pub use self::PrimTy::*;
pub use self::Sign::*;
pub use self::Stmt_::*;
pub use self::StrStyle::*;
pub use self::StructFieldKind::*;
@ -1269,36 +1268,11 @@ pub enum StrStyle {
/// A literal
pub type Lit = Spanned<Lit_>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum Sign {
Minus,
Plus
}
impl Sign {
pub fn new<T: IntSign>(n: T) -> Sign {
n.sign()
}
}
pub trait IntSign {
fn sign(&self) -> Sign;
}
macro_rules! doit {
($($t:ident)*) => ($(impl IntSign for $t {
#[allow(unused_comparisons)]
fn sign(&self) -> Sign {
if *self < 0 {Minus} else {Plus}
}
})*)
}
doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum LitIntType {
SignedIntLit(IntTy, Sign),
SignedIntLit(IntTy),
UnsignedIntLit(UintTy),
UnsuffixedIntLit(Sign)
UnsuffixedIntLit,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]