Store deprecated status of i/u-suffixed literals.
This commit is contained in:
parent
2f99a41fe1
commit
e95779554e
18 changed files with 112 additions and 79 deletions
|
|
@ -216,7 +216,7 @@ impl LintPass for TypeLimits {
|
|||
match lit.node {
|
||||
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
|
||||
ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
|
||||
let int_type = if t == ast::TyIs {
|
||||
let int_type = if let ast::TyIs(_) = t {
|
||||
cx.sess().target.int_type
|
||||
} else { t };
|
||||
let (min, max) = int_ty_range(int_type);
|
||||
|
|
@ -233,7 +233,7 @@ impl LintPass for TypeLimits {
|
|||
};
|
||||
},
|
||||
ty::ty_uint(t) => {
|
||||
let uint_type = if t == ast::TyUs {
|
||||
let uint_type = if let ast::TyUs(_) = t {
|
||||
cx.sess().target.uint_type
|
||||
} else { t };
|
||||
let (min, max) = uint_ty_range(uint_type);
|
||||
|
|
@ -296,7 +296,7 @@ impl LintPass for TypeLimits {
|
|||
// warnings are consistent between 32- and 64-bit platforms
|
||||
fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
|
||||
match int_ty {
|
||||
ast::TyIs=> (i64::MIN, i64::MAX),
|
||||
ast::TyIs(_) => (i64::MIN, i64::MAX),
|
||||
ast::TyI8 => (i8::MIN as i64, i8::MAX as i64),
|
||||
ast::TyI16 => (i16::MIN as i64, i16::MAX as i64),
|
||||
ast::TyI32 => (i32::MIN as i64, i32::MAX as i64),
|
||||
|
|
@ -306,7 +306,7 @@ impl LintPass for TypeLimits {
|
|||
|
||||
fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
|
||||
match uint_ty {
|
||||
ast::TyUs=> (u64::MIN, u64::MAX),
|
||||
ast::TyUs(_) => (u64::MIN, u64::MAX),
|
||||
ast::TyU8 => (u8::MIN as u64, u8::MAX as u64),
|
||||
ast::TyU16 => (u16::MIN as u64, u16::MAX as u64),
|
||||
ast::TyU32 => (u32::MIN as u64, u32::MAX as u64),
|
||||
|
|
@ -323,7 +323,7 @@ impl LintPass for TypeLimits {
|
|||
|
||||
fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
|
||||
match int_ty {
|
||||
ast::TyIs=> int_ty_bits(target_int_ty, target_int_ty),
|
||||
ast::TyIs(_) => int_ty_bits(target_int_ty, target_int_ty),
|
||||
ast::TyI8 => i8::BITS as u64,
|
||||
ast::TyI16 => i16::BITS as u64,
|
||||
ast::TyI32 => i32::BITS as u64,
|
||||
|
|
@ -333,7 +333,7 @@ impl LintPass for TypeLimits {
|
|||
|
||||
fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
|
||||
match uint_ty {
|
||||
ast::TyUs=> uint_ty_bits(target_uint_ty, target_uint_ty),
|
||||
ast::TyUs(_) => uint_ty_bits(target_uint_ty, target_uint_ty),
|
||||
ast::TyU8 => u8::BITS as u64,
|
||||
ast::TyU16 => u16::BITS as u64,
|
||||
ast::TyU32 => u32::BITS as u64,
|
||||
|
|
@ -404,12 +404,12 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
|
|||
impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
|
||||
match self.cx.tcx.def_map.borrow()[path_id].clone() {
|
||||
def::DefPrimTy(ast::TyInt(ast::TyIs)) => {
|
||||
def::DefPrimTy(ast::TyInt(ast::TyIs(_))) => {
|
||||
self.cx.span_lint(IMPROPER_CTYPES, sp,
|
||||
"found rust type `isize` in foreign module, while \
|
||||
libc::c_int or libc::c_long should be used");
|
||||
}
|
||||
def::DefPrimTy(ast::TyUint(ast::TyUs)) => {
|
||||
def::DefPrimTy(ast::TyUint(ast::TyUs(_))) => {
|
||||
self.cx.span_lint(IMPROPER_CTYPES, sp,
|
||||
"found rust type `usize` in foreign module, while \
|
||||
libc::c_uint or libc::c_ulong should be used");
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
ty::ty_char => mywrite!(w, "c"),
|
||||
ty::ty_int(t) => {
|
||||
match t {
|
||||
ast::TyIs => mywrite!(w, "is"),
|
||||
ast::TyIs(_) => mywrite!(w, "is"),
|
||||
ast::TyI8 => mywrite!(w, "MB"),
|
||||
ast::TyI16 => mywrite!(w, "MW"),
|
||||
ast::TyI32 => mywrite!(w, "ML"),
|
||||
|
|
@ -70,7 +70,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
}
|
||||
ty::ty_uint(t) => {
|
||||
match t {
|
||||
ast::TyUs => mywrite!(w, "us"),
|
||||
ast::TyUs(_) => mywrite!(w, "us"),
|
||||
ast::TyU8 => mywrite!(w, "Mb"),
|
||||
ast::TyU16 => mywrite!(w, "Mw"),
|
||||
ast::TyU32 => mywrite!(w, "Ml"),
|
||||
|
|
|
|||
|
|
@ -528,12 +528,12 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St
|
|||
|
||||
eval_const_expr_partial(tcx, &**base)
|
||||
.and_then(|val| define_casts!(val, {
|
||||
ty::ty_int(ast::TyIs) => (int, const_int, i64),
|
||||
ty::ty_int(ast::TyIs(_)) => (int, const_int, i64),
|
||||
ty::ty_int(ast::TyI8) => (i8, const_int, i64),
|
||||
ty::ty_int(ast::TyI16) => (i16, const_int, i64),
|
||||
ty::ty_int(ast::TyI32) => (i32, const_int, i64),
|
||||
ty::ty_int(ast::TyI64) => (i64, const_int, i64),
|
||||
ty::ty_uint(ast::TyUs) => (uint, const_uint, u64),
|
||||
ty::ty_uint(ast::TyUs(_)) => (uint, const_uint, u64),
|
||||
ty::ty_uint(ast::TyU8) => (u8, const_uint, u64),
|
||||
ty::ty_uint(ast::TyU16) => (u16, const_uint, u64),
|
||||
ty::ty_uint(ast::TyU32) => (u32, const_uint, u64),
|
||||
|
|
|
|||
|
|
@ -2341,12 +2341,12 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
bool: intern_ty(arena, interner, ty_bool),
|
||||
char: intern_ty(arena, interner, ty_char),
|
||||
err: intern_ty(arena, interner, ty_err),
|
||||
int: intern_ty(arena, interner, ty_int(ast::TyIs)),
|
||||
int: intern_ty(arena, interner, ty_int(ast::TyIs(_))),
|
||||
i8: intern_ty(arena, interner, ty_int(ast::TyI8)),
|
||||
i16: intern_ty(arena, interner, ty_int(ast::TyI16)),
|
||||
i32: intern_ty(arena, interner, ty_int(ast::TyI32)),
|
||||
i64: intern_ty(arena, interner, ty_int(ast::TyI64)),
|
||||
uint: intern_ty(arena, interner, ty_uint(ast::TyUs)),
|
||||
uint: intern_ty(arena, interner, ty_uint(ast::TyUs(_))),
|
||||
u8: intern_ty(arena, interner, ty_uint(ast::TyU8)),
|
||||
u16: intern_ty(arena, interner, ty_uint(ast::TyU16)),
|
||||
u32: intern_ty(arena, interner, ty_uint(ast::TyU32)),
|
||||
|
|
@ -2692,7 +2692,7 @@ impl FlagComputation {
|
|||
|
||||
pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyIs => tcx.types.int,
|
||||
ast::TyIs(_) => tcx.types.int,
|
||||
ast::TyI8 => tcx.types.i8,
|
||||
ast::TyI16 => tcx.types.i16,
|
||||
ast::TyI32 => tcx.types.i32,
|
||||
|
|
@ -2702,7 +2702,7 @@ pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
|
|||
|
||||
pub fn mk_mach_uint<'tcx>(tcx: &ctxt<'tcx>, tm: ast::UintTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyUs => tcx.types.uint,
|
||||
ast::TyUs(_) => tcx.types.uint,
|
||||
ast::TyU8 => tcx.types.u8,
|
||||
ast::TyU16 => tcx.types.u16,
|
||||
ast::TyU32 => tcx.types.u32,
|
||||
|
|
@ -3363,7 +3363,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
|
||||
let result = match ty.sty {
|
||||
// uint and int are ffi-unsafe
|
||||
ty_uint(ast::TyUs) | ty_int(ast::TyIs) => {
|
||||
ty_uint(ast::TyUs(_)) | ty_int(ast::TyIs(_)) => {
|
||||
TC::ReachesFfiUnsafe
|
||||
}
|
||||
|
||||
|
|
@ -3937,7 +3937,7 @@ pub fn type_is_fresh(ty: Ty) -> bool {
|
|||
|
||||
pub fn type_is_uint(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty_infer(IntVar(_)) | ty_uint(ast::TyUs) => true,
|
||||
ty_infer(IntVar(_)) | ty_uint(ast::TyUs(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
@ -3983,7 +3983,7 @@ pub fn type_is_signed(ty: Ty) -> bool {
|
|||
|
||||
pub fn type_is_machine(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty_int(ast::TyIs) | ty_uint(ast::TyUs) => false,
|
||||
ty_int(ast::TyIs(_)) | ty_uint(ast::TyUs(_)) => false,
|
||||
ty_int(..) | ty_uint(..) | ty_float(..) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue