Skip to content

Commit 54f16b8

Browse files
committed
rustc: Remove support for int/uint
This commit removes all parsing, resolve, and compiler support for the old and long-deprecated int/uint types.
1 parent a923278 commit 54f16b8

File tree

22 files changed

+71
-166
lines changed

22 files changed

+71
-166
lines changed

src/librustc/metadata/tyencode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
6464
ty::ty_char => mywrite!(w, "c"),
6565
ty::ty_int(t) => {
6666
match t {
67-
ast::TyIs(_) => mywrite!(w, "is"),
67+
ast::TyIs => mywrite!(w, "is"),
6868
ast::TyI8 => mywrite!(w, "MB"),
6969
ast::TyI16 => mywrite!(w, "MW"),
7070
ast::TyI32 => mywrite!(w, "ML"),
@@ -73,7 +73,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
7373
}
7474
ty::ty_uint(t) => {
7575
match t {
76-
ast::TyUs(_) => mywrite!(w, "us"),
76+
ast::TyUs => mywrite!(w, "us"),
7777
ast::TyU8 => mywrite!(w, "Mb"),
7878
ast::TyU16 => mywrite!(w, "Mw"),
7979
ast::TyU32 => mywrite!(w, "Ml"),

src/librustc/middle/const_eval.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
396396
Some(&ty::ty_int(int_ty)) => int_ty,
397397
_ => return false
398398
};
399-
let int_ty = if let ast::TyIs(_) = int_ty {
399+
let int_ty = if let ast::TyIs = int_ty {
400400
tcx.sess.target.int_type
401401
} else {
402402
int_ty
@@ -406,7 +406,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
406406
ast::TyI16 => (a as i16) == i16::MIN,
407407
ast::TyI32 => (a as i32) == i32::MIN,
408408
ast::TyI64 => (a as i64) == i64::MIN,
409-
ast::TyIs(_) => unreachable!()
409+
ast::TyIs => unreachable!()
410410
}
411411
};
412412
match op.node {
@@ -628,12 +628,12 @@ fn cast_const(val: const_val, ty: Ty) -> Result<const_val, ErrKind> {
628628
}
629629

630630
define_casts!{
631-
ty::ty_int(ast::TyIs(_)) => (int, const_int, i64),
631+
ty::ty_int(ast::TyIs) => (int, const_int, i64),
632632
ty::ty_int(ast::TyI8) => (i8, const_int, i64),
633633
ty::ty_int(ast::TyI16) => (i16, const_int, i64),
634634
ty::ty_int(ast::TyI32) => (i32, const_int, i64),
635635
ty::ty_int(ast::TyI64) => (i64, const_int, i64),
636-
ty::ty_uint(ast::TyUs(_)) => (uint, const_uint, u64),
636+
ty::ty_uint(ast::TyUs) => (uint, const_uint, u64),
637637
ty::ty_uint(ast::TyU8) => (u8, const_uint, u64),
638638
ty::ty_uint(ast::TyU16) => (u16, const_uint, u64),
639639
ty::ty_uint(ast::TyU32) => (u32, const_uint, u64),

src/librustc/middle/ty.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2545,12 +2545,12 @@ impl<'tcx> CommonTypes<'tcx> {
25452545
bool: intern_ty(arena, interner, ty_bool),
25462546
char: intern_ty(arena, interner, ty_char),
25472547
err: intern_ty(arena, interner, ty_err),
2548-
int: intern_ty(arena, interner, ty_int(ast::TyIs(false))),
2548+
int: intern_ty(arena, interner, ty_int(ast::TyIs)),
25492549
i8: intern_ty(arena, interner, ty_int(ast::TyI8)),
25502550
i16: intern_ty(arena, interner, ty_int(ast::TyI16)),
25512551
i32: intern_ty(arena, interner, ty_int(ast::TyI32)),
25522552
i64: intern_ty(arena, interner, ty_int(ast::TyI64)),
2553-
uint: intern_ty(arena, interner, ty_uint(ast::TyUs(false))),
2553+
uint: intern_ty(arena, interner, ty_uint(ast::TyUs)),
25542554
u8: intern_ty(arena, interner, ty_uint(ast::TyU8)),
25552555
u16: intern_ty(arena, interner, ty_uint(ast::TyU16)),
25562556
u32: intern_ty(arena, interner, ty_uint(ast::TyU32)),
@@ -2935,7 +2935,7 @@ impl FlagComputation {
29352935

29362936
pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
29372937
match tm {
2938-
ast::TyIs(_) => tcx.types.int,
2938+
ast::TyIs => tcx.types.int,
29392939
ast::TyI8 => tcx.types.i8,
29402940
ast::TyI16 => tcx.types.i16,
29412941
ast::TyI32 => tcx.types.i32,
@@ -2945,7 +2945,7 @@ pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
29452945

29462946
pub fn mk_mach_uint<'tcx>(tcx: &ctxt<'tcx>, tm: ast::UintTy) -> Ty<'tcx> {
29472947
match tm {
2948-
ast::TyUs(_) => tcx.types.uint,
2948+
ast::TyUs => tcx.types.uint,
29492949
ast::TyU8 => tcx.types.u8,
29502950
ast::TyU16 => tcx.types.u16,
29512951
ast::TyU32 => tcx.types.u32,
@@ -3612,7 +3612,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
36123612

36133613
let result = match ty.sty {
36143614
// uint and int are ffi-unsafe
3615-
ty_uint(ast::TyUs(_)) | ty_int(ast::TyIs(_)) => {
3615+
ty_uint(ast::TyUs) | ty_int(ast::TyIs) => {
36163616
TC::ReachesFfiUnsafe
36173617
}
36183618

@@ -4175,7 +4175,7 @@ pub fn type_is_fresh(ty: Ty) -> bool {
41754175

41764176
pub fn type_is_uint(ty: Ty) -> bool {
41774177
match ty.sty {
4178-
ty_infer(IntVar(_)) | ty_uint(ast::TyUs(_)) => true,
4178+
ty_infer(IntVar(_)) | ty_uint(ast::TyUs) => true,
41794179
_ => false
41804180
}
41814181
}
@@ -4221,7 +4221,7 @@ pub fn type_is_signed(ty: Ty) -> bool {
42214221

42224222
pub fn type_is_machine(ty: Ty) -> bool {
42234223
match ty.sty {
4224-
ty_int(ast::TyIs(_)) | ty_uint(ast::TyUs(_)) => false,
4224+
ty_int(ast::TyIs) | ty_uint(ast::TyUs) => false,
42254225
ty_int(..) | ty_uint(..) | ty_float(..) => true,
42264226
_ => false
42274227
}

src/librustc_driver/driver.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
501501
let features =
502502
syntax::feature_gate::check_crate(sess.codemap(),
503503
&sess.parse_sess.span_diagnostic,
504-
&krate,
505-
true);
504+
&krate);
506505
*sess.features.borrow_mut() = features;
507506
sess.abort_if_errors();
508507
});
@@ -532,8 +531,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
532531
let features =
533532
syntax::feature_gate::check_crate(sess.codemap(),
534533
&sess.parse_sess.span_diagnostic,
535-
&krate,
536-
false);
534+
&krate);
537535
*sess.features.borrow_mut() = features;
538536
sess.abort_if_errors();
539537
});

src/librustc_lint/builtin.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl LintPass for TypeLimits {
199199
match lit.node {
200200
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
201201
ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
202-
let int_type = if let ast::TyIs(_) = t {
202+
let int_type = if let ast::TyIs = t {
203203
cx.sess().target.int_type
204204
} else {
205205
t
@@ -218,7 +218,7 @@ impl LintPass for TypeLimits {
218218
};
219219
},
220220
ty::ty_uint(t) => {
221-
let uint_type = if let ast::TyUs(_) = t {
221+
let uint_type = if let ast::TyUs = t {
222222
cx.sess().target.uint_type
223223
} else {
224224
t
@@ -283,7 +283,7 @@ impl LintPass for TypeLimits {
283283
// warnings are consistent between 32- and 64-bit platforms
284284
fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
285285
match int_ty {
286-
ast::TyIs(_) => (i64::MIN, i64::MAX),
286+
ast::TyIs => (i64::MIN, i64::MAX),
287287
ast::TyI8 => (i8::MIN as i64, i8::MAX as i64),
288288
ast::TyI16 => (i16::MIN as i64, i16::MAX as i64),
289289
ast::TyI32 => (i32::MIN as i64, i32::MAX as i64),
@@ -293,7 +293,7 @@ impl LintPass for TypeLimits {
293293

294294
fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
295295
match uint_ty {
296-
ast::TyUs(_) => (u64::MIN, u64::MAX),
296+
ast::TyUs => (u64::MIN, u64::MAX),
297297
ast::TyU8 => (u8::MIN as u64, u8::MAX as u64),
298298
ast::TyU16 => (u16::MIN as u64, u16::MAX as u64),
299299
ast::TyU32 => (u32::MIN as u64, u32::MAX as u64),
@@ -310,7 +310,7 @@ impl LintPass for TypeLimits {
310310

311311
fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
312312
match int_ty {
313-
ast::TyIs(_) => int_ty_bits(target_int_ty, target_int_ty),
313+
ast::TyIs => int_ty_bits(target_int_ty, target_int_ty),
314314
ast::TyI8 => i8::BITS as u64,
315315
ast::TyI16 => i16::BITS as u64,
316316
ast::TyI32 => i32::BITS as u64,
@@ -320,7 +320,7 @@ impl LintPass for TypeLimits {
320320

321321
fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
322322
match uint_ty {
323-
ast::TyUs(_) => uint_ty_bits(target_uint_ty, target_uint_ty),
323+
ast::TyUs => uint_ty_bits(target_uint_ty, target_uint_ty),
324324
ast::TyU8 => u8::BITS as u64,
325325
ast::TyU16 => u16::BITS as u64,
326326
ast::TyU32 => u32::BITS as u64,
@@ -395,12 +395,12 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
395395
impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
396396
fn check_def(&mut self, sp: Span, id: ast::NodeId) {
397397
match self.cx.tcx.def_map.borrow().get(&id).unwrap().full_def() {
398-
def::DefPrimTy(ast::TyInt(ast::TyIs(_))) => {
398+
def::DefPrimTy(ast::TyInt(ast::TyIs)) => {
399399
self.cx.span_lint(IMPROPER_CTYPES, sp,
400400
"found rust type `isize` in foreign module, while \
401401
libc::c_int or libc::c_long should be used");
402402
}
403-
def::DefPrimTy(ast::TyUint(ast::TyUs(_))) => {
403+
def::DefPrimTy(ast::TyUint(ast::TyUs)) => {
404404
self.cx.span_lint(IMPROPER_CTYPES, sp,
405405
"found rust type `usize` in foreign module, while \
406406
libc::c_uint or libc::c_ulong should be used");

src/librustc_resolve/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -744,15 +744,13 @@ impl PrimitiveTypeTable {
744744
table.intern("char", TyChar);
745745
table.intern("f32", TyFloat(TyF32));
746746
table.intern("f64", TyFloat(TyF64));
747-
table.intern("int", TyInt(TyIs(true)));
748-
table.intern("isize", TyInt(TyIs(false)));
747+
table.intern("isize", TyInt(TyIs));
749748
table.intern("i8", TyInt(TyI8));
750749
table.intern("i16", TyInt(TyI16));
751750
table.intern("i32", TyInt(TyI32));
752751
table.intern("i64", TyInt(TyI64));
753752
table.intern("str", TyStr);
754-
table.intern("uint", TyUint(TyUs(true)));
755-
table.intern("usize", TyUint(TyUs(false)));
753+
table.intern("usize", TyUint(TyUs));
756754
table.intern("u8", TyUint(TyU8));
757755
table.intern("u16", TyUint(TyU16));
758756
table.intern("u32", TyUint(TyU32));

src/librustc_trans/trans/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
847847
ty::ty_int(t) => {
848848
let llty = Type::int_from_ty(cx.ccx(), t);
849849
let min = match t {
850-
ast::TyIs(_) if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
851-
ast::TyIs(_) => i64::MIN as u64,
850+
ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
851+
ast::TyIs => i64::MIN as u64,
852852
ast::TyI8 => i8::MIN as u64,
853853
ast::TyI16 => i16::MIN as u64,
854854
ast::TyI32 => i32::MIN as u64,

src/librustc_trans/trans/debuginfo.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1814,14 +1814,14 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
18141814
ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
18151815
ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
18161816
ty::ty_int(int_ty) => match int_ty {
1817-
ast::TyIs(_) => ("isize".to_string(), DW_ATE_signed),
1817+
ast::TyIs => ("isize".to_string(), DW_ATE_signed),
18181818
ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
18191819
ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
18201820
ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
18211821
ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
18221822
},
18231823
ty::ty_uint(uint_ty) => match uint_ty {
1824-
ast::TyUs(_) => ("usize".to_string(), DW_ATE_unsigned),
1824+
ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
18251825
ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
18261826
ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
18271827
ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
@@ -3745,12 +3745,12 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
37453745
ty::ty_bool => output.push_str("bool"),
37463746
ty::ty_char => output.push_str("char"),
37473747
ty::ty_str => output.push_str("str"),
3748-
ty::ty_int(ast::TyIs(_)) => output.push_str("isize"),
3748+
ty::ty_int(ast::TyIs) => output.push_str("isize"),
37493749
ty::ty_int(ast::TyI8) => output.push_str("i8"),
37503750
ty::ty_int(ast::TyI16) => output.push_str("i16"),
37513751
ty::ty_int(ast::TyI32) => output.push_str("i32"),
37523752
ty::ty_int(ast::TyI64) => output.push_str("i64"),
3753-
ty::ty_uint(ast::TyUs(_)) => output.push_str("usize"),
3753+
ty::ty_uint(ast::TyUs) => output.push_str("usize"),
37543754
ty::ty_uint(ast::TyU8) => output.push_str("u8"),
37553755
ty::ty_uint(ast::TyU16) => output.push_str("u16"),
37563756
ty::ty_uint(ast::TyU32) => output.push_str("u32"),

src/librustc_trans/trans/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2426,12 +2426,12 @@ impl OverflowOpViaIntrinsic {
24262426
use middle::ty::{ty_int, ty_uint};
24272427

24282428
let new_sty = match ty.sty {
2429-
ty_int(TyIs(_)) => match &tcx.sess.target.target.target_pointer_width[..] {
2429+
ty_int(TyIs) => match &tcx.sess.target.target.target_pointer_width[..] {
24302430
"32" => ty_int(TyI32),
24312431
"64" => ty_int(TyI64),
24322432
_ => panic!("unsupported target word size")
24332433
},
2434-
ty_uint(TyUs(_)) => match &tcx.sess.target.target.target_pointer_width[..] {
2434+
ty_uint(TyUs) => match &tcx.sess.target.target.target_pointer_width[..] {
24352435
"32" => ty_uint(TyU32),
24362436
"64" => ty_uint(TyU64),
24372437
_ => panic!("unsupported target word size")

src/librustc_trans/trans/type_.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Type {
118118

119119
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
120120
match t {
121-
ast::TyIs(_) => ccx.int_type(),
121+
ast::TyIs => ccx.int_type(),
122122
ast::TyI8 => Type::i8(ccx),
123123
ast::TyI16 => Type::i16(ccx),
124124
ast::TyI32 => Type::i32(ccx),
@@ -128,7 +128,7 @@ impl Type {
128128

129129
pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
130130
match t {
131-
ast::TyUs(_) => ccx.int_type(),
131+
ast::TyUs => ccx.int_type(),
132132
ast::TyU8 => Type::i8(ccx),
133133
ast::TyU16 => Type::i16(ccx),
134134
ast::TyU32 => Type::i32(ccx),

src/librustc_trans/trans/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
361361
let unsized_part = unsized_part_of_type(cx.tcx(), ty);
362362
let info_ty = match unsized_part.sty {
363363
ty::ty_str | ty::ty_vec(..) => {
364-
Type::uint_from_ty(cx, ast::TyUs(false))
364+
Type::uint_from_ty(cx, ast::TyUs)
365365
}
366366
ty::ty_trait(_) => Type::vtable_ptr(cx),
367367
_ => panic!("Unexpected type returned from \

src/librustc_typeck/check/method/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
325325
let lang_def_id = self.tcx().lang_items.i64_impl();
326326
self.assemble_inherent_impl_for_primitive(lang_def_id);
327327
}
328-
ty::ty_int(ast::TyIs(_)) => {
328+
ty::ty_int(ast::TyIs) => {
329329
let lang_def_id = self.tcx().lang_items.isize_impl();
330330
self.assemble_inherent_impl_for_primitive(lang_def_id);
331331
}
@@ -345,7 +345,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
345345
let lang_def_id = self.tcx().lang_items.u64_impl();
346346
self.assemble_inherent_impl_for_primitive(lang_def_id);
347347
}
348-
ty::ty_uint(ast::TyUs(_)) => {
348+
ty::ty_uint(ast::TyUs) => {
349349
let lang_def_id = self.tcx().lang_items.usize_impl();
350350
self.assemble_inherent_impl_for_primitive(lang_def_id);
351351
}

src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
21862186

21872187
// First, try built-in indexing.
21882188
match (ty::index(adjusted_ty), &index_ty.sty) {
2189-
(Some(ty), &ty::ty_uint(ast::TyUs(_))) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
2189+
(Some(ty), &ty::ty_uint(ast::TyUs)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
21902190
debug!("try_index_step: success, using built-in indexing");
21912191
fcx.write_adjustment(base_expr.id, base_expr.span, ty::AdjustDerefRef(adjustment));
21922192
return Some((tcx.types.uint, ty));
@@ -4602,7 +4602,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
46024602
ast::TyU16 => disr as u16 as Disr == disr,
46034603
ast::TyU32 => disr as u32 as Disr == disr,
46044604
ast::TyU64 => disr as u64 as Disr == disr,
4605-
ast::TyUs(_) => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
4605+
ast::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
46064606
}
46074607
}
46084608
fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
@@ -4611,7 +4611,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
46114611
ast::TyI16 => disr as i16 as Disr == disr,
46124612
ast::TyI32 => disr as i32 as Disr == disr,
46134613
ast::TyI64 => disr as i64 as Disr == disr,
4614-
ast::TyIs(_) => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
4614+
ast::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
46154615
}
46164616
}
46174617
match ty {

src/librustc_typeck/coherence/orphan.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
143143
"i64",
144144
item.span);
145145
}
146-
ty::ty_int(ast::TyIs(_)) => {
146+
ty::ty_int(ast::TyIs) => {
147147
self.check_primitive_impl(def_id,
148148
self.tcx.lang_items.isize_impl(),
149149
"isize",
@@ -178,7 +178,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
178178
"u64",
179179
item.span);
180180
}
181-
ty::ty_uint(ast::TyUs(_)) => {
181+
ty::ty_uint(ast::TyUs) => {
182182
self.check_primitive_impl(def_id,
183183
self.tcx.lang_items.usize_impl(),
184184
"usize",

0 commit comments

Comments
 (0)