Skip to content

Commit 149f002

Browse files
committed
Auto merge of #22497 - nikomatsakis:suffixes, r=alexcrichton
The old suffixes now issue warnings unless a feature-gate is given. Fixes #22496. r? @alexcrichton
2 parents 2299235 + 811c48f commit 149f002

File tree

351 files changed

+1027
-1031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+1027
-1031
lines changed

Diff for: src/doc/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ use std::sync::{Arc,Mutex};
480480
fn main() {
481481
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));
482482
483-
for i in 0us..3 {
483+
for i in 0..3 {
484484
let number = numbers.clone();
485485
Thread::spawn(move || {
486486
let mut array = number.lock().unwrap();
@@ -541,7 +541,7 @@ use std::thread::Thread;
541541
fn main() {
542542
let vec = vec![1, 2, 3];
543543
544-
for i in 0us..3 {
544+
for i in 0..3 {
545545
Thread::spawn(move || {
546546
println!("{}", vec[i]);
547547
});

Diff for: src/doc/reference.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,9 @@ An _integer literal_ has one of four forms:
465465

466466
Like any literal, an integer literal may be followed (immediately,
467467
without any spaces) by an _integer suffix_, which forcibly sets the
468-
type of the literal. There are 10 valid values for an integer suffix:
469-
470-
* Each of the signed and unsigned machine types `u8`, `i8`,
471-
`u16`, `i16`, `u32`, `i32`, `u64` and `i64`
472-
give the literal the corresponding machine type.
473-
* The `is` and `us` suffixes give the literal type `isize` or `usize`,
474-
respectively.
468+
type of the literal. The integer suffix must be the name of one of the
469+
integral types: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`,
470+
`isize`, or `usize`.
475471

476472
The type of an _unsuffixed_ integer literal is determined by type inference.
477473
If an integer type can be _uniquely_ determined from the surrounding program
@@ -489,7 +485,7 @@ Examples of integer literals of various forms:
489485
0xff_u8; // type u8
490486
0o70_i16; // type i16
491487
0b1111_1111_1001_0000_i32; // type i32
492-
0us; // type usize
488+
0usize; // type usize
493489
```
494490

495491
##### Floating-point literals
@@ -1001,8 +997,8 @@ fn foo<T>(_: T){}
1001997
fn bar(map1: HashMap<String, usize>, map2: hash_map::HashMap<String, usize>){}
1002998
1003999
fn main() {
1004-
// Equivalent to 'std::iter::range_step(0us, 10, 2);'
1005-
range_step(0us, 10, 2);
1000+
// Equivalent to 'std::iter::range_step(0, 10, 2);'
1001+
range_step(0, 10, 2);
10061002
10071003
// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
10081004
// std::option::Option::None]);'
@@ -3126,7 +3122,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
31263122
An example:
31273123

31283124
```
3129-
let mut i = 0us;
3125+
let mut i = 0;
31303126
31313127
while i < 10 {
31323128
println!("hello");
@@ -3206,7 +3202,7 @@ An example of a for loop over a series of integers:
32063202

32073203
```
32083204
# fn bar(b:usize) { }
3209-
for i in 0us..256 {
3205+
for i in 0..256 {
32103206
bar(i);
32113207
}
32123208
```

Diff for: src/doc/trpl/concurrency.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ use std::time::Duration;
244244
fn main() {
245245
let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
246246
247-
for i in 0us..2 {
247+
for i in 0..2 {
248248
let data = data.clone();
249249
thread::spawn(move || {
250250
let mut data = data.lock().unwrap();
@@ -267,7 +267,7 @@ thread more closely:
267267
# use std::time::Duration;
268268
# fn main() {
269269
# let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
270-
# for i in 0us..2 {
270+
# for i in 0..2 {
271271
# let data = data.clone();
272272
thread::spawn(move || {
273273
let mut data = data.lock().unwrap();

Diff for: src/libcollections/fmt.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
//! Some examples of the `format!` extension are:
2828
//!
2929
//! ```
30-
//! format!("Hello"); // => "Hello"
31-
//! format!("Hello, {}!", "world"); // => "Hello, world!"
30+
//! format!("Hello"); // => "Hello"
31+
//! format!("Hello, {}!", "world"); // => "Hello, world!"
3232
//! format!("The number is {}", 1); // => "The number is 1"
33-
//! format!("{:?}", (3, 4)); // => "(3, 4)"
33+
//! format!("{:?}", (3, 4)); // => "(3, 4)"
3434
//! format!("{value}", value=4); // => "4"
35-
//! format!("{} {}", 1, 2u); // => "1 2"
35+
//! format!("{} {}", 1, 2); // => "1 2"
3636
//! ```
3737
//!
3838
//! From these, you can see that the first argument is a format string. It is

Diff for: src/libcore/char.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -441,18 +441,18 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
441441
dst[0] = code as u8;
442442
Some(1)
443443
} else if code < MAX_TWO_B && dst.len() >= 2 {
444-
dst[0] = (code >> 6u & 0x1F_u32) as u8 | TAG_TWO_B;
444+
dst[0] = (code >> 6 & 0x1F_u32) as u8 | TAG_TWO_B;
445445
dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT;
446446
Some(2)
447447
} else if code < MAX_THREE_B && dst.len() >= 3 {
448-
dst[0] = (code >> 12u & 0x0F_u32) as u8 | TAG_THREE_B;
449-
dst[1] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT;
448+
dst[0] = (code >> 12 & 0x0F_u32) as u8 | TAG_THREE_B;
449+
dst[1] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
450450
dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT;
451451
Some(3)
452452
} else if dst.len() >= 4 {
453-
dst[0] = (code >> 18u & 0x07_u32) as u8 | TAG_FOUR_B;
454-
dst[1] = (code >> 12u & 0x3F_u32) as u8 | TAG_CONT;
455-
dst[2] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT;
453+
dst[0] = (code >> 18 & 0x07_u32) as u8 | TAG_FOUR_B;
454+
dst[1] = (code >> 12 & 0x3F_u32) as u8 | TAG_CONT;
455+
dst[2] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
456456
dst[3] = (code & 0x3F_u32) as u8 | TAG_CONT;
457457
Some(4)
458458
} else {

Diff for: src/libcoretest/any.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn any_referenced() {
3535

3636
#[test]
3737
fn any_owning() {
38-
let (a, b, c) = (box 5us as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
38+
let (a, b, c) = (box 5_usize as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
3939

4040
assert!(a.is::<uint>());
4141
assert!(!b.is::<uint>());
@@ -52,7 +52,7 @@ fn any_owning() {
5252

5353
#[test]
5454
fn any_downcast_ref() {
55-
let a = &5us as &Any;
55+
let a = &5_usize as &Any;
5656

5757
match a.downcast_ref::<uint>() {
5858
Some(&5) => {}
@@ -67,8 +67,8 @@ fn any_downcast_ref() {
6767

6868
#[test]
6969
fn any_downcast_mut() {
70-
let mut a = 5us;
71-
let mut b = box 7us;
70+
let mut a = 5_usize;
71+
let mut b = box 7_usize;
7272

7373
let a_r = &mut a as &mut Any;
7474
let tmp: &mut uint = &mut *b;
@@ -113,7 +113,7 @@ fn any_downcast_mut() {
113113

114114
#[test]
115115
fn any_fixed_vec() {
116-
let test = [0us; 8];
116+
let test = [0_usize; 8];
117117
let test = &test as &Any;
118118
assert!(test.is::<[uint; 8]>());
119119
assert!(!test.is::<[uint; 10]>());

Diff for: src/libcoretest/fmt/num.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,68 +16,68 @@ fn test_format_int() {
1616
// Formatting integers should select the right implementation based off
1717
// the type of the argument. Also, hex/octal/binary should be defined
1818
// for integers, but they shouldn't emit the negative sign.
19-
assert!(format!("{}", 1is) == "1");
19+
assert!(format!("{}", 1isize) == "1");
2020
assert!(format!("{}", 1i8) == "1");
2121
assert!(format!("{}", 1i16) == "1");
2222
assert!(format!("{}", 1i32) == "1");
2323
assert!(format!("{}", 1i64) == "1");
24-
assert!(format!("{}", -1is) == "-1");
24+
assert!(format!("{}", -1isize) == "-1");
2525
assert!(format!("{}", -1i8) == "-1");
2626
assert!(format!("{}", -1i16) == "-1");
2727
assert!(format!("{}", -1i32) == "-1");
2828
assert!(format!("{}", -1i64) == "-1");
29-
assert!(format!("{:?}", 1is) == "1");
29+
assert!(format!("{:?}", 1isize) == "1");
3030
assert!(format!("{:?}", 1i8) == "1");
3131
assert!(format!("{:?}", 1i16) == "1");
3232
assert!(format!("{:?}", 1i32) == "1");
3333
assert!(format!("{:?}", 1i64) == "1");
34-
assert!(format!("{:b}", 1is) == "1");
34+
assert!(format!("{:b}", 1isize) == "1");
3535
assert!(format!("{:b}", 1i8) == "1");
3636
assert!(format!("{:b}", 1i16) == "1");
3737
assert!(format!("{:b}", 1i32) == "1");
3838
assert!(format!("{:b}", 1i64) == "1");
39-
assert!(format!("{:x}", 1is) == "1");
39+
assert!(format!("{:x}", 1isize) == "1");
4040
assert!(format!("{:x}", 1i8) == "1");
4141
assert!(format!("{:x}", 1i16) == "1");
4242
assert!(format!("{:x}", 1i32) == "1");
4343
assert!(format!("{:x}", 1i64) == "1");
44-
assert!(format!("{:X}", 1is) == "1");
44+
assert!(format!("{:X}", 1isize) == "1");
4545
assert!(format!("{:X}", 1i8) == "1");
4646
assert!(format!("{:X}", 1i16) == "1");
4747
assert!(format!("{:X}", 1i32) == "1");
4848
assert!(format!("{:X}", 1i64) == "1");
49-
assert!(format!("{:o}", 1is) == "1");
49+
assert!(format!("{:o}", 1isize) == "1");
5050
assert!(format!("{:o}", 1i8) == "1");
5151
assert!(format!("{:o}", 1i16) == "1");
5252
assert!(format!("{:o}", 1i32) == "1");
5353
assert!(format!("{:o}", 1i64) == "1");
5454

55-
assert!(format!("{}", 1us) == "1");
55+
assert!(format!("{}", 1usize) == "1");
5656
assert!(format!("{}", 1u8) == "1");
5757
assert!(format!("{}", 1u16) == "1");
5858
assert!(format!("{}", 1u32) == "1");
5959
assert!(format!("{}", 1u64) == "1");
60-
assert!(format!("{:?}", 1us) == "1");
60+
assert!(format!("{:?}", 1usize) == "1");
6161
assert!(format!("{:?}", 1u8) == "1");
6262
assert!(format!("{:?}", 1u16) == "1");
6363
assert!(format!("{:?}", 1u32) == "1");
6464
assert!(format!("{:?}", 1u64) == "1");
65-
assert!(format!("{:b}", 1us) == "1");
65+
assert!(format!("{:b}", 1usize) == "1");
6666
assert!(format!("{:b}", 1u8) == "1");
6767
assert!(format!("{:b}", 1u16) == "1");
6868
assert!(format!("{:b}", 1u32) == "1");
6969
assert!(format!("{:b}", 1u64) == "1");
70-
assert!(format!("{:x}", 1us) == "1");
70+
assert!(format!("{:x}", 1usize) == "1");
7171
assert!(format!("{:x}", 1u8) == "1");
7272
assert!(format!("{:x}", 1u16) == "1");
7373
assert!(format!("{:x}", 1u32) == "1");
7474
assert!(format!("{:x}", 1u64) == "1");
75-
assert!(format!("{:X}", 1us) == "1");
75+
assert!(format!("{:X}", 1usize) == "1");
7676
assert!(format!("{:X}", 1u8) == "1");
7777
assert!(format!("{:X}", 1u16) == "1");
7878
assert!(format!("{:X}", 1u32) == "1");
7979
assert!(format!("{:X}", 1u64) == "1");
80-
assert!(format!("{:o}", 1us) == "1");
80+
assert!(format!("{:o}", 1usize) == "1");
8181
assert!(format!("{:o}", 1u8) == "1");
8282
assert!(format!("{:o}", 1u16) == "1");
8383
assert!(format!("{:o}", 1u32) == "1");

Diff for: src/libcoretest/hash/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ fn test_writer_hasher() {
4646

4747
assert_eq!(hash(&()), 0);
4848

49-
assert_eq!(hash(&5u8), 5);
50-
assert_eq!(hash(&5u16), 5);
51-
assert_eq!(hash(&5u32), 5);
52-
assert_eq!(hash(&5u64), 5);
53-
assert_eq!(hash(&5us), 5);
54-
55-
assert_eq!(hash(&5i8), 5);
56-
assert_eq!(hash(&5i16), 5);
57-
assert_eq!(hash(&5i32), 5);
58-
assert_eq!(hash(&5i64), 5);
59-
assert_eq!(hash(&5is), 5);
49+
assert_eq!(hash(&5_u8), 5);
50+
assert_eq!(hash(&5_u16), 5);
51+
assert_eq!(hash(&5_u32), 5);
52+
assert_eq!(hash(&5_u64), 5);
53+
assert_eq!(hash(&5_usize), 5);
54+
55+
assert_eq!(hash(&5_i8), 5);
56+
assert_eq!(hash(&5_i16), 5);
57+
assert_eq!(hash(&5_i32), 5);
58+
assert_eq!(hash(&5_i64), 5);
59+
assert_eq!(hash(&5_isize), 5);
6060

6161
assert_eq!(hash(&false), 0);
6262
assert_eq!(hash(&true), 1);
@@ -76,12 +76,12 @@ fn test_writer_hasher() {
7676
// FIXME (#18248) Add tests for hashing Rc<str> and Rc<[T]>
7777

7878
unsafe {
79-
let ptr: *const i32 = mem::transmute(5us);
79+
let ptr: *const i32 = mem::transmute(5_usize);
8080
assert_eq!(hash(&ptr), 5);
8181
}
8282

8383
unsafe {
84-
let ptr: *mut i32 = mem::transmute(5us);
84+
let ptr: *mut i32 = mem::transmute(5_usize);
8585
assert_eq!(hash(&ptr), 5);
8686
}
8787
}

Diff for: src/liblibc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ pub mod types {
19301930
pub iSecurityScheme: c_int,
19311931
pub dwMessageSize: DWORD,
19321932
pub dwProviderReserved: DWORD,
1933-
pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1us],
1933+
pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1],
19341934
}
19351935

19361936
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;

Diff for: src/librbml/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,10 @@ pub mod writer {
713713
match size {
714714
1 => w.write_all(&[0x80u8 | (n as u8)]),
715715
2 => w.write_all(&[0x40u8 | ((n >> 8) as u8), n as u8]),
716-
3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8_u) as u8,
716+
3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8) as u8,
717717
n as u8]),
718-
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16_u) as u8,
719-
(n >> 8_u) as u8, n as u8]),
718+
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16) as u8,
719+
(n >> 8) as u8, n as u8]),
720720
_ => Err(old_io::IoError {
721721
kind: old_io::OtherIoError,
722722
desc: "int too big",
@@ -863,7 +863,7 @@ pub mod writer {
863863
impl<'a, W: Writer + Seek> Encoder<'a, W> {
864864
// used internally to emit things like the vector length and so on
865865
fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) -> EncodeResult {
866-
assert!(v <= 0xFFFF_FFFF_u);
866+
assert!(v <= 0xFFFF_FFFF);
867867
self.wr_tagged_u32(t as uint, v as u32)
868868
}
869869

Diff for: src/librustc/lint/builtin.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,12 @@ pub struct BoxPointers;
494494
impl BoxPointers {
495495
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
496496
span: Span, ty: Ty<'tcx>) {
497-
let mut n_uniq = 0us;
497+
let mut n_uniq: usize = 0;
498498
ty::fold_ty(cx.tcx, ty, |t| {
499499
match t.sty {
500500
ty::ty_uniq(_) => {
501501
n_uniq += 1;
502502
}
503-
504503
_ => ()
505504
};
506505
t

Diff for: src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>,
560560
pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
561561
let mut s = typ.repr(cx).to_string();
562562
if s.len() >= 32 {
563-
s = (&s[0u..32]).to_string();
563+
s = (&s[0..32]).to_string();
564564
}
565565
return s;
566566
}

Diff for: src/librustc_trans/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
6262
let file = path.filename_str().unwrap();
6363
let file = &file[3..file.len() - 5]; // chop off lib/.rlib
6464
debug!("reading {}", file);
65-
for i in iter::count(0us, 1) {
65+
for i in iter::count(0, 1) {
6666
let bc_encoded = time(sess.time_passes(),
6767
&format!("check for {}.{}.bytecode.deflate", name, i),
6868
(),

Diff for: src/librustc_trans/trans/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
443443

444444
pub fn env_arg_pos(&self) -> uint {
445445
if self.caller_expects_out_pointer {
446-
1u
446+
1
447447
} else {
448-
0u
448+
0
449449
}
450450
}
451451

Diff for: src/librustc_trans/trans/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
467467
PointerCast(bcx, lval.val, type_of::type_of(bcx.ccx(), unsized_ty).ptr_to())
468468
}
469469
ty::UnsizeLength(..) => {
470-
GEPi(bcx, lval.val, &[0u, 0u])
470+
GEPi(bcx, lval.val, &[0, 0])
471471
}
472472
};
473473

0 commit comments

Comments
 (0)