]> git.lizzy.rs Git - rust.git/commitdiff
Store deprecated status of i/u-suffixed literals.
authorHuon Wilson <dbau.pp+github@gmail.com>
Thu, 8 Jan 2015 09:13:14 +0000 (20:13 +1100)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 8 Jan 2015 16:02:23 +0000 (11:02 -0500)
18 files changed:
src/librustc/lint/builtin.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/ty.rs
src/librustc_resolve/lib.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/type_.rs
src/librustc_trans/trans/type_of.rs
src/librustc_typeck/check/mod.rs
src/librustdoc/clean/mod.rs
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/attr.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/quote.rs
src/libsyntax/parse/mod.rs

index 7d893f3a106cc7180af782f813563b8132ec228a..9795947ac811d6e8096de353a0b51e2dd0bb6902 100644 (file)
@@ -216,7 +216,7 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
                         match lit.node {
                             ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
                             ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
-                                let int_type = if t == ast::TyIs {
+                                let int_type = if let ast::TyIs(_) = t {
                                     cx.sess().target.int_type
                                 } else { t };
                                 let (min, max) = int_ty_range(int_type);
@@ -233,7 +233,7 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
                         };
                     },
                     ty::ty_uint(t) => {
-                        let uint_type = if t == ast::TyUs {
+                        let uint_type = if let ast::TyUs(_) = t {
                             cx.sess().target.uint_type
                         } else { t };
                         let (min, max) = uint_ty_range(uint_type);
@@ -296,7 +296,7 @@ fn rev_binop(binop: ast::BinOp) -> ast::BinOp {
         // warnings are consistent between 32- and 64-bit platforms
         fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
             match int_ty {
-                ast::TyIs=>    (i64::MIN,        i64::MAX),
+                ast::TyIs(_) =>    (i64::MIN,        i64::MAX),
                 ast::TyI8 =>   (i8::MIN  as i64, i8::MAX  as i64),
                 ast::TyI16 =>  (i16::MIN as i64, i16::MAX as i64),
                 ast::TyI32 =>  (i32::MIN as i64, i32::MAX as i64),
@@ -306,7 +306,7 @@ fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
 
         fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
             match uint_ty {
-                ast::TyUs=>   (u64::MIN,         u64::MAX),
+                ast::TyUs(_) =>   (u64::MIN,         u64::MAX),
                 ast::TyU8 =>  (u8::MIN   as u64, u8::MAX   as u64),
                 ast::TyU16 => (u16::MIN  as u64, u16::MAX  as u64),
                 ast::TyU32 => (u32::MIN  as u64, u32::MAX  as u64),
@@ -323,7 +323,7 @@ fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
 
         fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
             match int_ty {
-                ast::TyIs=>    int_ty_bits(target_int_ty, target_int_ty),
+                ast::TyIs(_) =>    int_ty_bits(target_int_ty, target_int_ty),
                 ast::TyI8 =>   i8::BITS  as u64,
                 ast::TyI16 =>  i16::BITS as u64,
                 ast::TyI32 =>  i32::BITS as u64,
@@ -333,7 +333,7 @@ fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
 
         fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
             match uint_ty {
-                ast::TyUs=>    uint_ty_bits(target_uint_ty, target_uint_ty),
+                ast::TyUs(_) =>    uint_ty_bits(target_uint_ty, target_uint_ty),
                 ast::TyU8 =>   u8::BITS  as u64,
                 ast::TyU16 =>  u16::BITS as u64,
                 ast::TyU32 =>  u32::BITS as u64,
@@ -404,12 +404,12 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
 impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
     fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
         match self.cx.tcx.def_map.borrow()[path_id].clone() {
-            def::DefPrimTy(ast::TyInt(ast::TyIs)) => {
+            def::DefPrimTy(ast::TyInt(ast::TyIs(_))) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
                                   "found rust type `isize` in foreign module, while \
                                    libc::c_int or libc::c_long should be used");
             }
-            def::DefPrimTy(ast::TyUint(ast::TyUs)) => {
+            def::DefPrimTy(ast::TyUint(ast::TyUs(_))) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
                                   "found rust type `usize` in foreign module, while \
                                    libc::c_uint or libc::c_ulong should be used");
index c019d129218b659ea878992351cb223157ca4742..bdd08ad6c4952038af1029b1982de787ee9c047b 100644 (file)
@@ -61,7 +61,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
         ty::ty_char => mywrite!(w, "c"),
         ty::ty_int(t) => {
             match t {
-                ast::TyIs => mywrite!(w, "is"),
+                ast::TyIs(_) => mywrite!(w, "is"),
                 ast::TyI8 => mywrite!(w, "MB"),
                 ast::TyI16 => mywrite!(w, "MW"),
                 ast::TyI32 => mywrite!(w, "ML"),
@@ -70,7 +70,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
         }
         ty::ty_uint(t) => {
             match t {
-                ast::TyUs => mywrite!(w, "us"),
+                ast::TyUs(_) => mywrite!(w, "us"),
                 ast::TyU8 => mywrite!(w, "Mb"),
                 ast::TyU16 => mywrite!(w, "Mw"),
                 ast::TyU32 => mywrite!(w, "Ml"),
index 04d4b41b21aa4a273407b8390854ed8009cf71c0..52352e920ce36a3922683413684780e822e951d9 100644 (file)
@@ -528,12 +528,12 @@ macro_rules! define_casts {
 
         eval_const_expr_partial(tcx, &**base)
             .and_then(|val| define_casts!(val, {
-                ty::ty_int(ast::TyIs) => (int, const_int, i64),
+                ty::ty_int(ast::TyIs(_)) => (int, const_int, i64),
                 ty::ty_int(ast::TyI8) => (i8, const_int, i64),
                 ty::ty_int(ast::TyI16) => (i16, const_int, i64),
                 ty::ty_int(ast::TyI32) => (i32, const_int, i64),
                 ty::ty_int(ast::TyI64) => (i64, const_int, i64),
-                ty::ty_uint(ast::TyUs) => (uint, const_uint, u64),
+                ty::ty_uint(ast::TyUs(_)) => (uint, const_uint, u64),
                 ty::ty_uint(ast::TyU8) => (u8, const_uint, u64),
                 ty::ty_uint(ast::TyU16) => (u16, const_uint, u64),
                 ty::ty_uint(ast::TyU32) => (u32, const_uint, u64),
index 64f0bcb1c88db280d4bc73b44f0fcc260bba4fa2..2534232960fad5b22e3a45bf9d4e239b8eb673e2 100644 (file)
@@ -2341,12 +2341,12 @@ fn new(arena: &'tcx TypedArena<TyS<'tcx>>,
             bool: intern_ty(arena, interner, ty_bool),
             char: intern_ty(arena, interner, ty_char),
             err: intern_ty(arena, interner, ty_err),
-            int: intern_ty(arena, interner, ty_int(ast::TyIs)),
+            int: intern_ty(arena, interner, ty_int(ast::TyIs(_))),
             i8: intern_ty(arena, interner, ty_int(ast::TyI8)),
             i16: intern_ty(arena, interner, ty_int(ast::TyI16)),
             i32: intern_ty(arena, interner, ty_int(ast::TyI32)),
             i64: intern_ty(arena, interner, ty_int(ast::TyI64)),
-            uint: intern_ty(arena, interner, ty_uint(ast::TyUs)),
+            uint: intern_ty(arena, interner, ty_uint(ast::TyUs(_))),
             u8: intern_ty(arena, interner, ty_uint(ast::TyU8)),
             u16: intern_ty(arena, interner, ty_uint(ast::TyU16)),
             u32: intern_ty(arena, interner, ty_uint(ast::TyU32)),
@@ -2692,7 +2692,7 @@ fn add_bounds(&mut self, bounds: &ExistentialBounds) {
 
 pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
     match tm {
-        ast::TyIs   => tcx.types.int,
+        ast::TyIs(_)   => tcx.types.int,
         ast::TyI8   => tcx.types.i8,
         ast::TyI16  => tcx.types.i16,
         ast::TyI32  => tcx.types.i32,
@@ -2702,7 +2702,7 @@ pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
 
 pub fn mk_mach_uint<'tcx>(tcx: &ctxt<'tcx>, tm: ast::UintTy) -> Ty<'tcx> {
     match tm {
-        ast::TyUs   => tcx.types.uint,
+        ast::TyUs(_)   => tcx.types.uint,
         ast::TyU8   => tcx.types.u8,
         ast::TyU16  => tcx.types.u16,
         ast::TyU32  => tcx.types.u32,
@@ -3363,7 +3363,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
 
         let result = match ty.sty {
             // uint and int are ffi-unsafe
-            ty_uint(ast::TyUs) | ty_int(ast::TyIs) => {
+            ty_uint(ast::TyUs(_)) | ty_int(ast::TyIs(_)) => {
                 TC::ReachesFfiUnsafe
             }
 
@@ -3937,7 +3937,7 @@ pub fn type_is_fresh(ty: Ty) -> bool {
 
 pub fn type_is_uint(ty: Ty) -> bool {
     match ty.sty {
-      ty_infer(IntVar(_)) | ty_uint(ast::TyUs) => true,
+      ty_infer(IntVar(_)) | ty_uint(ast::TyUs(_)) => true,
       _ => false
     }
 }
@@ -3983,7 +3983,7 @@ pub fn type_is_signed(ty: Ty) -> bool {
 
 pub fn type_is_machine(ty: Ty) -> bool {
     match ty.sty {
-        ty_int(ast::TyIs) | ty_uint(ast::TyUs) => false,
+        ty_int(ast::TyIs(_)) | ty_uint(ast::TyUs(_)) => false,
         ty_int(..) | ty_uint(..) | ty_float(..) => true,
         _ => false
     }
index a1ae96490cad7c679a4f799d014b206797d63c8d..88f0abf3ca761e586302146eeaf9616bc7f87aed 100644 (file)
@@ -819,15 +819,15 @@ fn new() -> PrimitiveTypeTable {
         table.intern("char",    TyChar);
         table.intern("f32",     TyFloat(TyF32));
         table.intern("f64",     TyFloat(TyF64));
-        table.intern("int",     TyInt(TyIs));
-        table.intern("isize",   TyInt(TyIs));
+        table.intern("int",     TyInt(TyIs(true)));
+        table.intern("isize",   TyInt(TyIs(false)));
         table.intern("i8",      TyInt(TyI8));
         table.intern("i16",     TyInt(TyI16));
         table.intern("i32",     TyInt(TyI32));
         table.intern("i64",     TyInt(TyI64));
         table.intern("str",     TyStr);
-        table.intern("uint",    TyUint(TyUs));
-        table.intern("usize",   TyUint(TyUs));
+        table.intern("uint",    TyUint(TyUs(true)));
+        table.intern("usize",   TyUint(TyUs(false)));
         table.intern("u8",      TyUint(TyU8));
         table.intern("u16",     TyUint(TyU16));
         table.intern("u32",     TyUint(TyU32));
index 74071a1de4c3d080c797133c0db7a5d1577a1342..88ce36a710a0c606ff06c32ce1c6f1f769f84a9d 100644 (file)
@@ -917,8 +917,8 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
             ty::ty_int(t) => {
                 let llty = Type::int_from_ty(cx.ccx(), t);
                 let min = match t {
-                    ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
-                    ast::TyIs => i64::MIN as u64,
+                    ast::TyIs(_) if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
+                    ast::TyIs(_) => i64::MIN as u64,
                     ast::TyI8 => i8::MIN as u64,
                     ast::TyI16 => i16::MIN as u64,
                     ast::TyI32 => i32::MIN as u64,
index 3a6f4b47e4e1e7b2837be07b251e1a0727c61585..2f58baab7fca944327b5e073538c0e9150431f62 100644 (file)
@@ -1804,14 +1804,14 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
         ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
         ty::ty_int(int_ty) => match int_ty {
-            ast::TyIs => ("isize".to_string(), DW_ATE_signed),
+            ast::TyIs(_) => ("isize".to_string(), DW_ATE_signed),
             ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
             ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
             ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
             ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
         },
         ty::ty_uint(uint_ty) => match uint_ty {
-            ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
+            ast::TyUs(_) => ("usize".to_string(), DW_ATE_unsigned),
             ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
             ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
             ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
@@ -3739,12 +3739,12 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_bool              => output.push_str("bool"),
         ty::ty_char              => output.push_str("char"),
         ty::ty_str               => output.push_str("str"),
-        ty::ty_int(ast::TyIs)     => output.push_str("isize"),
+        ty::ty_int(ast::TyIs(_))     => output.push_str("isize"),
         ty::ty_int(ast::TyI8)    => output.push_str("i8"),
         ty::ty_int(ast::TyI16)   => output.push_str("i16"),
         ty::ty_int(ast::TyI32)   => output.push_str("i32"),
         ty::ty_int(ast::TyI64)   => output.push_str("i64"),
-        ty::ty_uint(ast::TyUs)    => output.push_str("usize"),
+        ty::ty_uint(ast::TyUs(_))    => output.push_str("usize"),
         ty::ty_uint(ast::TyU8)   => output.push_str("u8"),
         ty::ty_uint(ast::TyU16)  => output.push_str("u16"),
         ty::ty_uint(ast::TyU32)  => output.push_str("u32"),
index e2ed275d4c0ccf278f25542f6159d0f3130678b5..71a7789eb393277ec4a7372554d44a399001d6a1 100644 (file)
@@ -112,7 +112,7 @@ pub fn int(ccx: &CrateContext) -> Type {
 
     pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
         match t {
-            ast::TyIs => ccx.int_type(),
+            ast::TyIs(_) => ccx.int_type(),
             ast::TyI8 => Type::i8(ccx),
             ast::TyI16 => Type::i16(ccx),
             ast::TyI32 => Type::i32(ccx),
@@ -122,7 +122,7 @@ pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
 
     pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
         match t {
-            ast::TyUs => ccx.int_type(),
+            ast::TyUs(_) => ccx.int_type(),
             ast::TyU8 => Type::i8(ccx),
             ast::TyU16 => Type::i16(ccx),
             ast::TyU32 => Type::i32(ccx),
index 034a1ee8be5925ef2903803cb4de9def9da020ec..416dfb420ffae0068d301998d96fc5b2426d1ee7 100644 (file)
@@ -263,7 +263,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
         }
 
         match unsized_part_of_type(cx.tcx(), t).sty {
-            ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs),
+            ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs(_)),
             ty::ty_trait(_) => Type::vtable_ptr(cx),
             _ => panic!("Unexpected type returned from unsized_part_of_type : {}",
                        t.repr(cx.tcx()))
index b98b327100cdb7e1abb2e8344298679638cca359..f3778eb054037ee355ded8af6bcfe1a29b1625c4 100644 (file)
@@ -2442,7 +2442,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 
     // First, try built-in indexing.
     match (ty::index(adjusted_ty), &index_ty.sty) {
-        (Some(ty), &ty::ty_uint(ast::TyUs)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
+        (Some(ty), &ty::ty_uint(ast::TyUs(_))) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
             debug!("try_index_step: success, using built-in indexing");
             fcx.write_adjustment(base_expr.id, base_expr.span, ty::AdjustDerefRef(adjustment));
             return Some((tcx.types.uint, ty));
@@ -4770,7 +4770,7 @@ fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
                 ast::TyU16 => disr as u16 as Disr == disr,
                 ast::TyU32 => disr as u32 as Disr == disr,
                 ast::TyU64 => disr as u64 as Disr == disr,
-                ast::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
+                ast::TyUs(_) => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
             }
         }
         fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
@@ -4779,7 +4779,7 @@ fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
                 ast::TyI16 => disr as i16 as Disr == disr,
                 ast::TyI32 => disr as i32 as Disr == disr,
                 ast::TyI64 => disr as i64 as Disr == disr,
-                ast::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
+                ast::TyIs(_) => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
             }
         }
         match ty {
index fbb3c40ee99f659d62a5e93382f3876fd344ab34..a44c73e8c4120f91d9b986673e6a68273003faf8 100644 (file)
@@ -1389,12 +1389,12 @@ fn clean(&self, cx: &DocContext) -> Type {
         match self.sty {
             ty::ty_bool => Primitive(Bool),
             ty::ty_char => Primitive(Char),
-            ty::ty_int(ast::TyIs) => Primitive(Isize),
+            ty::ty_int(ast::TyIs(_)) => Primitive(Isize),
             ty::ty_int(ast::TyI8) => Primitive(I8),
             ty::ty_int(ast::TyI16) => Primitive(I16),
             ty::ty_int(ast::TyI32) => Primitive(I32),
             ty::ty_int(ast::TyI64) => Primitive(I64),
-            ty::ty_uint(ast::TyUs) => Primitive(Usize),
+            ty::ty_uint(ast::TyUs(_)) => Primitive(Usize),
             ty::ty_uint(ast::TyU8) => Primitive(U8),
             ty::ty_uint(ast::TyU16) => Primitive(U16),
             ty::ty_uint(ast::TyU32) => Primitive(U32),
@@ -2269,12 +2269,12 @@ fn resolve_type(cx: &DocContext,
             ast::TyStr => return Primitive(Str),
             ast::TyBool => return Primitive(Bool),
             ast::TyChar => return Primitive(Char),
-            ast::TyInt(ast::TyIs) => return Primitive(Isize),
+            ast::TyInt(ast::TyIs(_)) => return Primitive(Isize),
             ast::TyInt(ast::TyI8) => return Primitive(I8),
             ast::TyInt(ast::TyI16) => return Primitive(I16),
             ast::TyInt(ast::TyI32) => return Primitive(I32),
             ast::TyInt(ast::TyI64) => return Primitive(I64),
-            ast::TyUint(ast::TyUs) => return Primitive(Usize),
+            ast::TyUint(ast::TyUs(_)) => return Primitive(Usize),
             ast::TyUint(ast::TyU8) => return Primitive(U8),
             ast::TyUint(ast::TyU16) => return Primitive(U16),
             ast::TyUint(ast::TyU32) => return Primitive(U32),
index 0a9e0aedd3da886090240d604cdfb2726361d1f8..630f7768885de6ec6097834c0b90a2a312398f6f 100644 (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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 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,
         }
     }
index b4e917e28cb24a9ed0c849b780a8daeae70839de..bc7fbd46fd8bac52f795026e8f48854f315ffa3f 100644 (file)
@@ -127,8 +127,10 @@ pub fn is_path(e: P<Expr>) -> bool {
 /// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
 pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
     let s = match t {
-        TyIs if val.is_some() => "is",
-        TyIs => "isize",
+        TyIs(true) if val.is_some() => "i",
+        TyIs(true) => "int",
+        TyIs(false) if val.is_some() => "is",
+        TyIs(false) => "isize",
         TyI8 => "i8",
         TyI16 => "i16",
         TyI32 => "i32",
@@ -148,7 +150,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
     match t {
         TyI8 => 0x80u64,
         TyI16 => 0x8000u64,
-        TyIs | TyI32 => 0x80000000u64, // actually ni about TyIs
+        TyIs(_) | TyI32 => 0x80000000u64, // actually ni about TyIs
         TyI64 => 0x8000000000000000u64
     }
 }
@@ -157,8 +159,10 @@ pub fn int_ty_max(t: IntTy) -> u64 {
 /// We want to avoid "42uint" in favor of "42u"
 pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
     let s = match t {
-        TyUs if val.is_some() => "us",
-        TyUs => "usize",
+        TyUs(true) if val.is_some() => "u",
+        TyUs(true) => "uint",
+        TyUs(false) if val.is_some() => "us",
+        TyUs(false) => "usize",
         TyU8 => "u8",
         TyU16 => "u16",
         TyU32 => "u32",
@@ -175,7 +179,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 {
     match t {
         TyU8 => 0xffu64,
         TyU16 => 0xffffu64,
-        TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUs
+        TyUs(_) | TyU32 => 0xffffffffu64, // actually ni about TyUs
         TyU64 => 0xffffffffffffffffu64
     }
 }
index 2cea55dfc55efa6ae5bf890fac8296ef8e2ca804..6f57c06d33e885d682d33f5d0c6856bec4429a3f 100644 (file)
@@ -464,10 +464,10 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
         "u32" => Some(UnsignedInt(ast::TyU32)),
         "i64" => Some(SignedInt(ast::TyI64)),
         "u64" => Some(UnsignedInt(ast::TyU64)),
-        "int" => Some(SignedInt(ast::TyIs)),
-        "uint" => Some(UnsignedInt(ast::TyUs)),
-        "isize" => Some(SignedInt(ast::TyIs)),
-        "usize" => Some(UnsignedInt(ast::TyUs)),
+        "int" => Some(SignedInt(ast::TyIs(true))),
+        "uint" => Some(UnsignedInt(ast::TyUs(true))),
+        "isize" => Some(SignedInt(ast::TyIs(false))),
+        "usize" => Some(UnsignedInt(ast::TyUs(false))),
         _ => None
     }
 }
@@ -511,7 +511,7 @@ fn is_ffi_safe(self) -> bool {
             SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |
             SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |
             SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,
-            SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false
+            SignedInt(ast::TyIs(_)) | UnsignedInt(ast::TyUs(_)) => false
         }
     }
 }
index 27523ea453585aa180cbb5b21407608772dfd782..c34142aec39c8e7aa4158717613ceda9531ff8f0 100644 (file)
@@ -642,10 +642,11 @@ fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
         self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
     }
     fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr> {
-        self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
+        self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs(false))))
     }
     fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
-        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs, ast::Sign::new(i))))
+        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs(false),
+                                                                  ast::Sign::new(i))))
     }
     fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
index 47b29a4db3e27fbffd18dc6bb635aef05bd20883..e6b6f7bbd49c3d0f09d99bd7fcfd5d7fad69cce2 100644 (file)
@@ -1031,7 +1031,7 @@ fn build_enum_match_tuple(
             let arms: Vec<ast::Arm> = variants.iter().enumerate()
                 .map(|(index, variant)| {
                     let pat = variant_to_pat(cx, sp, type_ident, &**variant);
-                    let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs));
+                    let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs(false)));
                     cx.arm(sp, vec![pat], cx.expr_lit(sp, lit))
                 }).collect();
 
index 2dbf29c145c8ab1dea9d534284b644ca6f20aacf..c42b188302cc3ab25c1001c80b183535604622e9 100644 (file)
@@ -244,10 +244,10 @@ fn to_source_with_hygiene(&self) -> String {
     }
 
     macro_rules! impl_to_source_int {
-        (signed, $t:ty, $tag:ident) => (
+        (signed, $t:ty, $tag:expr) => (
             impl ToSource for $t {
                 fn to_source(&self) -> String {
-                    let lit = ast::LitInt(*self as u64, ast::SignedIntLit(ast::$tag,
+                    let lit = ast::LitInt(*self as u64, ast::SignedIntLit($tag,
                                                                           ast::Sign::new(*self)));
                     pprust::lit_to_string(&dummy_spanned(lit))
                 }
@@ -258,10 +258,10 @@ fn to_source_with_hygiene(&self) -> String {
                 }
             }
         );
-        (unsigned, $t:ty, $tag:ident) => (
+        (unsigned, $t:ty, $tag:expr) => (
             impl ToSource for $t {
                 fn to_source(&self) -> String {
-                    let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit(ast::$tag));
+                    let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag));
                     pprust::lit_to_string(&dummy_spanned(lit))
                 }
             }
@@ -273,17 +273,17 @@ fn to_source_with_hygiene(&self) -> String {
         );
     }
 
-    impl_to_source_int! { signed, int, TyIs }
-    impl_to_source_int! { signed, i8,  TyI8 }
-    impl_to_source_int! { signed, i16, TyI16 }
-    impl_to_source_int! { signed, i32, TyI32 }
-    impl_to_source_int! { signed, i64, TyI64 }
+    impl_to_source_int! { signed, int, ast::TyIs(false) }
+    impl_to_source_int! { signed, i8,  ast::TyI8 }
+    impl_to_source_int! { signed, i16, ast::TyI16 }
+    impl_to_source_int! { signed, i32, ast::TyI32 }
+    impl_to_source_int! { signed, i64, ast::TyI64 }
 
-    impl_to_source_int! { unsigned, uint, TyUs }
-    impl_to_source_int! { unsigned, u8,   TyU8 }
-    impl_to_source_int! { unsigned, u16,  TyU16 }
-    impl_to_source_int! { unsigned, u32,  TyU32 }
-    impl_to_source_int! { unsigned, u64,  TyU64 }
+    impl_to_source_int! { unsigned, uint, ast::TyUs(false) }
+    impl_to_source_int! { unsigned, u8,   ast::TyU8 }
+    impl_to_source_int! { unsigned, u16,  ast::TyU16 }
+    impl_to_source_int! { unsigned, u32,  ast::TyU32 }
+    impl_to_source_int! { unsigned, u64,  ast::TyU64 }
 
     // Alas ... we write these out instead. All redundant.
 
index c42a6beea2d447baec345b07f218ff1bc4da721e..f1f547ba0c7dd52e24855c6f32f558ecb390e743 100644 (file)
@@ -702,14 +702,14 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
     if let Some(suf) = suffix {
         if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
         ty = match suf {
-            "i"   => ast::SignedIntLit(ast::TyIs, ast::Plus),
-            "is"   => ast::SignedIntLit(ast::TyIs, ast::Plus),
+            "i"   => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
+            "is"   => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
             "i8"  => ast::SignedIntLit(ast::TyI8, ast::Plus),
             "i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
             "i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
             "i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
-            "u"   => ast::UnsignedIntLit(ast::TyUs),
-            "us"   => ast::UnsignedIntLit(ast::TyUs),
+            "u"   => ast::UnsignedIntLit(ast::TyUs(true)),
+            "us"   => ast::UnsignedIntLit(ast::TyUs(false)),
             "u8"  => ast::UnsignedIntLit(ast::TyU8),
             "u16" => ast::UnsignedIntLit(ast::TyU16),
             "u32" => ast::UnsignedIntLit(ast::TyU32),