]> git.lizzy.rs Git - rust.git/commitdiff
syntax/rustc: implement isize/usize
authorCorey Richardson <corey@octayn.net>
Sat, 6 Dec 2014 02:11:46 +0000 (18:11 -0800)
committerCorey Richardson <corey@octayn.net>
Tue, 6 Jan 2015 20:15:07 +0000 (15:15 -0500)
22 files changed:
src/librustc/lint/builtin.rs
src/librustc/metadata/tydecode.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
src/test/run-fail/assert-as-macro.rs
src/test/run-fail/panic.rs
src/test/run-pass/tydesc-name.rs

index 425e34cd9f0424b437b8eab9972519829e3a36b3..64ca49d76f3c8789ff32b34cfe158bde176998a7 100644 (file)
@@ -46,7 +46,7 @@
 use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{Span, DUMMY_SP};
 use syntax::parse::token;
-use syntax::ast::{TyI, TyU, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
+use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ast_util;
 use syntax::ptr::P;
 use syntax::visit::{self, Visitor};
@@ -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::TyI {
+                                let int_type = if t == ast::TyIs {
                                     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::TyU {
+                        let uint_type = if t == ast::TyUs {
                             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::TyI =>    (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::TyU =>   (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::TyI =>    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::TyU =>    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,14 +404,14 @@ 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::TyI)) => {
+            def::DefPrimTy(ast::TyInt(ast::TyIs)) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
-                                  "found rust type `int` in foreign module, while \
+                                  "found rust type `isize` in foreign module, while \
                                    libc::c_int or libc::c_long should be used");
             }
-            def::DefPrimTy(ast::TyUint(ast::TyU)) => {
+            def::DefPrimTy(ast::TyUint(ast::TyUs)) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
-                                  "found rust type `uint` in foreign module, while \
+                                  "found rust type `usize` in foreign module, while \
                                    libc::c_uint or libc::c_ulong should be used");
             }
             def::DefTy(..) => {
index 07dc13ff0d48f6e3b782bb1bbf858b57f935359c..a39126f0851649e30e62d1cc4b50a9c70b8317ae 100644 (file)
@@ -443,8 +443,8 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
     let tcx = st.tcx;
     match next(st) {
       'b' => return tcx.types.bool,
-      'i' => return tcx.types.int,
-      'u' => return tcx.types.uint,
+      'i' => { /* eat the s of is */ next(st); return tcx.types.int },
+      'u' => { /* eat the s of us */ next(st); return tcx.types.uint },
       'M' => {
         match next(st) {
           'b' => return tcx.types.u8,
index 0042209aced6ad4e17d1392c72e374e9d35f8f34..c019d129218b659ea878992351cb223157ca4742 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::TyI => mywrite!(w, "i"),
+                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::TyU => mywrite!(w, "u"),
+                ast::TyUs => mywrite!(w, "us"),
                 ast::TyU8 => mywrite!(w, "Mb"),
                 ast::TyU16 => mywrite!(w, "Mw"),
                 ast::TyU32 => mywrite!(w, "Ml"),
index 32482fce4daa8b05d556f35333e724f4980937cb..1aec7252a3c1d4d379bd45fb8452053dc25de9da 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::TyI) => (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::TyU) => (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 c359233eca173cd4ad7b9fe05d76b6838a4bc6d4..62f1a2b49d444dd07ee5bb2358ca1cd0c7e54b6e 100644 (file)
@@ -2302,12 +2302,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::TyI)),
+            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::TyU)),
+            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)),
@@ -2653,7 +2653,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::TyI    => tcx.types.int,
+        ast::TyIs   => tcx.types.int,
         ast::TyI8   => tcx.types.i8,
         ast::TyI16  => tcx.types.i16,
         ast::TyI32  => tcx.types.i32,
@@ -2663,7 +2663,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::TyU    => tcx.types.uint,
+        ast::TyUs   => tcx.types.uint,
         ast::TyU8   => tcx.types.u8,
         ast::TyU16  => tcx.types.u16,
         ast::TyU32  => tcx.types.u32,
@@ -3324,7 +3324,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
 
         let result = match ty.sty {
             // uint and int are ffi-unsafe
-            ty_uint(ast::TyU) | ty_int(ast::TyI) => {
+            ty_uint(ast::TyUs) | ty_int(ast::TyIs) => {
                 TC::ReachesFfiUnsafe
             }
 
@@ -3896,7 +3896,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::TyU) => true,
+      ty_infer(IntVar(_)) | ty_uint(ast::TyUs) => true,
       _ => false
     }
 }
@@ -3942,7 +3942,7 @@ pub fn type_is_signed(ty: Ty) -> bool {
 
 pub fn type_is_machine(ty: Ty) -> bool {
     match ty.sty {
-        ty_int(ast::TyI) | ty_uint(ast::TyU) => false,
+        ty_int(ast::TyIs) | ty_uint(ast::TyUs) => false,
         ty_int(..) | ty_uint(..) | ty_float(..) => true,
         _ => false
     }
index 58102fe5629d9f43bc2656d609830f2451a0f68e..cc9abecc20fc8a360c82c1623a5a1bb773ef7dc3 100644 (file)
@@ -86,9 +86,9 @@
 use syntax::ast::{RegionTyParamBound, StructField};
 use syntax::ast::{TraitRef, TraitTyParamBound};
 use syntax::ast::{Ty, TyBool, TyChar, TyF32};
-use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
+use syntax::ast::{TyF64, TyFloat, TyIs, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
 use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyQPath};
-use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
+use syntax::ast::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint};
 use syntax::ast::{TypeImplItem};
 use syntax::ast;
 use syntax::ast_map;
@@ -833,13 +833,15 @@ fn new() -> PrimitiveTypeTable {
         table.intern("char",    TyChar);
         table.intern("f32",     TyFloat(TyF32));
         table.intern("f64",     TyFloat(TyF64));
-        table.intern("int",     TyInt(TyI));
+        table.intern("int",     TyInt(TyIs));
+        table.intern("isize",     TyInt(TyIs));
         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(TyU));
+        table.intern("uint",    TyUint(TyUs));
+        table.intern("usize",    TyUint(TyUs));
         table.intern("u8",      TyUint(TyU8));
         table.intern("u16",     TyUint(TyU16));
         table.intern("u32",     TyUint(TyU32));
index edcfaae0f802d32482aab9ca1f785b2d142d7999..b889b52207885a655a17e4651dad05df432dcd50 100644 (file)
@@ -903,8 +903,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::TyI if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
-                    ast::TyI => 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 3f0f7fd9bd3032564c37beff27febf777b1aecb3..c099c80f86334fd8810810383751bf3e6e0322fb 100644 (file)
@@ -1797,14 +1797,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::TyI => ("int".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::TyU => ("uint".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),
@@ -3729,12 +3729,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::TyI)     => output.push_str("int"),
+        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::TyU)    => output.push_str("uint"),
+        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 3785c2fb9bc54e5b633e3dd36099266ed2840dec..88199f97b54ba575c007731610e8ad98dc64671c 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::TyI => 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::TyU => ccx.int_type(),
+            ast::TyUs => ccx.int_type(),
             ast::TyU8 => Type::i8(ccx),
             ast::TyU16 => Type::i16(ccx),
             ast::TyU32 => Type::i32(ccx),
index 3e499ea8498fbad9355e18cf6204370fb9db8573..d2f33c03ed549980c893c1fc411e705f65ae8a4a 100644 (file)
@@ -264,7 +264,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::TyU),
+            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 1b51434a58cc130c5f20b9a73810ee4ba797b0c9..7be383f2a026da6cb8de696d0c6af91a17e89d8b 100644 (file)
@@ -4859,7 +4859,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::TyU => 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 {
@@ -4868,7 +4868,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::TyI => 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 bb9a9ac430340642d193d21293af34296674a4a0..60faa09b964ddcd7dccac7117f922a4c0c634263 100644 (file)
@@ -1238,8 +1238,8 @@ pub enum Type {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy)]
 pub enum PrimitiveType {
-    Int, I8, I16, I32, I64,
-    Uint, U8, U16, U32, U64,
+    Isize, I8, I16, I32, I64,
+    Usize, U8, U16, U32, U64,
     F32, F64,
     Char,
     Bool,
@@ -1264,12 +1264,12 @@ pub enum TypeKind {
 impl PrimitiveType {
     fn from_str(s: &str) -> Option<PrimitiveType> {
         match s.as_slice() {
-            "int" => Some(Int),
+            "isize" | "int" => Some(Isize),
             "i8" => Some(I8),
             "i16" => Some(I16),
             "i32" => Some(I32),
             "i64" => Some(I64),
-            "uint" => Some(Uint),
+            "usize" | "uint" => Some(Usize),
             "u8" => Some(U8),
             "u16" => Some(U16),
             "u32" => Some(U32),
@@ -1308,12 +1308,12 @@ fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
 
     pub fn to_string(&self) -> &'static str {
         match *self {
-            Int => "int",
+            Isize => "isize",
             I8 => "i8",
             I16 => "i16",
             I32 => "i32",
             I64 => "i64",
-            Uint => "uint",
+            Usize => "usize",
             U8 => "u8",
             U16 => "u16",
             U32 => "u32",
@@ -1387,12 +1387,12 @@ fn clean(&self, cx: &DocContext) -> Type {
         match self.sty {
             ty::ty_bool => Primitive(Bool),
             ty::ty_char => Primitive(Char),
-            ty::ty_int(ast::TyI) => Primitive(Int),
+            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::TyU) => Primitive(Uint),
+            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),
@@ -2265,12 +2265,12 @@ fn resolve_type(cx: &DocContext,
             ast::TyStr => return Primitive(Str),
             ast::TyBool => return Primitive(Bool),
             ast::TyChar => return Primitive(Char),
-            ast::TyInt(ast::TyI) => return Primitive(Int),
+            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::TyU) => return Primitive(Uint),
+            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 7aa7c4fcfb3019be51d900134fb6adab37a0c81a..032ab05a418b27e7db6d9b8280bff092efef0b2e 100644 (file)
@@ -1087,7 +1087,7 @@ pub struct Typedef {
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
 pub enum IntTy {
-    TyI,
+    TyIs,
     TyI8,
     TyI16,
     TyI32,
@@ -1103,7 +1103,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl IntTy {
     pub fn suffix_len(&self) -> uint {
         match *self {
-            TyI => 1,
+            TyIs => 1,
             TyI8 => 2,
             TyI16 | TyI32 | TyI64  => 3,
         }
@@ -1112,7 +1112,7 @@ pub fn suffix_len(&self) -> uint {
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
 pub enum UintTy {
-    TyU,
+    TyUs,
     TyU8,
     TyU16,
     TyU32,
@@ -1122,7 +1122,7 @@ pub enum UintTy {
 impl UintTy {
     pub fn suffix_len(&self) -> uint {
         match *self {
-            TyU => 1,
+            TyUs => 1,
             TyU8 => 2,
             TyU16 | TyU32 | TyU64  => 3,
         }
index 5e03afec16cf8709e1e5a92a047e87d39ef9a6b5..d6df9f46621a7b29e916d033717c3eac3e8d01fe 100644 (file)
@@ -120,8 +120,8 @@ 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 {
-        TyI if val.is_some() => "i",
-        TyI => "int",
+        TyIs if val.is_some() => "is",
+        TyIs => "isize",
         TyI8 => "i8",
         TyI16 => "i16",
         TyI32 => "i32",
@@ -141,7 +141,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
     match t {
         TyI8 => 0x80u64,
         TyI16 => 0x8000u64,
-        TyI | TyI32 => 0x80000000u64, // actually ni about TyI
+        TyIs | TyI32 => 0x80000000u64, // actually ni about TyIm
         TyI64 => 0x8000000000000000u64
     }
 }
@@ -150,8 +150,8 @@ 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 {
-        TyU if val.is_some() => "u",
-        TyU => "uint",
+        TyUs if val.is_some() => "us",
+        TyUs => "usize",
         TyU8 => "u8",
         TyU16 => "u16",
         TyU32 => "u32",
@@ -168,7 +168,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 {
     match t {
         TyU8 => 0xffu64,
         TyU16 => 0xffffu64,
-        TyU | TyU32 => 0xffffffffu64, // actually ni about TyU
+        TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUm
         TyU64 => 0xffffffffffffffffu64
     }
 }
index 43e23f26e930e8155d7cc8b634cbb3a18eefce57..523477eef22c8537c19cd1f323ad3f883f2959ba 100644 (file)
@@ -457,8 +457,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::TyI)),
-        "uint" => Some(UnsignedInt(ast::TyU)),
+        "int" => Some(SignedInt(ast::TyIs)),
+        "uint" => Some(UnsignedInt(ast::TyUs)),
+        "isize" => Some(SignedInt(ast::TyIs)),
+        "usize" => Some(UnsignedInt(ast::TyUs)),
         _ => None
     }
 }
@@ -502,7 +504,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::TyI) | UnsignedInt(ast::TyU) => false
+            SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false
         }
     }
 }
index ea345f3a458f49ea4b5d49b579072cf3efdaf18f..843172cee19b1afaae69e8d2299b4571cff146c2 100644 (file)
@@ -642,10 +642,10 @@ 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::TyU)))
+        self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
     }
     fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
-        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyI, ast::Sign::new(i))))
+        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs, 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 1aa430c4a08299b325ec73fd42dbb8934ffa4443..1112eaa789026c412d51bd3aea2b44fb7a098985 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::TyU));
+                    let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs));
                     cx.arm(sp, vec![pat], cx.expr_lit(sp, lit))
                 }).collect();
 
index f1b52fa33c386a3bd439ad9b9c2e9e4f0ed308c4..ccc15449834c1a60775bd74b57e1e94b3bc32c02 100644 (file)
@@ -273,13 +273,13 @@ fn to_source_with_hygiene(&self) -> String {
         );
     }
 
-    impl_to_source_int! { signed, int, TyI }
+    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! { unsigned, uint, TyU }
+    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 }
index b0969a573e66b3cf35e1cb5a0573c079e85228de..c26613b4d6cb35a4dd2e135bfead1fcecf29d22f 100644 (file)
@@ -701,12 +701,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::TyI, ast::Plus),
+            "i"   => ast::SignedIntLit(ast::TyIs, ast::Plus),
+            "is"   => ast::SignedIntLit(ast::TyIs, 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::TyU),
+            "u"   => ast::UnsignedIntLit(ast::TyUs),
+            "us"   => ast::UnsignedIntLit(ast::TyUs),
             "u8"  => ast::UnsignedIntLit(ast::TyU8),
             "u16" => ast::UnsignedIntLit(ast::TyU16),
             "u32" => ast::UnsignedIntLit(ast::TyU32),
index fb069e61bd2a1b571a2bd36367cbabbf74ae6ac7..59e79fe9266f0aa7e28edd81a746c98f5409727b 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: 1i == 2
+// error-pattern:assertion failed: 1is == 2
 
 fn main() {
-    assert!(1i == 2);
+    assert!(1is == 2);
 }
index 54ccc98bcd9243d61f8c19eb01c855113358534c..dd4c58f176c84ad8e1691800fd646eeb3a1b108d 100644 (file)
@@ -8,8 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-
-// error-pattern:1i == 2
-fn main() { assert!((1i == 2)); }
+// error-pattern:1is == 2
+fn main() { assert!((1is == 2)); }
index 4f473755cb6cff868fd36c406abd55d2fac49d4a..e3b148ac92db6fbe1e4a8e6c43027176454c1fc1 100644 (file)
@@ -17,7 +17,7 @@ struct Foo<T> {
 
 pub fn main() {
     unsafe {
-        assert_eq!((*get_tydesc::<int>()).name, "int");
-        assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<uint>");
+        assert_eq!((*get_tydesc::<int>()).name, "isize");
+        assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<usize>");
     }
 }