Rollup merge of #47170 - eddyb:us-vs-usize, r=nikomatsakis

rustc: use {U,I}size instead of {U,I}s shorthands.

`Us`/`Is` come from a time when `us` and `is` were the literal suffixes that are now `usize` / `isize`.

r? @nikomatsakis
This commit is contained in:
kennytm 2018-01-07 02:36:02 +08:00 committed by GitHub
commit b63f89783d
35 changed files with 100 additions and 100 deletions

View File

@ -155,8 +155,8 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
Bool(value) Bool(value)
}); });
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Is, I8, I16, I32, I64, I128 }); impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Us, U8, U16, U32, U64, U128 }); impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 }); impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal }); impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst }); impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });

View File

@ -754,13 +754,13 @@ impl<'tcx> CommonTypes<'tcx> {
char: mk(TyChar), char: mk(TyChar),
never: mk(TyNever), never: mk(TyNever),
err: mk(TyError), err: mk(TyError),
isize: mk(TyInt(ast::IntTy::Is)), isize: mk(TyInt(ast::IntTy::Isize)),
i8: mk(TyInt(ast::IntTy::I8)), i8: mk(TyInt(ast::IntTy::I8)),
i16: mk(TyInt(ast::IntTy::I16)), i16: mk(TyInt(ast::IntTy::I16)),
i32: mk(TyInt(ast::IntTy::I32)), i32: mk(TyInt(ast::IntTy::I32)),
i64: mk(TyInt(ast::IntTy::I64)), i64: mk(TyInt(ast::IntTy::I64)),
i128: mk(TyInt(ast::IntTy::I128)), i128: mk(TyInt(ast::IntTy::I128)),
usize: mk(TyUint(ast::UintTy::Us)), usize: mk(TyUint(ast::UintTy::Usize)),
u8: mk(TyUint(ast::UintTy::U8)), u8: mk(TyUint(ast::UintTy::U8)),
u16: mk(TyUint(ast::UintTy::U16)), u16: mk(TyUint(ast::UintTy::U16)),
u32: mk(TyUint(ast::UintTy::U32)), u32: mk(TyUint(ast::UintTy::U32)),
@ -1912,7 +1912,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> { pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {
match tm { match tm {
ast::IntTy::Is => self.types.isize, ast::IntTy::Isize => self.types.isize,
ast::IntTy::I8 => self.types.i8, ast::IntTy::I8 => self.types.i8,
ast::IntTy::I16 => self.types.i16, ast::IntTy::I16 => self.types.i16,
ast::IntTy::I32 => self.types.i32, ast::IntTy::I32 => self.types.i32,
@ -1923,7 +1923,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn mk_mach_uint(self, tm: ast::UintTy) -> Ty<'tcx> { pub fn mk_mach_uint(self, tm: ast::UintTy) -> Ty<'tcx> {
match tm { match tm {
ast::UintTy::Us => self.types.usize, ast::UintTy::Usize => self.types.usize,
ast::UintTy::U8 => self.types.u8, ast::UintTy::U8 => self.types.u8,
ast::UintTy::U16 => self.types.u16, ast::UintTy::U16 => self.types.u16,
ast::UintTy::U32 => self.types.u32, ast::UintTy::U32 => self.types.u32,

View File

@ -520,7 +520,7 @@ impl<'a, 'tcx> Integer {
attr::SignedInt(IntTy::I32) | attr::UnsignedInt(UintTy::U32) => I32, attr::SignedInt(IntTy::I32) | attr::UnsignedInt(UintTy::U32) => I32,
attr::SignedInt(IntTy::I64) | attr::UnsignedInt(UintTy::U64) => I64, attr::SignedInt(IntTy::I64) | attr::UnsignedInt(UintTy::U64) => I64,
attr::SignedInt(IntTy::I128) | attr::UnsignedInt(UintTy::U128) => I128, attr::SignedInt(IntTy::I128) | attr::UnsignedInt(UintTy::U128) => I128,
attr::SignedInt(IntTy::Is) | attr::UnsignedInt(UintTy::Us) => { attr::SignedInt(IntTy::Isize) | attr::UnsignedInt(UintTy::Usize) => {
dl.ptr_sized_integer() dl.ptr_sized_integer()
} }
} }

View File

@ -1575,7 +1575,7 @@ impl ReprOptions {
pub fn linear(&self) -> bool { self.flags.contains(ReprFlags::IS_LINEAR) } pub fn linear(&self) -> bool { self.flags.contains(ReprFlags::IS_LINEAR) }
pub fn discr_type(&self) -> attr::IntType { pub fn discr_type(&self) -> attr::IntType {
self.int.unwrap_or(attr::SignedInt(ast::IntTy::Is)) self.int.unwrap_or(attr::SignedInt(ast::IntTy::Isize))
} }
/// Returns true if this `#[repr()]` should inhabit "smart enum /// Returns true if this `#[repr()]` should inhabit "smart enum

View File

@ -1478,13 +1478,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
} }
} }
pub fn is_uint(&self) -> bool {
match self.sty {
TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true,
_ => false
}
}
pub fn is_char(&self) -> bool { pub fn is_char(&self) -> bool {
match self.sty { match self.sty {
TyChar => true, TyChar => true,
@ -1512,7 +1505,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
pub fn is_machine(&self) -> bool { pub fn is_machine(&self) -> bool {
match self.sty { match self.sty {
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false, TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false,
TyInt(..) | TyUint(..) | TyFloat(..) => true, TyInt(..) | TyUint(..) | TyFloat(..) => true,
_ => false, _ => false,
} }

View File

@ -55,7 +55,7 @@ macro_rules! typed_literal {
SignedInt(ast::IntTy::I32) => ConstInt::I32($lit), SignedInt(ast::IntTy::I32) => ConstInt::I32($lit),
SignedInt(ast::IntTy::I64) => ConstInt::I64($lit), SignedInt(ast::IntTy::I64) => ConstInt::I64($lit),
SignedInt(ast::IntTy::I128) => ConstInt::I128($lit), SignedInt(ast::IntTy::I128) => ConstInt::I128($lit),
SignedInt(ast::IntTy::Is) => match $tcx.sess.target.isize_ty { SignedInt(ast::IntTy::Isize) => match $tcx.sess.target.isize_ty {
ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16($lit)), ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16($lit)),
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32($lit)), ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32($lit)),
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64($lit)), ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64($lit)),
@ -66,7 +66,7 @@ macro_rules! typed_literal {
UnsignedInt(ast::UintTy::U32) => ConstInt::U32($lit), UnsignedInt(ast::UintTy::U32) => ConstInt::U32($lit),
UnsignedInt(ast::UintTy::U64) => ConstInt::U64($lit), UnsignedInt(ast::UintTy::U64) => ConstInt::U64($lit),
UnsignedInt(ast::UintTy::U128) => ConstInt::U128($lit), UnsignedInt(ast::UintTy::U128) => ConstInt::U128($lit),
UnsignedInt(ast::UintTy::Us) => match $tcx.sess.target.usize_ty { UnsignedInt(ast::UintTy::Usize) => match $tcx.sess.target.usize_ty {
ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16($lit)), ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16($lit)),
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32($lit)), ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32($lit)),
ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64($lit)), ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64($lit)),
@ -84,13 +84,13 @@ impl IntTypeExt for attr::IntType {
SignedInt(ast::IntTy::I32) => tcx.types.i32, SignedInt(ast::IntTy::I32) => tcx.types.i32,
SignedInt(ast::IntTy::I64) => tcx.types.i64, SignedInt(ast::IntTy::I64) => tcx.types.i64,
SignedInt(ast::IntTy::I128) => tcx.types.i128, SignedInt(ast::IntTy::I128) => tcx.types.i128,
SignedInt(ast::IntTy::Is) => tcx.types.isize, SignedInt(ast::IntTy::Isize) => tcx.types.isize,
UnsignedInt(ast::UintTy::U8) => tcx.types.u8, UnsignedInt(ast::UintTy::U8) => tcx.types.u8,
UnsignedInt(ast::UintTy::U16) => tcx.types.u16, UnsignedInt(ast::UintTy::U16) => tcx.types.u16,
UnsignedInt(ast::UintTy::U32) => tcx.types.u32, UnsignedInt(ast::UintTy::U32) => tcx.types.u32,
UnsignedInt(ast::UintTy::U64) => tcx.types.u64, UnsignedInt(ast::UintTy::U64) => tcx.types.u64,
UnsignedInt(ast::UintTy::U128) => tcx.types.u128, UnsignedInt(ast::UintTy::U128) => tcx.types.u128,
UnsignedInt(ast::UintTy::Us) => tcx.types.usize, UnsignedInt(ast::UintTy::Usize) => tcx.types.usize,
} }
} }
@ -105,13 +105,13 @@ impl IntTypeExt for attr::IntType {
(SignedInt(ast::IntTy::I32), ConstInt::I32(_)) => {}, (SignedInt(ast::IntTy::I32), ConstInt::I32(_)) => {},
(SignedInt(ast::IntTy::I64), ConstInt::I64(_)) => {}, (SignedInt(ast::IntTy::I64), ConstInt::I64(_)) => {},
(SignedInt(ast::IntTy::I128), ConstInt::I128(_)) => {}, (SignedInt(ast::IntTy::I128), ConstInt::I128(_)) => {},
(SignedInt(ast::IntTy::Is), ConstInt::Isize(_)) => {}, (SignedInt(ast::IntTy::Isize), ConstInt::Isize(_)) => {},
(UnsignedInt(ast::UintTy::U8), ConstInt::U8(_)) => {}, (UnsignedInt(ast::UintTy::U8), ConstInt::U8(_)) => {},
(UnsignedInt(ast::UintTy::U16), ConstInt::U16(_)) => {}, (UnsignedInt(ast::UintTy::U16), ConstInt::U16(_)) => {},
(UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {}, (UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {},
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {}, (UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
(UnsignedInt(ast::UintTy::U128), ConstInt::U128(_)) => {}, (UnsignedInt(ast::UintTy::U128), ConstInt::U128(_)) => {},
(UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {}, (UnsignedInt(ast::UintTy::Usize), ConstInt::Usize(_)) => {},
_ => bug!("disr type mismatch: {:?} vs {:?}", self, val), _ => bug!("disr type mismatch: {:?} vs {:?}", self, val),
} }
} }

View File

@ -133,8 +133,8 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
(&LitKind::Int(I128_OVERFLOW, Signed(IntTy::I128)), _) => { (&LitKind::Int(I128_OVERFLOW, Signed(IntTy::I128)), _) => {
Some(I128(i128::min_value())) Some(I128(i128::min_value()))
}, },
(&LitKind::Int(n, _), &ty::TyInt(IntTy::Is)) | (&LitKind::Int(n, _), &ty::TyInt(IntTy::Isize)) |
(&LitKind::Int(n, Signed(IntTy::Is)), _) => { (&LitKind::Int(n, Signed(IntTy::Isize)), _) => {
match tcx.sess.target.isize_ty { match tcx.sess.target.isize_ty {
IntTy::I16 => if n == I16_OVERFLOW { IntTy::I16 => if n == I16_OVERFLOW {
Some(Isize(Is16(i16::min_value()))) Some(Isize(Is16(i16::min_value())))
@ -478,7 +478,7 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty::TyInt(ast::IntTy::I32) => Ok(Integral(I32(v as i128 as i32))), ty::TyInt(ast::IntTy::I32) => Ok(Integral(I32(v as i128 as i32))),
ty::TyInt(ast::IntTy::I64) => Ok(Integral(I64(v as i128 as i64))), ty::TyInt(ast::IntTy::I64) => Ok(Integral(I64(v as i128 as i64))),
ty::TyInt(ast::IntTy::I128) => Ok(Integral(I128(v as i128))), ty::TyInt(ast::IntTy::I128) => Ok(Integral(I128(v as i128))),
ty::TyInt(ast::IntTy::Is) => { ty::TyInt(ast::IntTy::Isize) => {
Ok(Integral(Isize(ConstIsize::new_truncating(v as i128, tcx.sess.target.isize_ty)))) Ok(Integral(Isize(ConstIsize::new_truncating(v as i128, tcx.sess.target.isize_ty))))
}, },
ty::TyUint(ast::UintTy::U8) => Ok(Integral(U8(v as u8))), ty::TyUint(ast::UintTy::U8) => Ok(Integral(U8(v as u8))),
@ -486,7 +486,7 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty::TyUint(ast::UintTy::U32) => Ok(Integral(U32(v as u32))), ty::TyUint(ast::UintTy::U32) => Ok(Integral(U32(v as u32))),
ty::TyUint(ast::UintTy::U64) => Ok(Integral(U64(v as u64))), ty::TyUint(ast::UintTy::U64) => Ok(Integral(U64(v as u64))),
ty::TyUint(ast::UintTy::U128) => Ok(Integral(U128(v as u128))), ty::TyUint(ast::UintTy::U128) => Ok(Integral(U128(v as u128))),
ty::TyUint(ast::UintTy::Us) => { ty::TyUint(ast::UintTy::Usize) => {
Ok(Integral(Usize(ConstUsize::new_truncating(v, tcx.sess.target.usize_ty)))) Ok(Integral(Usize(ConstUsize::new_truncating(v, tcx.sess.target.usize_ty))))
}, },
ty::TyFloat(fty) => { ty::TyFloat(fty) => {

View File

@ -75,13 +75,13 @@ impl ConstMathErr {
ULitOutOfRange(ast::UintTy::U32) => "literal out of range for u32", ULitOutOfRange(ast::UintTy::U32) => "literal out of range for u32",
ULitOutOfRange(ast::UintTy::U64) => "literal out of range for u64", ULitOutOfRange(ast::UintTy::U64) => "literal out of range for u64",
ULitOutOfRange(ast::UintTy::U128) => "literal out of range for u128", ULitOutOfRange(ast::UintTy::U128) => "literal out of range for u128",
ULitOutOfRange(ast::UintTy::Us) => "literal out of range for usize", ULitOutOfRange(ast::UintTy::Usize) => "literal out of range for usize",
LitOutOfRange(ast::IntTy::I8) => "literal out of range for i8", LitOutOfRange(ast::IntTy::I8) => "literal out of range for i8",
LitOutOfRange(ast::IntTy::I16) => "literal out of range for i16", LitOutOfRange(ast::IntTy::I16) => "literal out of range for i16",
LitOutOfRange(ast::IntTy::I32) => "literal out of range for i32", LitOutOfRange(ast::IntTy::I32) => "literal out of range for i32",
LitOutOfRange(ast::IntTy::I64) => "literal out of range for i64", LitOutOfRange(ast::IntTy::I64) => "literal out of range for i64",
LitOutOfRange(ast::IntTy::I128) => "literal out of range for i128", LitOutOfRange(ast::IntTy::I128) => "literal out of range for i128",
LitOutOfRange(ast::IntTy::Is) => "literal out of range for isize", LitOutOfRange(ast::IntTy::Isize) => "literal out of range for isize",
} }
} }
} }

View File

@ -12,8 +12,8 @@ use std::cmp::Ordering;
use syntax::attr::IntType; use syntax::attr::IntType;
use syntax::ast::{IntTy, UintTy}; use syntax::ast::{IntTy, UintTy};
use super::is::*; use super::isize::*;
use super::us::*; use super::usize::*;
use super::err::*; use super::err::*;
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, Hash, Eq, PartialEq)] #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, Hash, Eq, PartialEq)]
@ -83,7 +83,7 @@ impl ConstInt {
UintTy::U16 if val <= ubounds::U16MAX => Some(U16(val as u16)), UintTy::U16 if val <= ubounds::U16MAX => Some(U16(val as u16)),
UintTy::U32 if val <= ubounds::U32MAX => Some(U32(val as u32)), UintTy::U32 if val <= ubounds::U32MAX => Some(U32(val as u32)),
UintTy::U64 if val <= ubounds::U64MAX => Some(U64(val as u64)), UintTy::U64 if val <= ubounds::U64MAX => Some(U64(val as u64)),
UintTy::Us if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok() UintTy::Usize if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok()
.map(Usize), .map(Usize),
UintTy::U128 => Some(U128(val)), UintTy::U128 => Some(U128(val)),
_ => None _ => None
@ -98,7 +98,7 @@ impl ConstInt {
IntTy::I16 if val <= ibounds::I16MAX => Some(I16(val as i16)), IntTy::I16 if val <= ibounds::I16MAX => Some(I16(val as i16)),
IntTy::I32 if val <= ibounds::I32MAX => Some(I32(val as i32)), IntTy::I32 if val <= ibounds::I32MAX => Some(I32(val as i32)),
IntTy::I64 if val <= ibounds::I64MAX => Some(I64(val as i64)), IntTy::I64 if val <= ibounds::I64MAX => Some(I64(val as i64)),
IntTy::Is if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok() IntTy::Isize if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok()
.map(Isize), .map(Isize),
IntTy::I128 => Some(I128(val)), IntTy::I128 => Some(I128(val)),
_ => None _ => None
@ -112,7 +112,7 @@ impl ConstInt {
UintTy::U16 => U16(val as u16), UintTy::U16 => U16(val as u16),
UintTy::U32 => U32(val as u32), UintTy::U32 => U32(val as u32),
UintTy::U64 => U64(val as u64), UintTy::U64 => U64(val as u64),
UintTy::Us => Usize(ConstUsize::new_truncating(val, usize_ty)), UintTy::Usize => Usize(ConstUsize::new_truncating(val, usize_ty)),
UintTy::U128 => U128(val) UintTy::U128 => U128(val)
} }
} }
@ -124,7 +124,7 @@ impl ConstInt {
IntTy::I16 => I16(val as i16), IntTy::I16 => I16(val as i16),
IntTy::I32 => I32(val as i32), IntTy::I32 => I32(val as i32),
IntTy::I64 => I64(val as i64), IntTy::I64 => I64(val as i64),
IntTy::Is => Isize(ConstIsize::new_truncating(val, isize_ty)), IntTy::Isize => Isize(ConstIsize::new_truncating(val, isize_ty)),
IntTy::I128 => I128(val) IntTy::I128 => I128(val)
} }
} }
@ -280,13 +280,13 @@ impl ConstInt {
ConstInt::I32(_) => IntType::SignedInt(IntTy::I32), ConstInt::I32(_) => IntType::SignedInt(IntTy::I32),
ConstInt::I64(_) => IntType::SignedInt(IntTy::I64), ConstInt::I64(_) => IntType::SignedInt(IntTy::I64),
ConstInt::I128(_) => IntType::SignedInt(IntTy::I128), ConstInt::I128(_) => IntType::SignedInt(IntTy::I128),
ConstInt::Isize(_) => IntType::SignedInt(IntTy::Is), ConstInt::Isize(_) => IntType::SignedInt(IntTy::Isize),
ConstInt::U8(_) => IntType::UnsignedInt(UintTy::U8), ConstInt::U8(_) => IntType::UnsignedInt(UintTy::U8),
ConstInt::U16(_) => IntType::UnsignedInt(UintTy::U16), ConstInt::U16(_) => IntType::UnsignedInt(UintTy::U16),
ConstInt::U32(_) => IntType::UnsignedInt(UintTy::U32), ConstInt::U32(_) => IntType::UnsignedInt(UintTy::U32),
ConstInt::U64(_) => IntType::UnsignedInt(UintTy::U64), ConstInt::U64(_) => IntType::UnsignedInt(UintTy::U64),
ConstInt::U128(_) => IntType::UnsignedInt(UintTy::U128), ConstInt::U128(_) => IntType::UnsignedInt(UintTy::U128),
ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Us), ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Usize),
} }
} }
} }

View File

@ -38,9 +38,9 @@ impl ConstIsize {
pub fn new(i: i64, isize_ty: ast::IntTy) -> Result<Self, ConstMathErr> { pub fn new(i: i64, isize_ty: ast::IntTy) -> Result<Self, ConstMathErr> {
match isize_ty { match isize_ty {
ast::IntTy::I16 if i as i16 as i64 == i => Ok(Is16(i as i16)), ast::IntTy::I16 if i as i16 as i64 == i => Ok(Is16(i as i16)),
ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Is)), ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Isize)),
ast::IntTy::I32 if i as i32 as i64 == i => Ok(Is32(i as i32)), ast::IntTy::I32 if i as i32 as i64 == i => Ok(Is32(i as i32)),
ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Is)), ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Isize)),
ast::IntTy::I64 => Ok(Is64(i)), ast::IntTy::I64 => Ok(Is64(i)),
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -30,12 +30,12 @@ extern crate serialize as rustc_serialize; // used by deriving
mod float; mod float;
mod int; mod int;
mod us; mod usize;
mod is; mod isize;
mod err; mod err;
pub use float::*; pub use float::*;
pub use int::*; pub use int::*;
pub use us::*; pub use usize::*;
pub use is::*; pub use isize::*;
pub use err::{ConstMathErr, Op}; pub use err::{ConstMathErr, Op};

View File

@ -38,9 +38,9 @@ impl ConstUsize {
pub fn new(i: u64, usize_ty: ast::UintTy) -> Result<Self, ConstMathErr> { pub fn new(i: u64, usize_ty: ast::UintTy) -> Result<Self, ConstMathErr> {
match usize_ty { match usize_ty {
ast::UintTy::U16 if i as u16 as u64 == i => Ok(Us16(i as u16)), ast::UintTy::U16 if i as u16 as u64 == i => Ok(Us16(i as u16)),
ast::UintTy::U16 => Err(ULitOutOfRange(ast::UintTy::Us)), ast::UintTy::U16 => Err(ULitOutOfRange(ast::UintTy::Usize)),
ast::UintTy::U32 if i as u32 as u64 == i => Ok(Us32(i as u32)), ast::UintTy::U32 if i as u32 as u64 == i => Ok(Us32(i as u32)),
ast::UintTy::U32 => Err(ULitOutOfRange(ast::UintTy::Us)), ast::UintTy::U32 => Err(ULitOutOfRange(ast::UintTy::Usize)),
ast::UintTy::U64 => Ok(Us64(i)), ast::UintTy::U64 => Ok(Us64(i)),
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -140,7 +140,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
match lit.node { match lit.node {
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => { ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => {
let int_type = if let ast::IntTy::Is = t { let int_type = if let ast::IntTy::Isize = t {
cx.sess().target.isize_ty cx.sess().target.isize_ty
} else { } else {
t t
@ -163,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
}; };
} }
ty::TyUint(t) => { ty::TyUint(t) => {
let uint_type = if let ast::UintTy::Us = t { let uint_type = if let ast::UintTy::Usize = t {
cx.sess().target.usize_ty cx.sess().target.usize_ty
} else { } else {
t t
@ -230,7 +230,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
// warnings are consistent between 32- and 64-bit platforms // warnings are consistent between 32- and 64-bit platforms
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) { fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
match int_ty { match int_ty {
ast::IntTy::Is => (i64::min_value() as i128, i64::max_value() as i128), ast::IntTy::Isize => (i64::min_value() as i128, i64::max_value() as i128),
ast::IntTy::I8 => (i8::min_value() as i64 as i128, i8::max_value() as i128), ast::IntTy::I8 => (i8::min_value() as i64 as i128, i8::max_value() as i128),
ast::IntTy::I16 => (i16::min_value() as i64 as i128, i16::max_value() as i128), ast::IntTy::I16 => (i16::min_value() as i64 as i128, i16::max_value() as i128),
ast::IntTy::I32 => (i32::min_value() as i64 as i128, i32::max_value() as i128), ast::IntTy::I32 => (i32::min_value() as i64 as i128, i32::max_value() as i128),
@ -241,7 +241,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) { fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
match uint_ty { match uint_ty {
ast::UintTy::Us => (u64::min_value() as u128, u64::max_value() as u128), ast::UintTy::Usize => (u64::min_value() as u128, u64::max_value() as u128),
ast::UintTy::U8 => (u8::min_value() as u128, u8::max_value() as u128), ast::UintTy::U8 => (u8::min_value() as u128, u8::max_value() as u128),
ast::UintTy::U16 => (u16::min_value() as u128, u16::max_value() as u128), ast::UintTy::U16 => (u16::min_value() as u128, u16::max_value() as u128),
ast::UintTy::U32 => (u32::min_value() as u128, u32::max_value() as u128), ast::UintTy::U32 => (u32::min_value() as u128, u32::max_value() as u128),
@ -252,7 +252,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn int_ty_bits(int_ty: ast::IntTy, isize_ty: ast::IntTy) -> u64 { fn int_ty_bits(int_ty: ast::IntTy, isize_ty: ast::IntTy) -> u64 {
match int_ty { match int_ty {
ast::IntTy::Is => int_ty_bits(isize_ty, isize_ty), ast::IntTy::Isize => int_ty_bits(isize_ty, isize_ty),
ast::IntTy::I8 => 8, ast::IntTy::I8 => 8,
ast::IntTy::I16 => 16 as u64, ast::IntTy::I16 => 16 as u64,
ast::IntTy::I32 => 32, ast::IntTy::I32 => 32,
@ -263,7 +263,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn uint_ty_bits(uint_ty: ast::UintTy, usize_ty: ast::UintTy) -> u64 { fn uint_ty_bits(uint_ty: ast::UintTy, usize_ty: ast::UintTy) -> u64 {
match uint_ty { match uint_ty {
ast::UintTy::Us => uint_ty_bits(usize_ty, usize_ty), ast::UintTy::Usize => uint_ty_bits(usize_ty, usize_ty),
ast::UintTy::U8 => 8, ast::UintTy::U8 => 8,
ast::UintTy::U16 => 16, ast::UintTy::U16 => 16,
ast::UintTy::U32 => 32, ast::UintTy::U32 => 32,
@ -387,7 +387,7 @@ fn is_ffi_safe(ty: attr::IntType) -> bool {
attr::SignedInt(ast::IntTy::I32) | attr::UnsignedInt(ast::UintTy::U32) | attr::SignedInt(ast::IntTy::I32) | attr::UnsignedInt(ast::UintTy::U32) |
attr::SignedInt(ast::IntTy::I64) | attr::UnsignedInt(ast::UintTy::U64) | attr::SignedInt(ast::IntTy::I64) | attr::UnsignedInt(ast::UintTy::U64) |
attr::SignedInt(ast::IntTy::I128) | attr::UnsignedInt(ast::UintTy::U128) => true, attr::SignedInt(ast::IntTy::I128) | attr::UnsignedInt(ast::UintTy::U128) => true,
attr::SignedInt(ast::IntTy::Is) | attr::UnsignedInt(ast::UintTy::Us) => false attr::SignedInt(ast::IntTy::Isize) | attr::UnsignedInt(ast::UintTy::Usize) => false
} }
} }

View File

@ -392,7 +392,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
ast::IntTy::I32 => ConstInt::I32(-1), ast::IntTy::I32 => ConstInt::I32(-1),
ast::IntTy::I64 => ConstInt::I64(-1), ast::IntTy::I64 => ConstInt::I64(-1),
ast::IntTy::I128 => ConstInt::I128(-1), ast::IntTy::I128 => ConstInt::I128(-1),
ast::IntTy::Is => { ast::IntTy::Isize => {
let int_ty = self.hir.tcx().sess.target.isize_ty; let int_ty = self.hir.tcx().sess.target.isize_ty;
let val = ConstIsize::new(-1, int_ty).unwrap(); let val = ConstIsize::new(-1, int_ty).unwrap();
ConstInt::Isize(val) ConstInt::Isize(val)
@ -424,7 +424,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
ast::IntTy::I32 => ConstInt::I32(i32::min_value()), ast::IntTy::I32 => ConstInt::I32(i32::min_value()),
ast::IntTy::I64 => ConstInt::I64(i64::min_value()), ast::IntTy::I64 => ConstInt::I64(i64::min_value()),
ast::IntTy::I128 => ConstInt::I128(i128::min_value()), ast::IntTy::I128 => ConstInt::I128(i128::min_value()),
ast::IntTy::Is => { ast::IntTy::Isize => {
let int_ty = self.hir.tcx().sess.target.isize_ty; let int_ty = self.hir.tcx().sess.target.isize_ty;
let min = match int_ty { let min = match int_ty {
ast::IntTy::I16 => std::i16::MIN as i64, ast::IntTy::I16 => std::i16::MIN as i64,

View File

@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
ast::UintTy::U32 => ConstInt::U32(0), ast::UintTy::U32 => ConstInt::U32(0),
ast::UintTy::U64 => ConstInt::U64(0), ast::UintTy::U64 => ConstInt::U64(0),
ast::UintTy::U128 => ConstInt::U128(0), ast::UintTy::U128 => ConstInt::U128(0),
ast::UintTy::Us => { ast::UintTy::Usize => {
let uint_ty = self.hir.tcx().sess.target.usize_ty; let uint_ty = self.hir.tcx().sess.target.usize_ty;
let val = ConstUsize::new(0, uint_ty).unwrap(); let val = ConstUsize::new(0, uint_ty).unwrap();
ConstInt::Usize(val) ConstInt::Usize(val)
@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
ast::IntTy::I32 => ConstInt::I32(0), ast::IntTy::I32 => ConstInt::I32(0),
ast::IntTy::I64 => ConstInt::I64(0), ast::IntTy::I64 => ConstInt::I64(0),
ast::IntTy::I128 => ConstInt::I128(0), ast::IntTy::I128 => ConstInt::I128(0),
ast::IntTy::Is => { ast::IntTy::Isize => {
let int_ty = self.hir.tcx().sess.target.isize_ty; let int_ty = self.hir.tcx().sess.target.isize_ty;
let val = ConstIsize::new(0, int_ty).unwrap(); let val = ConstIsize::new(0, int_ty).unwrap();
ConstInt::Isize(val) ConstInt::Isize(val)

View File

@ -49,7 +49,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
IntTy::I32 => v as i32 as u128, IntTy::I32 => v as i32 as u128,
IntTy::I64 => v as i64 as u128, IntTy::I64 => v as i64 as u128,
IntTy::I128 => v as u128, IntTy::I128 => v as u128,
IntTy::Is => { IntTy::Isize => {
let ty = self.tcx.sess.target.isize_ty; let ty = self.tcx.sess.target.isize_ty;
self.int_to_int(v, ty) self.int_to_int(v, ty)
} }
@ -62,7 +62,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
UintTy::U32 => v as u32 as u128, UintTy::U32 => v as u32 as u128,
UintTy::U64 => v as u64 as u128, UintTy::U64 => v as u64 as u128,
UintTy::U128 => v, UintTy::U128 => v,
UintTy::Us => { UintTy::Usize => {
let ty = self.tcx.sess.target.usize_ty; let ty = self.tcx.sess.target.usize_ty;
self.int_to_uint(v, ty) self.int_to_uint(v, ty)
} }
@ -124,8 +124,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
match ty.sty { match ty.sty {
// Casting to a reference or fn pointer is not permitted by rustc, no need to support it here. // Casting to a reference or fn pointer is not permitted by rustc, no need to support it here.
TyRawPtr(_) | TyRawPtr(_) |
TyInt(IntTy::Is) | TyInt(IntTy::Isize) |
TyUint(UintTy::Us) => Ok(PrimVal::Ptr(ptr)), TyUint(UintTy::Usize) => Ok(PrimVal::Ptr(ptr)),
TyInt(_) | TyUint(_) => err!(ReadPointerAsBytes), TyInt(_) | TyUint(_) => err!(ReadPointerAsBytes),
_ => err!(Unimplemented(format!("ptr to {:?} cast", ty))), _ => err!(Unimplemented(format!("ptr to {:?} cast", ty))),
} }

View File

@ -106,7 +106,7 @@ pub fn eval_body_as_integer<'a, 'tcx>(
TyInt(IntTy::I32) => ConstInt::I32(prim as i128 as i32), TyInt(IntTy::I32) => ConstInt::I32(prim as i128 as i32),
TyInt(IntTy::I64) => ConstInt::I64(prim as i128 as i64), TyInt(IntTy::I64) => ConstInt::I64(prim as i128 as i64),
TyInt(IntTy::I128) => ConstInt::I128(prim as i128), TyInt(IntTy::I128) => ConstInt::I128(prim as i128),
TyInt(IntTy::Is) => ConstInt::Isize( TyInt(IntTy::Isize) => ConstInt::Isize(
ConstIsize::new(prim as i128 as i64, tcx.sess.target.isize_ty) ConstIsize::new(prim as i128 as i64, tcx.sess.target.isize_ty)
.expect("miri should already have errored"), .expect("miri should already have errored"),
), ),
@ -115,7 +115,7 @@ pub fn eval_body_as_integer<'a, 'tcx>(
TyUint(UintTy::U32) => ConstInt::U32(prim as u32), TyUint(UintTy::U32) => ConstInt::U32(prim as u32),
TyUint(UintTy::U64) => ConstInt::U64(prim as u64), TyUint(UintTy::U64) => ConstInt::U64(prim as u64),
TyUint(UintTy::U128) => ConstInt::U128(prim), TyUint(UintTy::U128) => ConstInt::U128(prim),
TyUint(UintTy::Us) => ConstInt::Usize( TyUint(UintTy::Usize) => ConstInt::Usize(
ConstUsize::new(prim as u64, tcx.sess.target.usize_ty) ConstUsize::new(prim as u64, tcx.sess.target.usize_ty)
.expect("miri should already have errored"), .expect("miri should already have errored"),
), ),

View File

@ -1165,7 +1165,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
I32 => 4, I32 => 4,
I64 => 8, I64 => 8,
I128 => 16, I128 => 16,
Is => self.memory.pointer_size(), Isize => self.memory.pointer_size(),
}; };
PrimValKind::from_int_size(size) PrimValKind::from_int_size(size)
} }
@ -1178,7 +1178,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
U32 => 4, U32 => 4,
U64 => 8, U64 => 8,
U128 => 16, U128 => 16,
Us => self.memory.pointer_size(), Usize => self.memory.pointer_size(),
}; };
PrimValKind::from_uint_size(size) PrimValKind::from_uint_size(size)
} }
@ -1292,7 +1292,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
I32 => 4, I32 => 4,
I64 => 8, I64 => 8,
I128 => 16, I128 => 16,
Is => self.memory.pointer_size(), Isize => self.memory.pointer_size(),
}; };
self.memory.read_primval(ptr, ptr_align, size, true)? self.memory.read_primval(ptr, ptr_align, size, true)?
} }
@ -1305,7 +1305,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
U32 => 4, U32 => 4,
U64 => 8, U64 => 8,
U128 => 16, U128 => 16,
Us => self.memory.pointer_size(), Usize => self.memory.pointer_size(),
}; };
self.memory.read_primval(ptr, ptr_align, size, false)? self.memory.read_primval(ptr, ptr_align, size, false)?
} }

View File

@ -292,13 +292,13 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
ty::TyChar => output.push_str("char"), ty::TyChar => output.push_str("char"),
ty::TyStr => output.push_str("str"), ty::TyStr => output.push_str("str"),
ty::TyNever => output.push_str("!"), ty::TyNever => output.push_str("!"),
ty::TyInt(ast::IntTy::Is) => output.push_str("isize"), ty::TyInt(ast::IntTy::Isize) => output.push_str("isize"),
ty::TyInt(ast::IntTy::I8) => output.push_str("i8"), ty::TyInt(ast::IntTy::I8) => output.push_str("i8"),
ty::TyInt(ast::IntTy::I16) => output.push_str("i16"), ty::TyInt(ast::IntTy::I16) => output.push_str("i16"),
ty::TyInt(ast::IntTy::I32) => output.push_str("i32"), ty::TyInt(ast::IntTy::I32) => output.push_str("i32"),
ty::TyInt(ast::IntTy::I64) => output.push_str("i64"), ty::TyInt(ast::IntTy::I64) => output.push_str("i64"),
ty::TyInt(ast::IntTy::I128) => output.push_str("i128"), ty::TyInt(ast::IntTy::I128) => output.push_str("i128"),
ty::TyUint(ast::UintTy::Us) => output.push_str("usize"), ty::TyUint(ast::UintTy::Usize) => output.push_str("usize"),
ty::TyUint(ast::UintTy::U8) => output.push_str("u8"), ty::TyUint(ast::UintTy::U8) => output.push_str("u8"),
ty::TyUint(ast::UintTy::U16) => output.push_str("u16"), ty::TyUint(ast::UintTy::U16) => output.push_str("u16"),
ty::TyUint(ast::UintTy::U32) => output.push_str("u32"), ty::TyUint(ast::UintTy::U32) => output.push_str("u32"),

View File

@ -1204,14 +1204,14 @@ impl PrimitiveTypeTable {
table.intern("char", TyChar); table.intern("char", TyChar);
table.intern("f32", TyFloat(FloatTy::F32)); table.intern("f32", TyFloat(FloatTy::F32));
table.intern("f64", TyFloat(FloatTy::F64)); table.intern("f64", TyFloat(FloatTy::F64));
table.intern("isize", TyInt(IntTy::Is)); table.intern("isize", TyInt(IntTy::Isize));
table.intern("i8", TyInt(IntTy::I8)); table.intern("i8", TyInt(IntTy::I8));
table.intern("i16", TyInt(IntTy::I16)); table.intern("i16", TyInt(IntTy::I16));
table.intern("i32", TyInt(IntTy::I32)); table.intern("i32", TyInt(IntTy::I32));
table.intern("i64", TyInt(IntTy::I64)); table.intern("i64", TyInt(IntTy::I64));
table.intern("i128", TyInt(IntTy::I128)); table.intern("i128", TyInt(IntTy::I128));
table.intern("str", TyStr); table.intern("str", TyStr);
table.intern("usize", TyUint(UintTy::Us)); table.intern("usize", TyUint(UintTy::Usize));
table.intern("u8", TyUint(UintTy::U8)); table.intern("u8", TyUint(UintTy::U8));
table.intern("u16", TyUint(UintTy::U16)); table.intern("u16", TyUint(UintTy::U16));
table.intern("u32", TyUint(UintTy::U32)); table.intern("u32", TyUint(UintTy::U32));

View File

@ -1246,7 +1246,7 @@ fn generic_simd_intrinsic<'a, 'tcx>(
fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> { fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> {
match ty.sty { match ty.sty {
ty::TyInt(t) => Some((match t { ty::TyInt(t) => Some((match t {
ast::IntTy::Is => { ast::IntTy::Isize => {
match &ccx.tcx().sess.target.target.target_pointer_width[..] { match &ccx.tcx().sess.target.target.target_pointer_width[..] {
"16" => 16, "16" => 16,
"32" => 32, "32" => 32,
@ -1261,7 +1261,7 @@ fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> {
ast::IntTy::I128 => 128, ast::IntTy::I128 => 128,
}, true)), }, true)),
ty::TyUint(t) => Some((match t { ty::TyUint(t) => Some((match t {
ast::UintTy::Us => { ast::UintTy::Usize => {
match &ccx.tcx().sess.target.target.target_pointer_width[..] { match &ccx.tcx().sess.target.target.target_pointer_width[..] {
"16" => 16, "16" => 16,
"32" => 32, "32" => 32,

View File

@ -720,13 +720,13 @@ fn get_overflow_intrinsic(oop: OverflowOp, bcx: &Builder, ty: Ty) -> ValueRef {
let tcx = bcx.tcx(); let tcx = bcx.tcx();
let new_sty = match ty.sty { let new_sty = match ty.sty {
TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] { TyInt(Isize) => match &tcx.sess.target.target.target_pointer_width[..] {
"16" => TyInt(I16), "16" => TyInt(I16),
"32" => TyInt(I32), "32" => TyInt(I32),
"64" => TyInt(I64), "64" => TyInt(I64),
_ => panic!("unsupported target word size") _ => panic!("unsupported target word size")
}, },
TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] { TyUint(Usize) => match &tcx.sess.target.target.target_pointer_width[..] {
"16" => TyUint(U16), "16" => TyUint(U16),
"32" => TyUint(U32), "32" => TyUint(U32),
"64" => TyUint(U64), "64" => TyUint(U64),

View File

@ -147,7 +147,7 @@ impl Type {
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type { pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
match t { match t {
ast::IntTy::Is => ccx.isize_ty(), ast::IntTy::Isize => ccx.isize_ty(),
ast::IntTy::I8 => Type::i8(ccx), ast::IntTy::I8 => Type::i8(ccx),
ast::IntTy::I16 => Type::i16(ccx), ast::IntTy::I16 => Type::i16(ccx),
ast::IntTy::I32 => Type::i32(ccx), ast::IntTy::I32 => Type::i32(ccx),
@ -158,7 +158,7 @@ impl Type {
pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type { pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
match t { match t {
ast::UintTy::Us => ccx.isize_ty(), ast::UintTy::Usize => ccx.isize_ty(),
ast::UintTy::U8 => Type::i8(ccx), ast::UintTy::U8 => Type::i8(ccx),
ast::UintTy::U16 => Type::i16(ccx), ast::UintTy::U16 => Type::i16(ccx),
ast::UintTy::U32 => Type::i32(ccx), ast::UintTy::U32 => Type::i32(ccx),

View File

@ -233,7 +233,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
CastError::NeedViaPtr => { CastError::NeedViaPtr => {
let mut err = make_invalid_casting_error(fcx.tcx.sess, self.span, self.expr_ty, let mut err = make_invalid_casting_error(fcx.tcx.sess, self.span, self.expr_ty,
self.cast_ty, fcx); self.cast_ty, fcx);
if self.cast_ty.is_uint() { if self.cast_ty.is_integral() {
err.help(&format!("cast through {} first", err.help(&format!("cast through {} first",
match e { match e {
CastError::NeedViaPtr => "a raw pointer", CastError::NeedViaPtr => "a raw pointer",

View File

@ -494,7 +494,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
let lang_def_id = lang_items.i128_impl(); let lang_def_id = lang_items.i128_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id); self.assemble_inherent_impl_for_primitive(lang_def_id);
} }
ty::TyInt(ast::IntTy::Is) => { ty::TyInt(ast::IntTy::Isize) => {
let lang_def_id = lang_items.isize_impl(); let lang_def_id = lang_items.isize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id); self.assemble_inherent_impl_for_primitive(lang_def_id);
} }
@ -518,7 +518,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
let lang_def_id = lang_items.u128_impl(); let lang_def_id = lang_items.u128_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id); self.assemble_inherent_impl_for_primitive(lang_def_id);
} }
ty::TyUint(ast::UintTy::Us) => { ty::TyUint(ast::UintTy::Usize) => {
let lang_def_id = lang_items.usize_impl(); let lang_def_id = lang_items.usize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id); self.assemble_inherent_impl_for_primitive(lang_def_id);
} }

View File

@ -2219,7 +2219,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// First, try built-in indexing. // First, try built-in indexing.
match (adjusted_ty.builtin_index(), &index_ty.sty) { match (adjusted_ty.builtin_index(), &index_ty.sty) {
(Some(ty), &ty::TyUint(ast::UintTy::Us)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => { (Some(ty), &ty::TyUint(ast::UintTy::Usize)) |
(Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
debug!("try_index_step: success, using built-in indexing"); debug!("try_index_step: success, using built-in indexing");
let adjustments = autoderef.adjust_steps(lvalue_pref); let adjustments = autoderef.adjust_steps(lvalue_pref);
self.apply_adjustments(base_expr, adjustments); self.apply_adjustments(base_expr, adjustments);

View File

@ -200,7 +200,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
"i128", "i128",
item.span); item.span);
} }
ty::TyInt(ast::IntTy::Is) => { ty::TyInt(ast::IntTy::Isize) => {
self.check_primitive_impl(def_id, self.check_primitive_impl(def_id,
lang_items.isize_impl(), lang_items.isize_impl(),
"isize", "isize",
@ -242,7 +242,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
"u128", "u128",
item.span); item.span);
} }
ty::TyUint(ast::UintTy::Us) => { ty::TyUint(ast::UintTy::Usize) => {
self.check_primitive_impl(def_id, self.check_primitive_impl(def_id,
lang_items.usize_impl(), lang_items.usize_impl(),
"usize", "usize",

View File

@ -2011,7 +2011,7 @@ impl PrimitiveType {
impl From<ast::IntTy> for PrimitiveType { impl From<ast::IntTy> for PrimitiveType {
fn from(int_ty: ast::IntTy) -> PrimitiveType { fn from(int_ty: ast::IntTy) -> PrimitiveType {
match int_ty { match int_ty {
ast::IntTy::Is => PrimitiveType::Isize, ast::IntTy::Isize => PrimitiveType::Isize,
ast::IntTy::I8 => PrimitiveType::I8, ast::IntTy::I8 => PrimitiveType::I8,
ast::IntTy::I16 => PrimitiveType::I16, ast::IntTy::I16 => PrimitiveType::I16,
ast::IntTy::I32 => PrimitiveType::I32, ast::IntTy::I32 => PrimitiveType::I32,
@ -2024,7 +2024,7 @@ impl From<ast::IntTy> for PrimitiveType {
impl From<ast::UintTy> for PrimitiveType { impl From<ast::UintTy> for PrimitiveType {
fn from(uint_ty: ast::UintTy) -> PrimitiveType { fn from(uint_ty: ast::UintTy) -> PrimitiveType {
match uint_ty { match uint_ty {
ast::UintTy::Us => PrimitiveType::Usize, ast::UintTy::Usize => PrimitiveType::Usize,
ast::UintTy::U8 => PrimitiveType::U8, ast::UintTy::U8 => PrimitiveType::U8,
ast::UintTy::U16 => PrimitiveType::U16, ast::UintTy::U16 => PrimitiveType::U16,
ast::UintTy::U32 => PrimitiveType::U32, ast::UintTy::U32 => PrimitiveType::U32,

View File

@ -1324,7 +1324,7 @@ pub enum ImplItemKind {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
PartialOrd, Ord)] PartialOrd, Ord)]
pub enum IntTy { pub enum IntTy {
Is, Isize,
I8, I8,
I16, I16,
I32, I32,
@ -1347,7 +1347,7 @@ impl fmt::Display for IntTy {
impl IntTy { impl IntTy {
pub fn ty_to_string(&self) -> &'static str { pub fn ty_to_string(&self) -> &'static str {
match *self { match *self {
IntTy::Is => "isize", IntTy::Isize => "isize",
IntTy::I8 => "i8", IntTy::I8 => "i8",
IntTy::I16 => "i16", IntTy::I16 => "i16",
IntTy::I32 => "i32", IntTy::I32 => "i32",
@ -1365,7 +1365,7 @@ impl IntTy {
pub fn bit_width(&self) -> Option<usize> { pub fn bit_width(&self) -> Option<usize> {
Some(match *self { Some(match *self {
IntTy::Is => return None, IntTy::Isize => return None,
IntTy::I8 => 8, IntTy::I8 => 8,
IntTy::I16 => 16, IntTy::I16 => 16,
IntTy::I32 => 32, IntTy::I32 => 32,
@ -1378,7 +1378,7 @@ impl IntTy {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
PartialOrd, Ord)] PartialOrd, Ord)]
pub enum UintTy { pub enum UintTy {
Us, Usize,
U8, U8,
U16, U16,
U32, U32,
@ -1389,7 +1389,7 @@ pub enum UintTy {
impl UintTy { impl UintTy {
pub fn ty_to_string(&self) -> &'static str { pub fn ty_to_string(&self) -> &'static str {
match *self { match *self {
UintTy::Us => "usize", UintTy::Usize => "usize",
UintTy::U8 => "u8", UintTy::U8 => "u8",
UintTy::U16 => "u16", UintTy::U16 => "u16",
UintTy::U32 => "u32", UintTy::U32 => "u32",
@ -1404,7 +1404,7 @@ impl UintTy {
pub fn bit_width(&self) -> Option<usize> { pub fn bit_width(&self) -> Option<usize> {
Some(match *self { Some(match *self {
UintTy::Us => return None, UintTy::Usize => return None,
UintTy::U8 => 8, UintTy::U8 => 8,
UintTy::U16 => 16, UintTy::U16 => 16,
UintTy::U32 => 32, UintTy::U32 => 32,

View File

@ -1071,8 +1071,8 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
"u64" => Some(UnsignedInt(ast::UintTy::U64)), "u64" => Some(UnsignedInt(ast::UintTy::U64)),
"i128" => Some(SignedInt(ast::IntTy::I128)), "i128" => Some(SignedInt(ast::IntTy::I128)),
"u128" => Some(UnsignedInt(ast::UintTy::U128)), "u128" => Some(UnsignedInt(ast::UintTy::U128)),
"isize" => Some(SignedInt(ast::IntTy::Is)), "isize" => Some(SignedInt(ast::IntTy::Isize)),
"usize" => Some(UnsignedInt(ast::UintTy::Us)), "usize" => Some(UnsignedInt(ast::UintTy::Usize)),
_ => None _ => None
} }
} }

View File

@ -694,17 +694,17 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
} }
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> { fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
self.expr_lit(span, ast::LitKind::Int(i as u128, self.expr_lit(span, ast::LitKind::Int(i as u128,
ast::LitIntType::Unsigned(ast::UintTy::Us))) ast::LitIntType::Unsigned(ast::UintTy::Usize)))
} }
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> { fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
if i < 0 { if i < 0 {
let i = (-i) as u128; let i = (-i) as u128;
let lit_ty = ast::LitIntType::Signed(ast::IntTy::Is); let lit_ty = ast::LitIntType::Signed(ast::IntTy::Isize);
let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty)); let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty));
self.expr_unary(sp, ast::UnOp::Neg, lit) self.expr_unary(sp, ast::UnOp::Neg, lit)
} else { } else {
self.expr_lit(sp, ast::LitKind::Int(i as u128, self.expr_lit(sp, ast::LitKind::Int(i as u128,
ast::LitIntType::Signed(ast::IntTy::Is))) ast::LitIntType::Signed(ast::IntTy::Isize)))
} }
} }
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> { fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {

View File

@ -326,13 +326,13 @@ pub mod rt {
); );
} }
impl_to_tokens_int! { signed, isize, ast::IntTy::Is } impl_to_tokens_int! { signed, isize, ast::IntTy::Isize }
impl_to_tokens_int! { signed, i8, ast::IntTy::I8 } impl_to_tokens_int! { signed, i8, ast::IntTy::I8 }
impl_to_tokens_int! { signed, i16, ast::IntTy::I16 } impl_to_tokens_int! { signed, i16, ast::IntTy::I16 }
impl_to_tokens_int! { signed, i32, ast::IntTy::I32 } impl_to_tokens_int! { signed, i32, ast::IntTy::I32 }
impl_to_tokens_int! { signed, i64, ast::IntTy::I64 } impl_to_tokens_int! { signed, i64, ast::IntTy::I64 }
impl_to_tokens_int! { unsigned, usize, ast::UintTy::Us } impl_to_tokens_int! { unsigned, usize, ast::UintTy::Usize }
impl_to_tokens_int! { unsigned, u8, ast::UintTy::U8 } impl_to_tokens_int! { unsigned, u8, ast::UintTy::U8 }
impl_to_tokens_int! { unsigned, u16, ast::UintTy::U16 } impl_to_tokens_int! { unsigned, u16, ast::UintTy::U16 }
impl_to_tokens_int! { unsigned, u32, ast::UintTy::U32 } impl_to_tokens_int! { unsigned, u32, ast::UintTy::U32 }

View File

@ -603,13 +603,13 @@ pub fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler
err!(diag, |span, diag| diag.span_bug(span, "found empty literal suffix in Some")); err!(diag, |span, diag| diag.span_bug(span, "found empty literal suffix in Some"));
} }
ty = match &*suf.as_str() { ty = match &*suf.as_str() {
"isize" => ast::LitIntType::Signed(ast::IntTy::Is), "isize" => ast::LitIntType::Signed(ast::IntTy::Isize),
"i8" => ast::LitIntType::Signed(ast::IntTy::I8), "i8" => ast::LitIntType::Signed(ast::IntTy::I8),
"i16" => ast::LitIntType::Signed(ast::IntTy::I16), "i16" => ast::LitIntType::Signed(ast::IntTy::I16),
"i32" => ast::LitIntType::Signed(ast::IntTy::I32), "i32" => ast::LitIntType::Signed(ast::IntTy::I32),
"i64" => ast::LitIntType::Signed(ast::IntTy::I64), "i64" => ast::LitIntType::Signed(ast::IntTy::I64),
"i128" => ast::LitIntType::Signed(ast::IntTy::I128), "i128" => ast::LitIntType::Signed(ast::IntTy::I128),
"usize" => ast::LitIntType::Unsigned(ast::UintTy::Us), "usize" => ast::LitIntType::Unsigned(ast::UintTy::Usize),
"u8" => ast::LitIntType::Unsigned(ast::UintTy::U8), "u8" => ast::LitIntType::Unsigned(ast::UintTy::U8),
"u16" => ast::LitIntType::Unsigned(ast::UintTy::U16), "u16" => ast::LitIntType::Unsigned(ast::UintTy::U16),
"u32" => ast::LitIntType::Unsigned(ast::UintTy::U32), "u32" => ast::LitIntType::Unsigned(ast::UintTy::U32),

View File

@ -833,14 +833,14 @@ fn find_repr_type_name(diagnostic: &Handler, type_attrs: &[ast::Attribute]) -> &
attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue, attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue,
attr::ReprExtern => "i32", attr::ReprExtern => "i32",
attr::ReprInt(attr::SignedInt(ast::IntTy::Is)) => "isize", attr::ReprInt(attr::SignedInt(ast::IntTy::Isize)) => "isize",
attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8", attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8",
attr::ReprInt(attr::SignedInt(ast::IntTy::I16)) => "i16", attr::ReprInt(attr::SignedInt(ast::IntTy::I16)) => "i16",
attr::ReprInt(attr::SignedInt(ast::IntTy::I32)) => "i32", attr::ReprInt(attr::SignedInt(ast::IntTy::I32)) => "i32",
attr::ReprInt(attr::SignedInt(ast::IntTy::I64)) => "i64", attr::ReprInt(attr::SignedInt(ast::IntTy::I64)) => "i64",
attr::ReprInt(attr::SignedInt(ast::IntTy::I128)) => "i128", attr::ReprInt(attr::SignedInt(ast::IntTy::I128)) => "i128",
attr::ReprInt(attr::UnsignedInt(ast::UintTy::Us)) => "usize", attr::ReprInt(attr::UnsignedInt(ast::UintTy::Usize)) => "usize",
attr::ReprInt(attr::UnsignedInt(ast::UintTy::U8)) => "u8", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U8)) => "u8",
attr::ReprInt(attr::UnsignedInt(ast::UintTy::U16)) => "u16", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U16)) => "u16",
attr::ReprInt(attr::UnsignedInt(ast::UintTy::U32)) => "u32", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U32)) => "u32",

View File

@ -11,18 +11,24 @@ error[E0606]: casting `&[i32]` as `isize` is invalid
| |
21 | a as isize; //~ ERROR casting 21 | a as isize; //~ ERROR casting
| ^^^^^^^^^^ | ^^^^^^^^^^
|
= help: cast through a raw pointer first
error[E0606]: casting `&[i32]` as `i16` is invalid error[E0606]: casting `&[i32]` as `i16` is invalid
--> $DIR/fat-ptr-cast.rs:22:5 --> $DIR/fat-ptr-cast.rs:22:5
| |
22 | a as i16; //~ ERROR casting `&[i32]` as `i16` is invalid 22 | a as i16; //~ ERROR casting `&[i32]` as `i16` is invalid
| ^^^^^^^^ | ^^^^^^^^
|
= help: cast through a raw pointer first
error[E0606]: casting `&[i32]` as `u32` is invalid error[E0606]: casting `&[i32]` as `u32` is invalid
--> $DIR/fat-ptr-cast.rs:23:5 --> $DIR/fat-ptr-cast.rs:23:5
| |
23 | a as u32; //~ ERROR casting `&[i32]` as `u32` is invalid 23 | a as u32; //~ ERROR casting `&[i32]` as `u32` is invalid
| ^^^^^^^^ | ^^^^^^^^
|
= help: cast through a raw pointer first
error[E0605]: non-primitive cast: `std::boxed::Box<[i32]>` as `usize` error[E0605]: non-primitive cast: `std::boxed::Box<[i32]>` as `usize`
--> $DIR/fat-ptr-cast.rs:24:5 --> $DIR/fat-ptr-cast.rs:24:5