[breaking-change] don't glob export ast::{UintTy, IntTy} variants

This commit is contained in:
Oliver Schneider 2016-02-08 16:20:57 +01:00
parent ccf48bcd40
commit 625e78b700
33 changed files with 393 additions and 396 deletions

View File

@ -545,34 +545,34 @@ pub enum UintTy { U8, U16, U32, U64 }
impl IntTy {
pub fn from(tcx: &ty::ctxt, t: ast::IntTy) -> IntTy {
let t = if let ast::TyIs = t {
let t = if let ast::IntTy::Is = t {
tcx.sess.target.int_type
} else {
t
};
match t {
ast::TyIs => unreachable!(),
ast::TyI8 => IntTy::I8,
ast::TyI16 => IntTy::I16,
ast::TyI32 => IntTy::I32,
ast::TyI64 => IntTy::I64,
ast::IntTy::Is => unreachable!(),
ast::IntTy::I8 => IntTy::I8,
ast::IntTy::I16 => IntTy::I16,
ast::IntTy::I32 => IntTy::I32,
ast::IntTy::I64 => IntTy::I64,
}
}
}
impl UintTy {
pub fn from(tcx: &ty::ctxt, t: ast::UintTy) -> UintTy {
let t = if let ast::TyUs = t {
let t = if let ast::UintTy::Us = t {
tcx.sess.target.uint_type
} else {
t
};
match t {
ast::TyUs => unreachable!(),
ast::TyU8 => UintTy::U8,
ast::TyU16 => UintTy::U16,
ast::TyU32 => UintTy::U32,
ast::TyU64 => UintTy::U64,
ast::UintTy::Us => unreachable!(),
ast::UintTy::U8 => UintTy::U8,
ast::UintTy::U16 => UintTy::U16,
ast::UintTy::U32 => UintTy::U32,
ast::UintTy::U64 => UintTy::U64,
}
}
}
@ -1289,30 +1289,30 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult {
// Issue #23890: If isize/usize, then dispatch to appropriate target representation type
match (&ty.sty, tcx.sess.target.int_type, tcx.sess.target.uint_type) {
(&ty::TyInt(ast::TyIs), ast::TyI32, _) => return convert_val!(i32, Int, i64),
(&ty::TyInt(ast::TyIs), ast::TyI64, _) => return convert_val!(i64, Int, i64),
(&ty::TyInt(ast::TyIs), _, _) => panic!("unexpected target.int_type"),
(&ty::TyInt(ast::IntTy::Is), ast::IntTy::I32, _) => return convert_val!(i32, Int, i64),
(&ty::TyInt(ast::IntTy::Is), ast::IntTy::I64, _) => return convert_val!(i64, Int, i64),
(&ty::TyInt(ast::IntTy::Is), _, _) => panic!("unexpected target.int_type"),
(&ty::TyUint(ast::TyUs), _, ast::TyU32) => return convert_val!(u32, Uint, u64),
(&ty::TyUint(ast::TyUs), _, ast::TyU64) => return convert_val!(u64, Uint, u64),
(&ty::TyUint(ast::TyUs), _, _) => panic!("unexpected target.uint_type"),
(&ty::TyUint(ast::UintTy::Us), _, ast::UintTy::U32) => return convert_val!(u32, Uint, u64),
(&ty::TyUint(ast::UintTy::Us), _, ast::UintTy::U64) => return convert_val!(u64, Uint, u64),
(&ty::TyUint(ast::UintTy::Us), _, _) => panic!("unexpected target.uint_type"),
_ => {}
}
match ty.sty {
ty::TyInt(ast::TyIs) => unreachable!(),
ty::TyUint(ast::TyUs) => unreachable!(),
ty::TyInt(ast::IntTy::Is) => unreachable!(),
ty::TyUint(ast::UintTy::Us) => unreachable!(),
ty::TyInt(ast::TyI8) => convert_val!(i8, Int, i64),
ty::TyInt(ast::TyI16) => convert_val!(i16, Int, i64),
ty::TyInt(ast::TyI32) => convert_val!(i32, Int, i64),
ty::TyInt(ast::TyI64) => convert_val!(i64, Int, i64),
ty::TyInt(ast::IntTy::I8) => convert_val!(i8, Int, i64),
ty::TyInt(ast::IntTy::I16) => convert_val!(i16, Int, i64),
ty::TyInt(ast::IntTy::I32) => convert_val!(i32, Int, i64),
ty::TyInt(ast::IntTy::I64) => convert_val!(i64, Int, i64),
ty::TyUint(ast::TyU8) => convert_val!(u8, Uint, u64),
ty::TyUint(ast::TyU16) => convert_val!(u16, Uint, u64),
ty::TyUint(ast::TyU32) => convert_val!(u32, Uint, u64),
ty::TyUint(ast::TyU64) => convert_val!(u64, Uint, u64),
ty::TyUint(ast::UintTy::U8) => convert_val!(u8, Uint, u64),
ty::TyUint(ast::UintTy::U16) => convert_val!(u16, Uint, u64),
ty::TyUint(ast::UintTy::U32) => convert_val!(u32, Uint, u64),
ty::TyUint(ast::UintTy::U64) => convert_val!(u64, Uint, u64),
ty::TyFloat(ast::FloatTy::F32) => convert_val!(f32, Float, f64),
ty::TyFloat(ast::FloatTy::F64) => convert_val!(f64, Float, f64),

View File

@ -180,7 +180,7 @@ impl<'tcx> ty::TyS<'tcx> {
let result = match ty.sty {
// usize and isize are ffi-unsafe
ty::TyUint(ast::TyUs) | ty::TyInt(ast::TyIs) => {
ty::TyUint(ast::UintTy::Us) | ty::TyInt(ast::IntTy::Is) => {
TC::None
}

View File

@ -192,16 +192,16 @@ impl<'tcx> CommonTypes<'tcx> {
bool: mk(TyBool),
char: mk(TyChar),
err: mk(TyError),
isize: mk(TyInt(ast::TyIs)),
i8: mk(TyInt(ast::TyI8)),
i16: mk(TyInt(ast::TyI16)),
i32: mk(TyInt(ast::TyI32)),
i64: mk(TyInt(ast::TyI64)),
usize: mk(TyUint(ast::TyUs)),
u8: mk(TyUint(ast::TyU8)),
u16: mk(TyUint(ast::TyU16)),
u32: mk(TyUint(ast::TyU32)),
u64: mk(TyUint(ast::TyU64)),
isize: mk(TyInt(ast::IntTy::Is)),
i8: mk(TyInt(ast::IntTy::I8)),
i16: mk(TyInt(ast::IntTy::I16)),
i32: mk(TyInt(ast::IntTy::I32)),
i64: mk(TyInt(ast::IntTy::I64)),
usize: mk(TyUint(ast::UintTy::Us)),
u8: mk(TyUint(ast::UintTy::U8)),
u16: mk(TyUint(ast::UintTy::U16)),
u32: mk(TyUint(ast::UintTy::U32)),
u64: mk(TyUint(ast::UintTy::U64)),
f32: mk(TyFloat(ast::FloatTy::F32)),
f64: mk(TyFloat(ast::FloatTy::F64)),
}
@ -840,21 +840,21 @@ impl<'tcx> ctxt<'tcx> {
pub fn mk_mach_int(&self, tm: ast::IntTy) -> Ty<'tcx> {
match tm {
ast::TyIs => self.types.isize,
ast::TyI8 => self.types.i8,
ast::TyI16 => self.types.i16,
ast::TyI32 => self.types.i32,
ast::TyI64 => self.types.i64,
ast::IntTy::Is => self.types.isize,
ast::IntTy::I8 => self.types.i8,
ast::IntTy::I16 => self.types.i16,
ast::IntTy::I32 => self.types.i32,
ast::IntTy::I64 => self.types.i64,
}
}
pub fn mk_mach_uint(&self, tm: ast::UintTy) -> Ty<'tcx> {
match tm {
ast::TyUs => self.types.usize,
ast::TyU8 => self.types.u8,
ast::TyU16 => self.types.u16,
ast::TyU32 => self.types.u32,
ast::TyU64 => self.types.u64,
ast::UintTy::Us => self.types.usize,
ast::UintTy::U8 => self.types.u8,
ast::UintTy::U16 => self.types.u16,
ast::UintTy::U32 => self.types.u32,
ast::UintTy::U64 => self.types.u64,
}
}

View File

@ -977,7 +977,7 @@ impl<'tcx> TyS<'tcx> {
pub fn sequence_element_type(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
match self.sty {
TyArray(ty, _) | TySlice(ty) => ty,
TyStr => cx.mk_mach_uint(ast::TyU8),
TyStr => cx.mk_mach_uint(ast::UintTy::U8),
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
self)),
}
@ -1068,7 +1068,7 @@ impl<'tcx> TyS<'tcx> {
pub fn is_uint(&self) -> bool {
match self.sty {
TyInfer(IntVar(_)) | TyUint(ast::TyUs) => true,
TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true,
_ => false
}
}
@ -1114,7 +1114,7 @@ impl<'tcx> TyS<'tcx> {
pub fn is_machine(&self) -> bool {
match self.sty {
TyInt(ast::TyIs) | TyUint(ast::TyUs) => false,
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
TyInt(..) | TyUint(..) | TyFloat(..) => true,
_ => false
}

View File

@ -44,48 +44,48 @@ pub trait IntTypeExt {
impl IntTypeExt for attr::IntType {
fn to_ty<'tcx>(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
match *self {
SignedInt(ast::TyI8) => cx.types.i8,
SignedInt(ast::TyI16) => cx.types.i16,
SignedInt(ast::TyI32) => cx.types.i32,
SignedInt(ast::TyI64) => cx.types.i64,
SignedInt(ast::TyIs) => cx.types.isize,
UnsignedInt(ast::TyU8) => cx.types.u8,
UnsignedInt(ast::TyU16) => cx.types.u16,
UnsignedInt(ast::TyU32) => cx.types.u32,
UnsignedInt(ast::TyU64) => cx.types.u64,
UnsignedInt(ast::TyUs) => cx.types.usize,
SignedInt(ast::IntTy::I8) => cx.types.i8,
SignedInt(ast::IntTy::I16) => cx.types.i16,
SignedInt(ast::IntTy::I32) => cx.types.i32,
SignedInt(ast::IntTy::I64) => cx.types.i64,
SignedInt(ast::IntTy::Is) => cx.types.isize,
UnsignedInt(ast::UintTy::U8) => cx.types.u8,
UnsignedInt(ast::UintTy::U16) => cx.types.u16,
UnsignedInt(ast::UintTy::U32) => cx.types.u32,
UnsignedInt(ast::UintTy::U64) => cx.types.u64,
UnsignedInt(ast::UintTy::Us) => cx.types.usize,
}
}
fn i64_to_disr(&self, val: i64) -> Option<Disr> {
match *self {
SignedInt(ast::TyI8) => val.to_i8() .map(|v| v as Disr),
SignedInt(ast::TyI16) => val.to_i16() .map(|v| v as Disr),
SignedInt(ast::TyI32) => val.to_i32() .map(|v| v as Disr),
SignedInt(ast::TyI64) => val.to_i64() .map(|v| v as Disr),
UnsignedInt(ast::TyU8) => val.to_u8() .map(|v| v as Disr),
UnsignedInt(ast::TyU16) => val.to_u16() .map(|v| v as Disr),
UnsignedInt(ast::TyU32) => val.to_u32() .map(|v| v as Disr),
UnsignedInt(ast::TyU64) => val.to_u64() .map(|v| v as Disr),
SignedInt(ast::IntTy::I8) => val.to_i8() .map(|v| v as Disr),
SignedInt(ast::IntTy::I16) => val.to_i16() .map(|v| v as Disr),
SignedInt(ast::IntTy::I32) => val.to_i32() .map(|v| v as Disr),
SignedInt(ast::IntTy::I64) => val.to_i64() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U8) => val.to_u8() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U16) => val.to_u16() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U32) => val.to_u32() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U64) => val.to_u64() .map(|v| v as Disr),
UnsignedInt(ast::TyUs) |
SignedInt(ast::TyIs) => unreachable!(),
UnsignedInt(ast::UintTy::Us) |
SignedInt(ast::IntTy::Is) => unreachable!(),
}
}
fn u64_to_disr(&self, val: u64) -> Option<Disr> {
match *self {
SignedInt(ast::TyI8) => val.to_i8() .map(|v| v as Disr),
SignedInt(ast::TyI16) => val.to_i16() .map(|v| v as Disr),
SignedInt(ast::TyI32) => val.to_i32() .map(|v| v as Disr),
SignedInt(ast::TyI64) => val.to_i64() .map(|v| v as Disr),
UnsignedInt(ast::TyU8) => val.to_u8() .map(|v| v as Disr),
UnsignedInt(ast::TyU16) => val.to_u16() .map(|v| v as Disr),
UnsignedInt(ast::TyU32) => val.to_u32() .map(|v| v as Disr),
UnsignedInt(ast::TyU64) => val.to_u64() .map(|v| v as Disr),
SignedInt(ast::IntTy::I8) => val.to_i8() .map(|v| v as Disr),
SignedInt(ast::IntTy::I16) => val.to_i16() .map(|v| v as Disr),
SignedInt(ast::IntTy::I32) => val.to_i32() .map(|v| v as Disr),
SignedInt(ast::IntTy::I64) => val.to_i64() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U8) => val.to_u8() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U16) => val.to_u16() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U32) => val.to_u32() .map(|v| v as Disr),
UnsignedInt(ast::UintTy::U64) => val.to_u64() .map(|v| v as Disr),
UnsignedInt(ast::TyUs) |
SignedInt(ast::TyIs) => unreachable!(),
UnsignedInt(ast::UintTy::Us) |
SignedInt(ast::IntTy::Is) => unreachable!(),
}
}
@ -97,18 +97,18 @@ impl IntTypeExt for attr::IntType {
// SignedInt repr means we *want* to reinterpret the bits
// treating the highest bit of Disr as a sign-bit, so
// cast to i64 before range-checking.
SignedInt(ast::TyI8) => add1!((val as i64).to_i8()),
SignedInt(ast::TyI16) => add1!((val as i64).to_i16()),
SignedInt(ast::TyI32) => add1!((val as i64).to_i32()),
SignedInt(ast::TyI64) => add1!(Some(val as i64)),
SignedInt(ast::IntTy::I8) => add1!((val as i64).to_i8()),
SignedInt(ast::IntTy::I16) => add1!((val as i64).to_i16()),
SignedInt(ast::IntTy::I32) => add1!((val as i64).to_i32()),
SignedInt(ast::IntTy::I64) => add1!(Some(val as i64)),
UnsignedInt(ast::TyU8) => add1!(val.to_u8()),
UnsignedInt(ast::TyU16) => add1!(val.to_u16()),
UnsignedInt(ast::TyU32) => add1!(val.to_u32()),
UnsignedInt(ast::TyU64) => add1!(Some(val)),
UnsignedInt(ast::UintTy::U8) => add1!(val.to_u8()),
UnsignedInt(ast::UintTy::U16) => add1!(val.to_u16()),
UnsignedInt(ast::UintTy::U32) => add1!(val.to_u32()),
UnsignedInt(ast::UintTy::U64) => add1!(Some(val)),
UnsignedInt(ast::TyUs) |
SignedInt(ast::TyIs) => unreachable!(),
UnsignedInt(ast::UintTy::Us) |
SignedInt(ast::IntTy::Is) => unreachable!(),
}
}
@ -117,17 +117,17 @@ impl IntTypeExt for attr::IntType {
// full range from `i64::MIN` through `u64::MAX`.
fn disr_string(&self, val: Disr) -> String {
match *self {
SignedInt(ast::TyI8) => format!("{}", val as i8 ),
SignedInt(ast::TyI16) => format!("{}", val as i16),
SignedInt(ast::TyI32) => format!("{}", val as i32),
SignedInt(ast::TyI64) => format!("{}", val as i64),
UnsignedInt(ast::TyU8) => format!("{}", val as u8 ),
UnsignedInt(ast::TyU16) => format!("{}", val as u16),
UnsignedInt(ast::TyU32) => format!("{}", val as u32),
UnsignedInt(ast::TyU64) => format!("{}", val as u64),
SignedInt(ast::IntTy::I8) => format!("{}", val as i8 ),
SignedInt(ast::IntTy::I16) => format!("{}", val as i16),
SignedInt(ast::IntTy::I32) => format!("{}", val as i32),
SignedInt(ast::IntTy::I64) => format!("{}", val as i64),
UnsignedInt(ast::UintTy::U8) => format!("{}", val as u8 ),
UnsignedInt(ast::UintTy::U16) => format!("{}", val as u16),
UnsignedInt(ast::UintTy::U32) => format!("{}", val as u32),
UnsignedInt(ast::UintTy::U64) => format!("{}", val as u64),
UnsignedInt(ast::TyUs) |
SignedInt(ast::TyIs) => unreachable!(),
UnsignedInt(ast::UintTy::Us) |
SignedInt(ast::IntTy::Is) => unreachable!(),
}
}
@ -137,17 +137,17 @@ impl IntTypeExt for attr::IntType {
}
let val = val.unwrap_or(ty::INITIAL_DISCRIMINANT_VALUE);
match *self {
SignedInt(ast::TyI8) => add1!(val as i8 ),
SignedInt(ast::TyI16) => add1!(val as i16),
SignedInt(ast::TyI32) => add1!(val as i32),
SignedInt(ast::TyI64) => add1!(val as i64),
UnsignedInt(ast::TyU8) => add1!(val as u8 ),
UnsignedInt(ast::TyU16) => add1!(val as u16),
UnsignedInt(ast::TyU32) => add1!(val as u32),
UnsignedInt(ast::TyU64) => add1!(val as u64),
SignedInt(ast::IntTy::I8) => add1!(val as i8 ),
SignedInt(ast::IntTy::I16) => add1!(val as i16),
SignedInt(ast::IntTy::I32) => add1!(val as i32),
SignedInt(ast::IntTy::I64) => add1!(val as i64),
UnsignedInt(ast::UintTy::U8) => add1!(val as u8 ),
UnsignedInt(ast::UintTy::U16) => add1!(val as u16),
UnsignedInt(ast::UintTy::U32) => add1!(val as u32),
UnsignedInt(ast::UintTy::U64) => add1!(val as u64),
UnsignedInt(ast::TyUs) |
SignedInt(ast::TyIs) => unreachable!(),
UnsignedInt(ast::UintTy::Us) |
SignedInt(ast::IntTy::Is) => unreachable!(),
}
}
}
@ -279,14 +279,14 @@ impl<'tcx> ty::ctxt<'tcx> {
//
// NB. Historically `fn enum_variants` generate i64 here, while
// rustc_typeck::check would generate isize.
_ => SignedInt(ast::TyIs),
_ => SignedInt(ast::IntTy::Is),
};
let repr_type_ty = repr_type.to_ty(self);
let repr_type = match repr_type {
SignedInt(ast::TyIs) =>
SignedInt(ast::IntTy::Is) =>
SignedInt(self.sess.target.int_type),
UnsignedInt(ast::TyUs) =>
UnsignedInt(ast::UintTy::Us) =>
UnsignedInt(self.sess.target.uint_type),
other => other
};

View File

@ -728,8 +728,8 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
};
let (int_type, uint_type) = match &target.target_pointer_width[..] {
"32" => (ast::TyI32, ast::TyU32),
"64" => (ast::TyI64, ast::TyU64),
"32" => (ast::IntTy::I32, ast::UintTy::U32),
"64" => (ast::IntTy::I64, ast::UintTy::U64),
w => panic!(sp.fatal(&format!("target specification was invalid: \
unrecognized target-pointer-width {}", w))),
};

View File

@ -161,7 +161,7 @@ impl LateLintPass for TypeLimits {
match lit.node {
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
let int_type = if let ast::TyIs = t {
let int_type = if let ast::IntTy::Is = t {
cx.sess().target.int_type
} else {
t
@ -182,7 +182,7 @@ impl LateLintPass for TypeLimits {
};
},
ty::TyUint(t) => {
let uint_type = if let ast::TyUs = t {
let uint_type = if let ast::UintTy::Us = t {
cx.sess().target.uint_type
} else {
t
@ -247,21 +247,21 @@ impl LateLintPass 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::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),
ast::TyI64 => (i64::MIN, i64::MAX)
ast::IntTy::Is => (i64::MIN, i64::MAX),
ast::IntTy::I8 => (i8::MIN as i64, i8::MAX as i64),
ast::IntTy::I16 => (i16::MIN as i64, i16::MAX as i64),
ast::IntTy::I32 => (i32::MIN as i64, i32::MAX as i64),
ast::IntTy::I64 => (i64::MIN, i64::MAX)
}
}
fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
match uint_ty {
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),
ast::TyU64 => (u64::MIN, u64::MAX)
ast::UintTy::Us => (u64::MIN, u64::MAX),
ast::UintTy::U8 => (u8::MIN as u64, u8::MAX as u64),
ast::UintTy::U16 => (u16::MIN as u64, u16::MAX as u64),
ast::UintTy::U32 => (u32::MIN as u64, u32::MAX as u64),
ast::UintTy::U64 => (u64::MIN, u64::MAX)
}
}
@ -274,21 +274,21 @@ impl LateLintPass 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::TyI8 => 8,
ast::TyI16 => 16 as u64,
ast::TyI32 => 32,
ast::TyI64 => 64,
ast::IntTy::Is => int_ty_bits(target_int_ty, target_int_ty),
ast::IntTy::I8 => 8,
ast::IntTy::I16 => 16 as u64,
ast::IntTy::I32 => 32,
ast::IntTy::I64 => 64,
}
}
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::TyU8 => 8,
ast::TyU16 => 16,
ast::TyU32 => 32,
ast::TyU64 => 64,
ast::UintTy::Us => uint_ty_bits(target_uint_ty, target_uint_ty),
ast::UintTy::U8 => 8,
ast::UintTy::U16 => 16,
ast::UintTy::U32 => 32,
ast::UintTy::U64 => 64,
}
}

View File

@ -76,20 +76,20 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor<Vec<u8>>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx
ty::TyChar => { write!(w, "c"); }
ty::TyInt(t) => {
match t {
ast::TyIs => write!(w, "is"),
ast::TyI8 => write!(w, "MB"),
ast::TyI16 => write!(w, "MW"),
ast::TyI32 => write!(w, "ML"),
ast::TyI64 => write!(w, "MD")
ast::IntTy::Is => write!(w, "is"),
ast::IntTy::I8 => write!(w, "MB"),
ast::IntTy::I16 => write!(w, "MW"),
ast::IntTy::I32 => write!(w, "ML"),
ast::IntTy::I64 => write!(w, "MD")
};
}
ty::TyUint(t) => {
match t {
ast::TyUs => write!(w, "us"),
ast::TyU8 => write!(w, "Mb"),
ast::TyU16 => write!(w, "Mw"),
ast::TyU32 => write!(w, "Ml"),
ast::TyU64 => write!(w, "Md")
ast::UintTy::Us => write!(w, "us"),
ast::UintTy::U8 => write!(w, "Mb"),
ast::UintTy::U16 => write!(w, "Mw"),
ast::UintTy::U32 => write!(w, "Ml"),
ast::UintTy::U64 => write!(w, "Md")
};
}
ty::TyFloat(t) => {

View File

@ -61,8 +61,7 @@ use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap};
use rustc::util::nodemap::{NodeMap, DefIdSet, FnvHashMap};
use syntax::ast::{self, FloatTy};
use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, TyIs, TyI8, TyI16, TyI32, TyI64};
use syntax::ast::{TyUs, TyU8, TyU16, TyU32, TyU64};
use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, IntTy, UintTy};
use syntax::attr::AttrMetaMethods;
use syntax::codemap::{self, Span, Pos};
use syntax::errors::DiagnosticBuilder;
@ -1076,17 +1075,17 @@ impl PrimitiveTypeTable {
table.intern("char", TyChar);
table.intern("f32", TyFloat(FloatTy::F32));
table.intern("f64", TyFloat(FloatTy::F64));
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("isize", TyInt(IntTy::Is));
table.intern("i8", TyInt(IntTy::I8));
table.intern("i16", TyInt(IntTy::I16));
table.intern("i32", TyInt(IntTy::I32));
table.intern("i64", TyInt(IntTy::I64));
table.intern("str", TyStr);
table.intern("usize", TyUint(TyUs));
table.intern("u8", TyUint(TyU8));
table.intern("u16", TyUint(TyU16));
table.intern("u32", TyUint(TyU32));
table.intern("u64", TyUint(TyU64));
table.intern("usize", TyUint(UintTy::Us));
table.intern("u8", TyUint(UintTy::U8));
table.intern("u16", TyUint(UintTy::U16));
table.intern("u32", TyUint(UintTy::U32));
table.intern("u64", TyUint(UintTy::U64));
table
}

View File

@ -921,7 +921,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
}
ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
ty::TyUint(ast::TyU8) => {
ty::TyUint(ast::UintTy::U8) => {
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
// which calls memcmp().
let pat_len = val_ty(rhs).element_type().array_length();

View File

@ -403,11 +403,11 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let ity = if use_align {
// Use the overall alignment
match align {
1 => attr::UnsignedInt(ast::TyU8),
2 => attr::UnsignedInt(ast::TyU16),
4 => attr::UnsignedInt(ast::TyU32),
1 => attr::UnsignedInt(ast::UintTy::U8),
2 => attr::UnsignedInt(ast::UintTy::U16),
4 => attr::UnsignedInt(ast::UintTy::U32),
8 if machine::llalign_of_min(cx, Type::i64(cx)) == 8 =>
attr::UnsignedInt(ast::TyU64),
attr::UnsignedInt(ast::UintTy::U64),
_ => min_ity // use min_ity as a fallback
}
} else {
@ -599,12 +599,12 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
// Lists of sizes to try. u64 is always allowed as a fallback.
#[allow(non_upper_case_globals)]
const choose_shortest: &'static [IntType] = &[
attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8),
attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16),
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
attr::UnsignedInt(ast::UintTy::U8), attr::SignedInt(ast::IntTy::I8),
attr::UnsignedInt(ast::UintTy::U16), attr::SignedInt(ast::IntTy::I16),
attr::UnsignedInt(ast::UintTy::U32), attr::SignedInt(ast::IntTy::I32)];
#[allow(non_upper_case_globals)]
const at_least_32: &'static [IntType] = &[
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
attr::UnsignedInt(ast::UintTy::U32), attr::SignedInt(ast::IntTy::I32)];
let attempts;
match hint {
@ -638,7 +638,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
return ity;
}
}
return attr::UnsignedInt(ast::TyU64);
return attr::UnsignedInt(ast::UintTy::U64);
}
pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type {

View File

@ -816,12 +816,12 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
ty::TyInt(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::TyI8 => i8::MIN as u64,
ast::TyI16 => i16::MIN as u64,
ast::TyI32 => i32::MIN as u64,
ast::TyI64 => i64::MIN as u64,
ast::IntTy::Is if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
ast::IntTy::Is => i64::MIN as u64,
ast::IntTy::I8 => i8::MIN as u64,
ast::IntTy::I16 => i16::MIN as u64,
ast::IntTy::I32 => i32::MIN as u64,
ast::IntTy::I64 => i64::MIN as u64,
};
(llty, min)
}

View File

@ -1220,16 +1220,16 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
ty::TyBool => output.push_str("bool"),
ty::TyChar => output.push_str("char"),
ty::TyStr => output.push_str("str"),
ty::TyInt(ast::TyIs) => output.push_str("isize"),
ty::TyInt(ast::TyI8) => output.push_str("i8"),
ty::TyInt(ast::TyI16) => output.push_str("i16"),
ty::TyInt(ast::TyI32) => output.push_str("i32"),
ty::TyInt(ast::TyI64) => output.push_str("i64"),
ty::TyUint(ast::TyUs) => output.push_str("usize"),
ty::TyUint(ast::TyU8) => output.push_str("u8"),
ty::TyUint(ast::TyU16) => output.push_str("u16"),
ty::TyUint(ast::TyU32) => output.push_str("u32"),
ty::TyUint(ast::TyU64) => output.push_str("u64"),
ty::TyInt(ast::IntTy::Is) => output.push_str("isize"),
ty::TyInt(ast::IntTy::I8) => output.push_str("i8"),
ty::TyInt(ast::IntTy::I16) => output.push_str("i16"),
ty::TyInt(ast::IntTy::I32) => output.push_str("i32"),
ty::TyInt(ast::IntTy::I64) => output.push_str("i64"),
ty::TyUint(ast::UintTy::Us) => output.push_str("usize"),
ty::TyUint(ast::UintTy::U8) => output.push_str("u8"),
ty::TyUint(ast::UintTy::U16) => output.push_str("u16"),
ty::TyUint(ast::UintTy::U32) => output.push_str("u32"),
ty::TyUint(ast::UintTy::U64) => output.push_str("u64"),
ty::TyFloat(ast::FloatTy::F32) => output.push_str("f32"),
ty::TyFloat(ast::FloatTy::F64) => output.push_str("f64"),
ty::TyStruct(adt_def, substs) |

View File

@ -64,7 +64,7 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
let _icx = push_ctxt("trans_lit");
debug!("const_lit: {:?}", lit);
match lit.node {
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::UintTy::U8), b as u64, false),
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
ast::LitInt(i, ast::SignedIntLit(t, _)) => {
C_integral(Type::int_from_ty(cx, t), i, true)

View File

@ -2370,14 +2370,14 @@ impl OverflowOpViaIntrinsic {
use middle::ty::{TyInt, TyUint};
let new_sty = match ty.sty {
TyInt(TyIs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyInt(TyI32),
"64" => TyInt(TyI64),
TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyInt(I32),
"64" => TyInt(I64),
_ => panic!("unsupported target word size")
},
TyUint(TyUs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyUint(TyU32),
"64" => TyUint(TyU64),
TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyUint(U32),
"64" => TyUint(U64),
_ => panic!("unsupported target word size")
},
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
@ -2387,41 +2387,41 @@ impl OverflowOpViaIntrinsic {
match *self {
OverflowOpViaIntrinsic::Add => match new_sty {
TyInt(TyI8) => "llvm.sadd.with.overflow.i8",
TyInt(TyI16) => "llvm.sadd.with.overflow.i16",
TyInt(TyI32) => "llvm.sadd.with.overflow.i32",
TyInt(TyI64) => "llvm.sadd.with.overflow.i64",
TyInt(I8) => "llvm.sadd.with.overflow.i8",
TyInt(I16) => "llvm.sadd.with.overflow.i16",
TyInt(I32) => "llvm.sadd.with.overflow.i32",
TyInt(I64) => "llvm.sadd.with.overflow.i64",
TyUint(TyU8) => "llvm.uadd.with.overflow.i8",
TyUint(TyU16) => "llvm.uadd.with.overflow.i16",
TyUint(TyU32) => "llvm.uadd.with.overflow.i32",
TyUint(TyU64) => "llvm.uadd.with.overflow.i64",
TyUint(U8) => "llvm.uadd.with.overflow.i8",
TyUint(U16) => "llvm.uadd.with.overflow.i16",
TyUint(U32) => "llvm.uadd.with.overflow.i32",
TyUint(U64) => "llvm.uadd.with.overflow.i64",
_ => unreachable!(),
},
OverflowOpViaIntrinsic::Sub => match new_sty {
TyInt(TyI8) => "llvm.ssub.with.overflow.i8",
TyInt(TyI16) => "llvm.ssub.with.overflow.i16",
TyInt(TyI32) => "llvm.ssub.with.overflow.i32",
TyInt(TyI64) => "llvm.ssub.with.overflow.i64",
TyInt(I8) => "llvm.ssub.with.overflow.i8",
TyInt(I16) => "llvm.ssub.with.overflow.i16",
TyInt(I32) => "llvm.ssub.with.overflow.i32",
TyInt(I64) => "llvm.ssub.with.overflow.i64",
TyUint(TyU8) => "llvm.usub.with.overflow.i8",
TyUint(TyU16) => "llvm.usub.with.overflow.i16",
TyUint(TyU32) => "llvm.usub.with.overflow.i32",
TyUint(TyU64) => "llvm.usub.with.overflow.i64",
TyUint(U8) => "llvm.usub.with.overflow.i8",
TyUint(U16) => "llvm.usub.with.overflow.i16",
TyUint(U32) => "llvm.usub.with.overflow.i32",
TyUint(U64) => "llvm.usub.with.overflow.i64",
_ => unreachable!(),
},
OverflowOpViaIntrinsic::Mul => match new_sty {
TyInt(TyI8) => "llvm.smul.with.overflow.i8",
TyInt(TyI16) => "llvm.smul.with.overflow.i16",
TyInt(TyI32) => "llvm.smul.with.overflow.i32",
TyInt(TyI64) => "llvm.smul.with.overflow.i64",
TyInt(I8) => "llvm.smul.with.overflow.i8",
TyInt(I16) => "llvm.smul.with.overflow.i16",
TyInt(I32) => "llvm.smul.with.overflow.i32",
TyInt(I64) => "llvm.smul.with.overflow.i64",
TyUint(TyU8) => "llvm.umul.with.overflow.i8",
TyUint(TyU16) => "llvm.umul.with.overflow.i16",
TyUint(TyU32) => "llvm.umul.with.overflow.i32",
TyUint(TyU64) => "llvm.umul.with.overflow.i64",
TyUint(U8) => "llvm.umul.with.overflow.i8",
TyUint(U16) => "llvm.umul.with.overflow.i16",
TyUint(U32) => "llvm.umul.with.overflow.i32",
TyUint(U64) => "llvm.umul.with.overflow.i64",
_ => unreachable!(),
},

View File

@ -1664,30 +1664,30 @@ fn int_type_width_signed<'tcx>(sty: &ty::TypeVariants<'tcx>, ccx: &CrateContext)
use rustc::middle::ty::{TyInt, TyUint};
match *sty {
TyInt(t) => Some((match t {
ast::TyIs => {
ast::IntTy::Is => {
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
"32" => 32,
"64" => 64,
tws => panic!("Unsupported target word size for isize: {}", tws),
}
},
ast::TyI8 => 8,
ast::TyI16 => 16,
ast::TyI32 => 32,
ast::TyI64 => 64,
ast::IntTy::I8 => 8,
ast::IntTy::I16 => 16,
ast::IntTy::I32 => 32,
ast::IntTy::I64 => 64,
}, true)),
TyUint(t) => Some((match t {
ast::TyUs => {
ast::UintTy::Us => {
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
"32" => 32,
"64" => 64,
tws => panic!("Unsupported target word size for usize: {}", tws),
}
},
ast::TyU8 => 8,
ast::TyU16 => 16,
ast::TyU32 => 32,
ast::TyU64 => 64,
ast::UintTy::U8 => 8,
ast::UintTy::U16 => 16,
ast::UintTy::U32 => 32,
ast::UintTy::U64 => 64,
}, false)),
_ => None,
}

View File

@ -644,7 +644,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn opaque_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
-> &'tcx ty::BareFnTy<'tcx> {
let mut inputs = method_ty.sig.0.inputs.clone();
inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::TyI8));
inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::IntTy::I8));
tcx.mk_bare_fn(ty::BareFnTy {
unsafety: method_ty.unsafety,

View File

@ -127,21 +127,21 @@ impl Type {
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
match t {
ast::TyIs => ccx.int_type(),
ast::TyI8 => Type::i8(ccx),
ast::TyI16 => Type::i16(ccx),
ast::TyI32 => Type::i32(ccx),
ast::TyI64 => Type::i64(ccx)
ast::IntTy::Is => ccx.int_type(),
ast::IntTy::I8 => Type::i8(ccx),
ast::IntTy::I16 => Type::i16(ccx),
ast::IntTy::I32 => Type::i32(ccx),
ast::IntTy::I64 => Type::i64(ccx)
}
}
pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
match t {
ast::TyUs => ccx.int_type(),
ast::TyU8 => Type::i8(ccx),
ast::TyU16 => Type::i16(ccx),
ast::TyU32 => Type::i32(ccx),
ast::TyU64 => Type::i64(ccx)
ast::UintTy::Us => ccx.int_type(),
ast::UintTy::U8 => Type::i8(ccx),
ast::UintTy::U16 => Type::i16(ccx),
ast::UintTy::U32 => Type::i32(ccx),
ast::UintTy::U64 => Type::i64(ccx)
}
}

View File

@ -385,7 +385,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
let unsized_part = cx.tcx().struct_tail(ty);
let info_ty = match unsized_part.sty {
ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
Type::uint_from_ty(cx, ast::TyUs)
Type::uint_from_ty(cx, ast::UintTy::Us)
}
ty::TyTrait(_) => Type::vtable_ptr(cx),
_ => panic!("Unexpected type returned from \

View File

@ -248,7 +248,7 @@ impl<'tcx> CastCheck<'tcx> {
(_, Int(Bool)) => Err(CastError::CastToBool),
// * -> Char
(Int(U(ast::TyU8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
(Int(U(ast::UintTy::U8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
(_, Int(Char)) => Err(CastError::CastToChar),
// prim -> float,ptr

View File

@ -429,14 +429,14 @@ fn match_intrinsic_type_to_type<'tcx, 'a>(
},
// (The width we pass to LLVM doesn't concern the type checker.)
Integer(signed, bits, _llvm_width) => match (signed, bits, &t.sty) {
(true, 8, &ty::TyInt(ast::IntTy::TyI8)) |
(false, 8, &ty::TyUint(ast::UintTy::TyU8)) |
(true, 16, &ty::TyInt(ast::IntTy::TyI16)) |
(false, 16, &ty::TyUint(ast::UintTy::TyU16)) |
(true, 32, &ty::TyInt(ast::IntTy::TyI32)) |
(false, 32, &ty::TyUint(ast::UintTy::TyU32)) |
(true, 64, &ty::TyInt(ast::IntTy::TyI64)) |
(false, 64, &ty::TyUint(ast::UintTy::TyU64)) => {},
(true, 8, &ty::TyInt(ast::IntTy::I8)) |
(false, 8, &ty::TyUint(ast::UintTy::U8)) |
(true, 16, &ty::TyInt(ast::IntTy::I16)) |
(false, 16, &ty::TyUint(ast::UintTy::U16)) |
(true, 32, &ty::TyInt(ast::IntTy::I32)) |
(false, 32, &ty::TyUint(ast::UintTy::U32)) |
(true, 64, &ty::TyInt(ast::IntTy::I64)) |
(false, 64, &ty::TyUint(ast::UintTy::U64)) => {},
_ => simple_error(&format!("`{}`", t),
&format!("`{}{n}`",
if signed {"i"} else {"u"},

View File

@ -317,43 +317,43 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
let lang_def_id = self.tcx().lang_items.mut_ptr_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyInt(ast::TyI8) => {
ty::TyInt(ast::IntTy::I8) => {
let lang_def_id = self.tcx().lang_items.i8_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyInt(ast::TyI16) => {
ty::TyInt(ast::IntTy::I16) => {
let lang_def_id = self.tcx().lang_items.i16_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyInt(ast::TyI32) => {
ty::TyInt(ast::IntTy::I32) => {
let lang_def_id = self.tcx().lang_items.i32_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyInt(ast::TyI64) => {
ty::TyInt(ast::IntTy::I64) => {
let lang_def_id = self.tcx().lang_items.i64_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyInt(ast::TyIs) => {
ty::TyInt(ast::IntTy::Is) => {
let lang_def_id = self.tcx().lang_items.isize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyUint(ast::TyU8) => {
ty::TyUint(ast::UintTy::U8) => {
let lang_def_id = self.tcx().lang_items.u8_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyUint(ast::TyU16) => {
ty::TyUint(ast::UintTy::U16) => {
let lang_def_id = self.tcx().lang_items.u16_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyUint(ast::TyU32) => {
ty::TyUint(ast::UintTy::U32) => {
let lang_def_id = self.tcx().lang_items.u32_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyUint(ast::TyU64) => {
ty::TyUint(ast::UintTy::U64) => {
let lang_def_id = self.tcx().lang_items.u64_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyUint(ast::TyUs) => {
ty::TyUint(ast::UintTy::Us) => {
let lang_def_id = self.tcx().lang_items.usize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}

View File

@ -2264,7 +2264,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// First, try built-in indexing.
match (adjusted_ty.builtin_index(), &index_ty.sty) {
(Some(ty), &ty::TyUint(ast::TyUs)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
(Some(ty), &ty::TyUint(ast::UintTy::Us)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
debug!("try_index_step: success, using built-in indexing");
// If we had `[T; N]`, we should've caught it before unsizing to `[T]`.
assert!(!unsize);
@ -2563,14 +2563,14 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
function, cast to c_double", t)
}, arg_ty, None);
}
ty::TyInt(ast::TyI8) | ty::TyInt(ast::TyI16) | ty::TyBool => {
ty::TyInt(ast::IntTy::I8) | ty::TyInt(ast::IntTy::I16) | ty::TyBool => {
fcx.type_error_message(arg.span, |t| {
format!("can't pass {} to variadic \
function, cast to c_int",
t)
}, arg_ty, None);
}
ty::TyUint(ast::TyU8) | ty::TyUint(ast::TyU16) => {
ty::TyUint(ast::UintTy::U8) | ty::TyUint(ast::UintTy::U16) => {
fcx.type_error_message(arg.span, |t| {
format!("can't pass {} to variadic \
function, cast to c_uint",
@ -4167,20 +4167,20 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
disr: ty::Disr) -> bool {
fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
match ty {
ast::TyU8 => disr as u8 as Disr == disr,
ast::TyU16 => disr as u16 as Disr == disr,
ast::TyU32 => disr as u32 as Disr == disr,
ast::TyU64 => disr as u64 as Disr == disr,
ast::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
ast::UintTy::U8 => disr as u8 as Disr == disr,
ast::UintTy::U16 => disr as u16 as Disr == disr,
ast::UintTy::U32 => disr as u32 as Disr == disr,
ast::UintTy::U64 => disr as u64 as Disr == disr,
ast::UintTy::Us => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
}
}
fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
match ty {
ast::TyI8 => disr as i8 as Disr == disr,
ast::TyI16 => disr as i16 as Disr == disr,
ast::TyI32 => disr as i32 as Disr == disr,
ast::TyI64 => disr as i64 as Disr == disr,
ast::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
ast::IntTy::I8 => disr as i8 as Disr == disr,
ast::IntTy::I16 => disr as i16 as Disr == disr,
ast::IntTy::I32 => disr as i32 as Disr == disr,
ast::IntTy::I64 => disr as i64 as Disr == disr,
ast::IntTy::Is => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
}
}
match ty {

View File

@ -121,70 +121,70 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
"*mut T",
item.span);
}
ty::TyInt(ast::TyI8) => {
ty::TyInt(ast::IntTy::I8) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i8_impl(),
"i8",
"i8",
item.span);
}
ty::TyInt(ast::TyI16) => {
ty::TyInt(ast::IntTy::I16) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i16_impl(),
"i16",
"i16",
item.span);
}
ty::TyInt(ast::TyI32) => {
ty::TyInt(ast::IntTy::I32) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i32_impl(),
"i32",
"i32",
item.span);
}
ty::TyInt(ast::TyI64) => {
ty::TyInt(ast::IntTy::I64) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i64_impl(),
"i64",
"i64",
item.span);
}
ty::TyInt(ast::TyIs) => {
ty::TyInt(ast::IntTy::Is) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.isize_impl(),
"isize",
"isize",
item.span);
}
ty::TyUint(ast::TyU8) => {
ty::TyUint(ast::UintTy::U8) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u8_impl(),
"u8",
"u8",
item.span);
}
ty::TyUint(ast::TyU16) => {
ty::TyUint(ast::UintTy::U16) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u16_impl(),
"u16",
"u16",
item.span);
}
ty::TyUint(ast::TyU32) => {
ty::TyUint(ast::UintTy::U32) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u32_impl(),
"u32",
"u32",
item.span);
}
ty::TyUint(ast::TyU64) => {
ty::TyUint(ast::UintTy::U64) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u64_impl(),
"u64",
"u64",
item.span);
}
ty::TyUint(ast::TyUs) => {
ty::TyUint(ast::UintTy::Us) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.usize_impl(),
"usize",

View File

@ -1640,16 +1640,16 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
match self.sty {
ty::TyBool => Primitive(Bool),
ty::TyChar => Primitive(Char),
ty::TyInt(ast::TyIs) => Primitive(Isize),
ty::TyInt(ast::TyI8) => Primitive(I8),
ty::TyInt(ast::TyI16) => Primitive(I16),
ty::TyInt(ast::TyI32) => Primitive(I32),
ty::TyInt(ast::TyI64) => Primitive(I64),
ty::TyUint(ast::TyUs) => Primitive(Usize),
ty::TyUint(ast::TyU8) => Primitive(U8),
ty::TyUint(ast::TyU16) => Primitive(U16),
ty::TyUint(ast::TyU32) => Primitive(U32),
ty::TyUint(ast::TyU64) => Primitive(U64),
ty::TyInt(ast::IntTy::Is) => Primitive(Isize),
ty::TyInt(ast::IntTy::I8) => Primitive(I8),
ty::TyInt(ast::IntTy::I16) => Primitive(I16),
ty::TyInt(ast::IntTy::I32) => Primitive(I32),
ty::TyInt(ast::IntTy::I64) => Primitive(I64),
ty::TyUint(ast::UintTy::Us) => Primitive(Usize),
ty::TyUint(ast::UintTy::U8) => Primitive(U8),
ty::TyUint(ast::UintTy::U16) => Primitive(U16),
ty::TyUint(ast::UintTy::U32) => Primitive(U32),
ty::TyUint(ast::UintTy::U64) => Primitive(U64),
ty::TyFloat(ast::FloatTy::F32) => Primitive(F32),
ty::TyFloat(ast::FloatTy::F64) => Primitive(F64),
ty::TyStr => Primitive(Str),
@ -2619,16 +2619,16 @@ fn resolve_type(cx: &DocContext,
hir::TyStr => return Primitive(Str),
hir::TyBool => return Primitive(Bool),
hir::TyChar => return Primitive(Char),
hir::TyInt(ast::TyIs) => return Primitive(Isize),
hir::TyInt(ast::TyI8) => return Primitive(I8),
hir::TyInt(ast::TyI16) => return Primitive(I16),
hir::TyInt(ast::TyI32) => return Primitive(I32),
hir::TyInt(ast::TyI64) => return Primitive(I64),
hir::TyUint(ast::TyUs) => return Primitive(Usize),
hir::TyUint(ast::TyU8) => return Primitive(U8),
hir::TyUint(ast::TyU16) => return Primitive(U16),
hir::TyUint(ast::TyU32) => return Primitive(U32),
hir::TyUint(ast::TyU64) => return Primitive(U64),
hir::TyInt(ast::IntTy::Is) => return Primitive(Isize),
hir::TyInt(ast::IntTy::I8) => return Primitive(I8),
hir::TyInt(ast::IntTy::I16) => return Primitive(I16),
hir::TyInt(ast::IntTy::I32) => return Primitive(I32),
hir::TyInt(ast::IntTy::I64) => return Primitive(I64),
hir::TyUint(ast::UintTy::Us) => return Primitive(Usize),
hir::TyUint(ast::UintTy::U8) => return Primitive(U8),
hir::TyUint(ast::UintTy::U16) => return Primitive(U16),
hir::TyUint(ast::UintTy::U32) => return Primitive(U32),
hir::TyUint(ast::UintTy::U64) => return Primitive(U64),
hir::TyFloat(ast::FloatTy::F32) => return Primitive(F32),
hir::TyFloat(ast::FloatTy::F64) => return Primitive(F64),
},

View File

@ -11,7 +11,6 @@
// The Rust abstract syntax tree.
pub use self::ForeignItem_::*;
pub use self::IntTy::*;
pub use self::Item_::*;
pub use self::KleeneOp::*;
pub use self::Lit_::*;
@ -29,7 +28,6 @@ pub use self::StructFieldKind::*;
pub use self::TraitItem_::*;
pub use self::Ty_::*;
pub use self::TyParamBound::*;
pub use self::UintTy::*;
pub use self::UnsafeSource::*;
pub use self::ViewPath_::*;
pub use self::Visibility::*;
@ -1393,11 +1391,11 @@ pub enum ImplItemKind {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum IntTy {
TyIs,
TyI8,
TyI16,
TyI32,
TyI64,
Is,
I8,
I16,
I32,
I64,
}
impl fmt::Debug for IntTy {
@ -1415,11 +1413,11 @@ impl fmt::Display for IntTy {
impl IntTy {
pub fn ty_to_string(&self) -> &'static str {
match *self {
TyIs => "isize",
TyI8 => "i8",
TyI16 => "i16",
TyI32 => "i32",
TyI64 => "i64"
IntTy::Is => "isize",
IntTy::I8 => "i8",
IntTy::I16 => "i16",
IntTy::I32 => "i32",
IntTy::I64 => "i64"
}
}
@ -1432,41 +1430,41 @@ impl IntTy {
pub fn ty_max(&self) -> u64 {
match *self {
TyI8 => 0x80,
TyI16 => 0x8000,
TyIs | TyI32 => 0x80000000, // actually ni about TyIs
TyI64 => 0x8000000000000000
IntTy::I8 => 0x80,
IntTy::I16 => 0x8000,
IntTy::Is | IntTy::I32 => 0x80000000, // FIXME: actually ni about Is
IntTy::I64 => 0x8000000000000000
}
}
pub fn bit_width(&self) -> Option<usize> {
Some(match *self {
TyIs => return None,
TyI8 => 8,
TyI16 => 16,
TyI32 => 32,
TyI64 => 64,
IntTy::Is => return None,
IntTy::I8 => 8,
IntTy::I16 => 16,
IntTy::I32 => 32,
IntTy::I64 => 64,
})
}
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum UintTy {
TyUs,
TyU8,
TyU16,
TyU32,
TyU64,
Us,
U8,
U16,
U32,
U64,
}
impl UintTy {
pub fn ty_to_string(&self) -> &'static str {
match *self {
TyUs => "usize",
TyU8 => "u8",
TyU16 => "u16",
TyU32 => "u32",
TyU64 => "u64"
UintTy::Us => "usize",
UintTy::U8 => "u8",
UintTy::U16 => "u16",
UintTy::U32 => "u32",
UintTy::U64 => "u64"
}
}
@ -1476,20 +1474,20 @@ impl UintTy {
pub fn ty_max(&self) -> u64 {
match *self {
TyU8 => 0xff,
TyU16 => 0xffff,
TyUs | TyU32 => 0xffffffff, // actually ni about TyUs
TyU64 => 0xffffffffffffffff
UintTy::U8 => 0xff,
UintTy::U16 => 0xffff,
UintTy::Us | UintTy::U32 => 0xffffffff, // FIXME: actually ni about Us
UintTy::U64 => 0xffffffffffffffff
}
}
pub fn bit_width(&self) -> Option<usize> {
Some(match *self {
TyUs => return None,
TyU8 => 8,
TyU16 => 16,
TyU32 => 32,
TyU64 => 64,
UintTy::Us => return None,
UintTy::U8 => 8,
UintTy::U16 => 16,
UintTy::U32 => 32,
UintTy::U64 => 64,
})
}
}

View File

@ -746,16 +746,16 @@ pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr>
fn int_type_of_word(s: &str) -> Option<IntType> {
match s {
"i8" => Some(SignedInt(ast::TyI8)),
"u8" => Some(UnsignedInt(ast::TyU8)),
"i16" => Some(SignedInt(ast::TyI16)),
"u16" => Some(UnsignedInt(ast::TyU16)),
"i32" => Some(SignedInt(ast::TyI32)),
"u32" => Some(UnsignedInt(ast::TyU32)),
"i64" => Some(SignedInt(ast::TyI64)),
"u64" => Some(UnsignedInt(ast::TyU64)),
"isize" => Some(SignedInt(ast::TyIs)),
"usize" => Some(UnsignedInt(ast::TyUs)),
"i8" => Some(SignedInt(ast::IntTy::I8)),
"u8" => Some(UnsignedInt(ast::UintTy::U8)),
"i16" => Some(SignedInt(ast::IntTy::I16)),
"u16" => Some(UnsignedInt(ast::UintTy::U16)),
"i32" => Some(SignedInt(ast::IntTy::I32)),
"u32" => Some(UnsignedInt(ast::UintTy::U32)),
"i64" => Some(SignedInt(ast::IntTy::I64)),
"u64" => Some(UnsignedInt(ast::UintTy::U64)),
"isize" => Some(SignedInt(ast::IntTy::Is)),
"usize" => Some(UnsignedInt(ast::UintTy::Us)),
_ => None
}
}
@ -797,11 +797,11 @@ impl IntType {
}
fn is_ffi_safe(self) -> bool {
match self {
SignedInt(ast::TyI8) | UnsignedInt(ast::TyU8) |
SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |
SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |
SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,
SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false
SignedInt(ast::IntTy::I8) | UnsignedInt(ast::UintTy::U8) |
SignedInt(ast::IntTy::I16) | UnsignedInt(ast::UintTy::U16) |
SignedInt(ast::IntTy::I32) | UnsignedInt(ast::UintTy::U32) |
SignedInt(ast::IntTy::I64) | UnsignedInt(ast::UintTy::U64) => true,
SignedInt(ast::IntTy::Is) | UnsignedInt(ast::UintTy::Us) => false
}
}
}

View File

@ -680,17 +680,17 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr(sp, ast::ExprKind::Lit(P(respan(sp, lit))))
}
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::UintTy::Us)))
}
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs,
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::IntTy::Is,
ast::Sign::new(i))))
}
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU32)))
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U32)))
}
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::UintTy::U8)))
}
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr> {
self.expr_lit(sp, ast::LitBool(value))

View File

@ -279,17 +279,17 @@ pub mod rt {
);
}
impl_to_tokens_int! { signed, isize, ast::TyIs }
impl_to_tokens_int! { signed, i8, ast::TyI8 }
impl_to_tokens_int! { signed, i16, ast::TyI16 }
impl_to_tokens_int! { signed, i32, ast::TyI32 }
impl_to_tokens_int! { signed, i64, ast::TyI64 }
impl_to_tokens_int! { signed, isize, ast::IntTy::Is }
impl_to_tokens_int! { signed, i8, ast::IntTy::I8 }
impl_to_tokens_int! { signed, i16, ast::IntTy::I16 }
impl_to_tokens_int! { signed, i32, ast::IntTy::I32 }
impl_to_tokens_int! { signed, i64, ast::IntTy::I64 }
impl_to_tokens_int! { unsigned, usize, ast::TyUs }
impl_to_tokens_int! { unsigned, u8, ast::TyU8 }
impl_to_tokens_int! { unsigned, u16, ast::TyU16 }
impl_to_tokens_int! { unsigned, u32, ast::TyU32 }
impl_to_tokens_int! { unsigned, u64, ast::TyU64 }
impl_to_tokens_int! { unsigned, usize, ast::UintTy::Us }
impl_to_tokens_int! { unsigned, u8, ast::UintTy::U8 }
impl_to_tokens_int! { unsigned, u16, ast::UintTy::U16 }
impl_to_tokens_int! { unsigned, u32, ast::UintTy::U32 }
impl_to_tokens_int! { unsigned, u64, ast::UintTy::U64 }
pub trait ExtParseUtils {
fn parse_item(&self, s: String) -> P<ast::Item>;

View File

@ -618,16 +618,16 @@ pub fn integer_lit(s: &str,
if let Some(ref suf) = suffix {
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
ty = match &**suf {
"isize" => 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),
"usize" => ast::UnsignedIntLit(ast::TyUs),
"u8" => ast::UnsignedIntLit(ast::TyU8),
"u16" => ast::UnsignedIntLit(ast::TyU16),
"u32" => ast::UnsignedIntLit(ast::TyU32),
"u64" => ast::UnsignedIntLit(ast::TyU64),
"isize" => ast::SignedIntLit(ast::IntTy::Is, ast::Plus),
"i8" => ast::SignedIntLit(ast::IntTy::I8, ast::Plus),
"i16" => ast::SignedIntLit(ast::IntTy::I16, ast::Plus),
"i32" => ast::SignedIntLit(ast::IntTy::I32, ast::Plus),
"i64" => ast::SignedIntLit(ast::IntTy::I64, ast::Plus),
"usize" => ast::UnsignedIntLit(ast::UintTy::Us),
"u8" => ast::UnsignedIntLit(ast::UintTy::U8),
"u16" => ast::UnsignedIntLit(ast::UintTy::U16),
"u32" => ast::UnsignedIntLit(ast::UintTy::U32),
"u64" => ast::UnsignedIntLit(ast::UintTy::U64),
_ => {
// i<digits> and u<digits> look like widths, so lets
// give an error message along those lines

View File

@ -27,7 +27,7 @@ use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic};
use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst};
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
use ast::{ItemExternCrate, ItemUse};
use ast::{Lit, Lit_};
use ast::{Lit, Lit_, UintTy};
use ast::{LitBool, LitChar, LitByte, LitByteStr};
use ast::{LitStr, LitInt, Local};
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
@ -45,7 +45,7 @@ use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
use ast::{Ty, Ty_, TypeBinding, TyMac};
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPtr};
use ast::{TyRptr, TyTup, TyU32, TyVec};
use ast::{TyRptr, TyTup, TyVec};
use ast::TypeTraitItem;
use ast::UnnamedField;
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
@ -2017,7 +2017,7 @@ impl<'a> Parser<'a> {
pub fn mk_lit_u32(&mut self, i: u32, attrs: ThinAttributes) -> P<Expr> {
let span = &self.span;
let lv_lit = P(codemap::Spanned {
node: LitInt(i as u64, ast::UnsignedIntLit(TyU32)),
node: LitInt(i as u64, ast::UnsignedIntLit(UintTy::U32)),
span: *span
});

View File

@ -3184,8 +3184,8 @@ mod tests {
#[test]
fn test_signed_int_to_string() {
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus));
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus));
let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::IntTy::I32, ast::Plus));
let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::IntTy::I32, ast::Minus));
assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))),
lit_to_string(&codemap::dummy_spanned(neg_int)));
}

View File

@ -748,17 +748,17 @@ fn find_repr_type_name(diagnostic: &Handler,
attr::ReprAny | attr::ReprPacked | attr::ReprSimd => continue,
attr::ReprExtern => "i32",
attr::ReprInt(_, attr::SignedInt(ast::TyIs)) => "isize",
attr::ReprInt(_, attr::SignedInt(ast::TyI8)) => "i8",
attr::ReprInt(_, attr::SignedInt(ast::TyI16)) => "i16",
attr::ReprInt(_, attr::SignedInt(ast::TyI32)) => "i32",
attr::ReprInt(_, attr::SignedInt(ast::TyI64)) => "i64",
attr::ReprInt(_, attr::SignedInt(ast::IntTy::Is)) => "isize",
attr::ReprInt(_, attr::SignedInt(ast::IntTy::I8)) => "i8",
attr::ReprInt(_, attr::SignedInt(ast::IntTy::I16)) => "i16",
attr::ReprInt(_, attr::SignedInt(ast::IntTy::I32)) => "i32",
attr::ReprInt(_, attr::SignedInt(ast::IntTy::I64)) => "i64",
attr::ReprInt(_, attr::UnsignedInt(ast::TyUs)) => "usize",
attr::ReprInt(_, attr::UnsignedInt(ast::TyU8)) => "u8",
attr::ReprInt(_, attr::UnsignedInt(ast::TyU16)) => "u16",
attr::ReprInt(_, attr::UnsignedInt(ast::TyU32)) => "u32",
attr::ReprInt(_, attr::UnsignedInt(ast::TyU64)) => "u64",
attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::Us)) => "usize",
attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U8)) => "u8",
attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U16)) => "u16",
attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U32)) => "u32",
attr::ReprInt(_, attr::UnsignedInt(ast::UintTy::U64)) => "u64",
}
}
}