Skip to content

Commit b63f897

Browse files
authored
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
2 parents d9d5c66 + 210ac01 commit b63f897

File tree

35 files changed

+100
-100
lines changed

35 files changed

+100
-100
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
155155
Bool(value)
156156
});
157157

158-
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Is, I8, I16, I32, I64, I128 });
159-
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Us, U8, U16, U32, U64, U128 });
158+
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
159+
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
160160
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
161161
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
162162
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });

src/librustc/ty/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,13 +754,13 @@ impl<'tcx> CommonTypes<'tcx> {
754754
char: mk(TyChar),
755755
never: mk(TyNever),
756756
err: mk(TyError),
757-
isize: mk(TyInt(ast::IntTy::Is)),
757+
isize: mk(TyInt(ast::IntTy::Isize)),
758758
i8: mk(TyInt(ast::IntTy::I8)),
759759
i16: mk(TyInt(ast::IntTy::I16)),
760760
i32: mk(TyInt(ast::IntTy::I32)),
761761
i64: mk(TyInt(ast::IntTy::I64)),
762762
i128: mk(TyInt(ast::IntTy::I128)),
763-
usize: mk(TyUint(ast::UintTy::Us)),
763+
usize: mk(TyUint(ast::UintTy::Usize)),
764764
u8: mk(TyUint(ast::UintTy::U8)),
765765
u16: mk(TyUint(ast::UintTy::U16)),
766766
u32: mk(TyUint(ast::UintTy::U32)),
@@ -1912,7 +1912,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19121912

19131913
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {
19141914
match tm {
1915-
ast::IntTy::Is => self.types.isize,
1915+
ast::IntTy::Isize => self.types.isize,
19161916
ast::IntTy::I8 => self.types.i8,
19171917
ast::IntTy::I16 => self.types.i16,
19181918
ast::IntTy::I32 => self.types.i32,
@@ -1923,7 +1923,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
19231923

19241924
pub fn mk_mach_uint(self, tm: ast::UintTy) -> Ty<'tcx> {
19251925
match tm {
1926-
ast::UintTy::Us => self.types.usize,
1926+
ast::UintTy::Usize => self.types.usize,
19271927
ast::UintTy::U8 => self.types.u8,
19281928
ast::UintTy::U16 => self.types.u16,
19291929
ast::UintTy::U32 => self.types.u32,

src/librustc/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl<'a, 'tcx> Integer {
520520
attr::SignedInt(IntTy::I32) | attr::UnsignedInt(UintTy::U32) => I32,
521521
attr::SignedInt(IntTy::I64) | attr::UnsignedInt(UintTy::U64) => I64,
522522
attr::SignedInt(IntTy::I128) | attr::UnsignedInt(UintTy::U128) => I128,
523-
attr::SignedInt(IntTy::Is) | attr::UnsignedInt(UintTy::Us) => {
523+
attr::SignedInt(IntTy::Isize) | attr::UnsignedInt(UintTy::Usize) => {
524524
dl.ptr_sized_integer()
525525
}
526526
}

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ impl ReprOptions {
15751575
pub fn linear(&self) -> bool { self.flags.contains(ReprFlags::IS_LINEAR) }
15761576

15771577
pub fn discr_type(&self) -> attr::IntType {
1578-
self.int.unwrap_or(attr::SignedInt(ast::IntTy::Is))
1578+
self.int.unwrap_or(attr::SignedInt(ast::IntTy::Isize))
15791579
}
15801580

15811581
/// Returns true if this `#[repr()]` should inhabit "smart enum

src/librustc/ty/sty.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,13 +1478,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
14781478
}
14791479
}
14801480

1481-
pub fn is_uint(&self) -> bool {
1482-
match self.sty {
1483-
TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true,
1484-
_ => false
1485-
}
1486-
}
1487-
14881481
pub fn is_char(&self) -> bool {
14891482
match self.sty {
14901483
TyChar => true,
@@ -1512,7 +1505,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
15121505

15131506
pub fn is_machine(&self) -> bool {
15141507
match self.sty {
1515-
TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false,
1508+
TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false,
15161509
TyInt(..) | TyUint(..) | TyFloat(..) => true,
15171510
_ => false,
15181511
}

src/librustc/ty/util.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ macro_rules! typed_literal {
5555
SignedInt(ast::IntTy::I32) => ConstInt::I32($lit),
5656
SignedInt(ast::IntTy::I64) => ConstInt::I64($lit),
5757
SignedInt(ast::IntTy::I128) => ConstInt::I128($lit),
58-
SignedInt(ast::IntTy::Is) => match $tcx.sess.target.isize_ty {
58+
SignedInt(ast::IntTy::Isize) => match $tcx.sess.target.isize_ty {
5959
ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16($lit)),
6060
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32($lit)),
6161
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64($lit)),
@@ -66,7 +66,7 @@ macro_rules! typed_literal {
6666
UnsignedInt(ast::UintTy::U32) => ConstInt::U32($lit),
6767
UnsignedInt(ast::UintTy::U64) => ConstInt::U64($lit),
6868
UnsignedInt(ast::UintTy::U128) => ConstInt::U128($lit),
69-
UnsignedInt(ast::UintTy::Us) => match $tcx.sess.target.usize_ty {
69+
UnsignedInt(ast::UintTy::Usize) => match $tcx.sess.target.usize_ty {
7070
ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16($lit)),
7171
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32($lit)),
7272
ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64($lit)),
@@ -84,13 +84,13 @@ impl IntTypeExt for attr::IntType {
8484
SignedInt(ast::IntTy::I32) => tcx.types.i32,
8585
SignedInt(ast::IntTy::I64) => tcx.types.i64,
8686
SignedInt(ast::IntTy::I128) => tcx.types.i128,
87-
SignedInt(ast::IntTy::Is) => tcx.types.isize,
87+
SignedInt(ast::IntTy::Isize) => tcx.types.isize,
8888
UnsignedInt(ast::UintTy::U8) => tcx.types.u8,
8989
UnsignedInt(ast::UintTy::U16) => tcx.types.u16,
9090
UnsignedInt(ast::UintTy::U32) => tcx.types.u32,
9191
UnsignedInt(ast::UintTy::U64) => tcx.types.u64,
9292
UnsignedInt(ast::UintTy::U128) => tcx.types.u128,
93-
UnsignedInt(ast::UintTy::Us) => tcx.types.usize,
93+
UnsignedInt(ast::UintTy::Usize) => tcx.types.usize,
9494
}
9595
}
9696

@@ -105,13 +105,13 @@ impl IntTypeExt for attr::IntType {
105105
(SignedInt(ast::IntTy::I32), ConstInt::I32(_)) => {},
106106
(SignedInt(ast::IntTy::I64), ConstInt::I64(_)) => {},
107107
(SignedInt(ast::IntTy::I128), ConstInt::I128(_)) => {},
108-
(SignedInt(ast::IntTy::Is), ConstInt::Isize(_)) => {},
108+
(SignedInt(ast::IntTy::Isize), ConstInt::Isize(_)) => {},
109109
(UnsignedInt(ast::UintTy::U8), ConstInt::U8(_)) => {},
110110
(UnsignedInt(ast::UintTy::U16), ConstInt::U16(_)) => {},
111111
(UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {},
112112
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
113113
(UnsignedInt(ast::UintTy::U128), ConstInt::U128(_)) => {},
114-
(UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {},
114+
(UnsignedInt(ast::UintTy::Usize), ConstInt::Usize(_)) => {},
115115
_ => bug!("disr type mismatch: {:?} vs {:?}", self, val),
116116
}
117117
}

src/librustc_const_eval/eval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
133133
(&LitKind::Int(I128_OVERFLOW, Signed(IntTy::I128)), _) => {
134134
Some(I128(i128::min_value()))
135135
},
136-
(&LitKind::Int(n, _), &ty::TyInt(IntTy::Is)) |
137-
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {
136+
(&LitKind::Int(n, _), &ty::TyInt(IntTy::Isize)) |
137+
(&LitKind::Int(n, Signed(IntTy::Isize)), _) => {
138138
match tcx.sess.target.isize_ty {
139139
IntTy::I16 => if n == I16_OVERFLOW {
140140
Some(Isize(Is16(i16::min_value())))
@@ -478,15 +478,15 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
478478
ty::TyInt(ast::IntTy::I32) => Ok(Integral(I32(v as i128 as i32))),
479479
ty::TyInt(ast::IntTy::I64) => Ok(Integral(I64(v as i128 as i64))),
480480
ty::TyInt(ast::IntTy::I128) => Ok(Integral(I128(v as i128))),
481-
ty::TyInt(ast::IntTy::Is) => {
481+
ty::TyInt(ast::IntTy::Isize) => {
482482
Ok(Integral(Isize(ConstIsize::new_truncating(v as i128, tcx.sess.target.isize_ty))))
483483
},
484484
ty::TyUint(ast::UintTy::U8) => Ok(Integral(U8(v as u8))),
485485
ty::TyUint(ast::UintTy::U16) => Ok(Integral(U16(v as u16))),
486486
ty::TyUint(ast::UintTy::U32) => Ok(Integral(U32(v as u32))),
487487
ty::TyUint(ast::UintTy::U64) => Ok(Integral(U64(v as u64))),
488488
ty::TyUint(ast::UintTy::U128) => Ok(Integral(U128(v as u128))),
489-
ty::TyUint(ast::UintTy::Us) => {
489+
ty::TyUint(ast::UintTy::Usize) => {
490490
Ok(Integral(Usize(ConstUsize::new_truncating(v, tcx.sess.target.usize_ty))))
491491
},
492492
ty::TyFloat(fty) => {

src/librustc_const_math/err.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ impl ConstMathErr {
7575
ULitOutOfRange(ast::UintTy::U32) => "literal out of range for u32",
7676
ULitOutOfRange(ast::UintTy::U64) => "literal out of range for u64",
7777
ULitOutOfRange(ast::UintTy::U128) => "literal out of range for u128",
78-
ULitOutOfRange(ast::UintTy::Us) => "literal out of range for usize",
78+
ULitOutOfRange(ast::UintTy::Usize) => "literal out of range for usize",
7979
LitOutOfRange(ast::IntTy::I8) => "literal out of range for i8",
8080
LitOutOfRange(ast::IntTy::I16) => "literal out of range for i16",
8181
LitOutOfRange(ast::IntTy::I32) => "literal out of range for i32",
8282
LitOutOfRange(ast::IntTy::I64) => "literal out of range for i64",
8383
LitOutOfRange(ast::IntTy::I128) => "literal out of range for i128",
84-
LitOutOfRange(ast::IntTy::Is) => "literal out of range for isize",
84+
LitOutOfRange(ast::IntTy::Isize) => "literal out of range for isize",
8585
}
8686
}
8787
}

src/librustc_const_math/int.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::cmp::Ordering;
1212
use syntax::attr::IntType;
1313
use syntax::ast::{IntTy, UintTy};
1414

15-
use super::is::*;
16-
use super::us::*;
15+
use super::isize::*;
16+
use super::usize::*;
1717
use super::err::*;
1818

1919
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, Hash, Eq, PartialEq)]
@@ -83,7 +83,7 @@ impl ConstInt {
8383
UintTy::U16 if val <= ubounds::U16MAX => Some(U16(val as u16)),
8484
UintTy::U32 if val <= ubounds::U32MAX => Some(U32(val as u32)),
8585
UintTy::U64 if val <= ubounds::U64MAX => Some(U64(val as u64)),
86-
UintTy::Us if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok()
86+
UintTy::Usize if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok()
8787
.map(Usize),
8888
UintTy::U128 => Some(U128(val)),
8989
_ => None
@@ -98,7 +98,7 @@ impl ConstInt {
9898
IntTy::I16 if val <= ibounds::I16MAX => Some(I16(val as i16)),
9999
IntTy::I32 if val <= ibounds::I32MAX => Some(I32(val as i32)),
100100
IntTy::I64 if val <= ibounds::I64MAX => Some(I64(val as i64)),
101-
IntTy::Is if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok()
101+
IntTy::Isize if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok()
102102
.map(Isize),
103103
IntTy::I128 => Some(I128(val)),
104104
_ => None
@@ -112,7 +112,7 @@ impl ConstInt {
112112
UintTy::U16 => U16(val as u16),
113113
UintTy::U32 => U32(val as u32),
114114
UintTy::U64 => U64(val as u64),
115-
UintTy::Us => Usize(ConstUsize::new_truncating(val, usize_ty)),
115+
UintTy::Usize => Usize(ConstUsize::new_truncating(val, usize_ty)),
116116
UintTy::U128 => U128(val)
117117
}
118118
}
@@ -124,7 +124,7 @@ impl ConstInt {
124124
IntTy::I16 => I16(val as i16),
125125
IntTy::I32 => I32(val as i32),
126126
IntTy::I64 => I64(val as i64),
127-
IntTy::Is => Isize(ConstIsize::new_truncating(val, isize_ty)),
127+
IntTy::Isize => Isize(ConstIsize::new_truncating(val, isize_ty)),
128128
IntTy::I128 => I128(val)
129129
}
130130
}
@@ -280,13 +280,13 @@ impl ConstInt {
280280
ConstInt::I32(_) => IntType::SignedInt(IntTy::I32),
281281
ConstInt::I64(_) => IntType::SignedInt(IntTy::I64),
282282
ConstInt::I128(_) => IntType::SignedInt(IntTy::I128),
283-
ConstInt::Isize(_) => IntType::SignedInt(IntTy::Is),
283+
ConstInt::Isize(_) => IntType::SignedInt(IntTy::Isize),
284284
ConstInt::U8(_) => IntType::UnsignedInt(UintTy::U8),
285285
ConstInt::U16(_) => IntType::UnsignedInt(UintTy::U16),
286286
ConstInt::U32(_) => IntType::UnsignedInt(UintTy::U32),
287287
ConstInt::U64(_) => IntType::UnsignedInt(UintTy::U64),
288288
ConstInt::U128(_) => IntType::UnsignedInt(UintTy::U128),
289-
ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Us),
289+
ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Usize),
290290
}
291291
}
292292
}

src/librustc_const_math/is.rs renamed to src/librustc_const_math/isize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ impl ConstIsize {
3838
pub fn new(i: i64, isize_ty: ast::IntTy) -> Result<Self, ConstMathErr> {
3939
match isize_ty {
4040
ast::IntTy::I16 if i as i16 as i64 == i => Ok(Is16(i as i16)),
41-
ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Is)),
41+
ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Isize)),
4242
ast::IntTy::I32 if i as i32 as i64 == i => Ok(Is32(i as i32)),
43-
ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Is)),
43+
ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Isize)),
4444
ast::IntTy::I64 => Ok(Is64(i)),
4545
_ => unreachable!(),
4646
}

0 commit comments

Comments
 (0)