Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int/uint -> isize/usize #20750

Closed
wants to merge 10 commits into from
  •  
  •  
  •  
1 change: 1 addition & 0 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![allow(unknown_features)]
#![feature(slicing_syntax, unboxed_closures)]
#![feature(box_syntax)]
#![feature(int_uint)]

#![deny(warnings)]

Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#![allow(unknown_features)]
#![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

#[macro_use]
extern crate core;
Expand Down
1 change: 1 addition & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#![feature(unsafe_destructor)]
#![feature(unboxed_closures)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]
#![allow(missing_docs)]

extern crate alloc;
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![feature(box_syntax)]
#![feature(unboxed_closures)]
#![feature(old_impl_check)]
#![allow(unknown_features)] #![feature(int_uint)]
#![no_std]

#[macro_use]
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@
#![no_std]
#![allow(unknown_features, raw_pointer_derive)]
#![cfg_attr(stage0, allow(unused_attributes))]
#![feature(intrinsics, lang_items)]
#![allow(unknown_features)] #![feature(intrinsics, lang_items)]
#![feature(simd, unsafe_destructor, slicing_syntax)]
#![feature(unboxed_closures)]
#![allow(unknown_features)] #![feature(int_uint)]
#![deny(missing_docs)]

#[macro_use]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ macro_rules! panic {
panic!("explicit panic")
);
($msg:expr) => ({
static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!());
static _MSG_FILE_LINE: (&'static str, &'static str, usize) = ($msg, file!(), line!());
::core::panicking::panic(&_MSG_FILE_LINE)
});
($fmt:expr, $($arg:tt)*) => ({
// The leading _'s are to avoid dead code warnings if this is
// used inside a dead function. Just `#[allow(dead_code)]` is
// insufficient, since the user may have
// `#[forbid(dead_code)]` and which cannot be overridden.
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
static _FILE_LINE: (&'static str, usize) = (file!(), line!());
::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
});
}
Expand Down
1 change: 1 addition & 0 deletions src/libcoretest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(unsafe_destructor, slicing_syntax)]
#![feature(unboxed_closures)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate core;
extern crate test;
Expand Down
1 change: 1 addition & 0 deletions src/libflate/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![crate_name = "flate"]
#![experimental]
#![staged_api]
#![allow(unknown_features)] #![feature(int_uint)]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
Expand Down
1 change: 1 addition & 0 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
html_playground_url = "http://play.rust-lang.org/")]

#![feature(slicing_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

pub use self::Piece::*;
pub use self::Position::*;
Expand Down
1 change: 1 addition & 0 deletions src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(slicing_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]
#![deny(missing_docs)]

#[cfg(test)] #[macro_use] extern crate log;
Expand Down
1 change: 1 addition & 0 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(slicing_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

use self::LabelText::*;

Expand Down
1 change: 1 addition & 0 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![crate_type = "rlib"]
#![cfg_attr(not(feature = "cargo-build"), experimental)]
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
#![allow(unknown_features)] #![feature(int_uint)]
#![no_std]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
Expand Down
1 change: 1 addition & 0 deletions src/liblog/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
#![allow(unknown_features)]
#![feature(slicing_syntax)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]
#![deny(missing_docs)]

extern crate regex;
Expand Down
2 changes: 1 addition & 1 deletion src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]

#![allow(unknown_features)] #![feature(int_uint)]
#![no_std]
#![experimental]
#![staged_api]
Expand Down
1 change: 1 addition & 0 deletions src/librbml/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)]
#![feature(slicing_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate serialize;
#[macro_use] extern crate log;
Expand Down
1 change: 1 addition & 0 deletions src/libregex/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#![allow(unknown_features)]
#![feature(slicing_syntax)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]
#![deny(missing_docs)]

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]
#![feature(rustc_diagnostic_macros)]
#![feature(old_impl_check)]

Expand Down
16 changes: 8 additions & 8 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl LintPass for TypeLimits {
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);
Expand All @@ -233,7 +233,7 @@ impl LintPass for TypeLimits {
};
},
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);
Expand Down Expand Up @@ -296,7 +296,7 @@ impl LintPass for TypeLimits {
// 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),
Expand All @@ -306,7 +306,7 @@ impl LintPass for TypeLimits {

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),
Expand All @@ -323,7 +323,7 @@ impl LintPass for TypeLimits {

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,
Expand All @@ -333,7 +333,7 @@ impl LintPass for TypeLimits {

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,
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,12 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St

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),
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2341,12 +2341,12 @@ impl<'tcx> CommonTypes<'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(false))),
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(false))),
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)),
Expand Down Expand Up @@ -2692,7 +2692,7 @@ impl FlagComputation {

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,
Expand All @@ -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,
Expand Down Expand Up @@ -3363,7 +3363,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {

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
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![allow(unknown_features)]
#![feature(slicing_syntax, box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate syntax;
extern crate serialize;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_borrowck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(rustc_diagnostic_macros)]
#![allow(unknown_features)] #![feature(int_uint)]
#![allow(non_camel_case_types)]

#[macro_use] extern crate log;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate arena;
extern crate flate;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#![allow(unknown_features)]
#![feature(link_args)]
#![feature(box_syntax)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate libc;

Expand Down
9 changes: 5 additions & 4 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#![feature(slicing_syntax)]
#![feature(rustc_diagnostic_macros)]
#![allow(unknown_features)] #![feature(int_uint)]

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
Expand Down Expand Up @@ -819,15 +820,15 @@ impl 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));
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
#![allow(unknown_features)] #![feature(int_uint)]

extern crate arena;
extern crate flate;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading