Skip to content

Commit

Permalink
rollup merge of rust-lang#22497: nikomatsakis/suffixes
Browse files Browse the repository at this point in the history
Conflicts:
	src/librustc_trans/trans/tvec.rs
  • Loading branch information
alexcrichton committed Feb 18, 2015
2 parents 5a32b4a + 811c48f commit 5250a82
Show file tree
Hide file tree
Showing 351 changed files with 1,027 additions and 1,030 deletions.
4 changes: 2 additions & 2 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ use std::sync::{Arc,Mutex};
fn main() {
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));
for i in 0us..3 {
for i in 0..3 {
let number = numbers.clone();
Thread::spawn(move || {
let mut array = number.lock().unwrap();
Expand Down Expand Up @@ -541,7 +541,7 @@ use std::thread::Thread;
fn main() {
let vec = vec![1, 2, 3];
for i in 0us..3 {
for i in 0..3 {
Thread::spawn(move || {
println!("{}", vec[i]);
});
Expand Down
20 changes: 8 additions & 12 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,9 @@ An _integer literal_ has one of four forms:

Like any literal, an integer literal may be followed (immediately,
without any spaces) by an _integer suffix_, which forcibly sets the
type of the literal. There are 10 valid values for an integer suffix:

* Each of the signed and unsigned machine types `u8`, `i8`,
`u16`, `i16`, `u32`, `i32`, `u64` and `i64`
give the literal the corresponding machine type.
* The `is` and `us` suffixes give the literal type `isize` or `usize`,
respectively.
type of the literal. The integer suffix must be the name of one of the
integral types: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`,
`isize`, or `usize`.

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

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

```
let mut i = 0us;
let mut i = 0;
while i < 10 {
println!("hello");
Expand Down Expand Up @@ -3206,7 +3202,7 @@ An example of a for loop over a series of integers:

```
# fn bar(b:usize) { }
for i in 0us..256 {
for i in 0..256 {
bar(i);
}
```
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ use std::time::Duration;
fn main() {
let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
for i in 0us..2 {
for i in 0..2 {
let data = data.clone();
thread::spawn(move || {
let mut data = data.lock().unwrap();
Expand All @@ -267,7 +267,7 @@ thread more closely:
# use std::time::Duration;
# fn main() {
# let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
# for i in 0us..2 {
# for i in 0..2 {
# let data = data.clone();
thread::spawn(move || {
let mut data = data.lock().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
//! Some examples of the `format!` extension are:
//!
//! ```
//! format!("Hello"); // => "Hello"
//! format!("Hello, {}!", "world"); // => "Hello, world!"
//! format!("Hello"); // => "Hello"
//! format!("Hello, {}!", "world"); // => "Hello, world!"
//! format!("The number is {}", 1); // => "The number is 1"
//! format!("{:?}", (3, 4)); // => "(3, 4)"
//! format!("{:?}", (3, 4)); // => "(3, 4)"
//! format!("{value}", value=4); // => "4"
//! format!("{} {}", 1, 2u); // => "1 2"
//! format!("{} {}", 1, 2); // => "1 2"
//! ```
//!
//! From these, you can see that the first argument is a format string. It is
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,18 +441,18 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
dst[0] = code as u8;
Some(1)
} else if code < MAX_TWO_B && dst.len() >= 2 {
dst[0] = (code >> 6u & 0x1F_u32) as u8 | TAG_TWO_B;
dst[0] = (code >> 6 & 0x1F_u32) as u8 | TAG_TWO_B;
dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(2)
} else if code < MAX_THREE_B && dst.len() >= 3 {
dst[0] = (code >> 12u & 0x0F_u32) as u8 | TAG_THREE_B;
dst[1] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT;
dst[0] = (code >> 12 & 0x0F_u32) as u8 | TAG_THREE_B;
dst[1] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(3)
} else if dst.len() >= 4 {
dst[0] = (code >> 18u & 0x07_u32) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12u & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT;
dst[0] = (code >> 18 & 0x07_u32) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
dst[3] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(4)
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/libcoretest/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn any_referenced() {

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

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

#[test]
fn any_downcast_ref() {
let a = &5us as &Any;
let a = &5_usize as &Any;

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

#[test]
fn any_downcast_mut() {
let mut a = 5us;
let mut b = box 7us;
let mut a = 5_usize;
let mut b = box 7_usize;

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

#[test]
fn any_fixed_vec() {
let test = [0us; 8];
let test = [0_usize; 8];
let test = &test as &Any;
assert!(test.is::<[uint; 8]>());
assert!(!test.is::<[uint; 10]>());
Expand Down
26 changes: 13 additions & 13 deletions src/libcoretest/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,68 @@ fn test_format_int() {
// Formatting integers should select the right implementation based off
// the type of the argument. Also, hex/octal/binary should be defined
// for integers, but they shouldn't emit the negative sign.
assert!(format!("{}", 1is) == "1");
assert!(format!("{}", 1isize) == "1");
assert!(format!("{}", 1i8) == "1");
assert!(format!("{}", 1i16) == "1");
assert!(format!("{}", 1i32) == "1");
assert!(format!("{}", 1i64) == "1");
assert!(format!("{}", -1is) == "-1");
assert!(format!("{}", -1isize) == "-1");
assert!(format!("{}", -1i8) == "-1");
assert!(format!("{}", -1i16) == "-1");
assert!(format!("{}", -1i32) == "-1");
assert!(format!("{}", -1i64) == "-1");
assert!(format!("{:?}", 1is) == "1");
assert!(format!("{:?}", 1isize) == "1");
assert!(format!("{:?}", 1i8) == "1");
assert!(format!("{:?}", 1i16) == "1");
assert!(format!("{:?}", 1i32) == "1");
assert!(format!("{:?}", 1i64) == "1");
assert!(format!("{:b}", 1is) == "1");
assert!(format!("{:b}", 1isize) == "1");
assert!(format!("{:b}", 1i8) == "1");
assert!(format!("{:b}", 1i16) == "1");
assert!(format!("{:b}", 1i32) == "1");
assert!(format!("{:b}", 1i64) == "1");
assert!(format!("{:x}", 1is) == "1");
assert!(format!("{:x}", 1isize) == "1");
assert!(format!("{:x}", 1i8) == "1");
assert!(format!("{:x}", 1i16) == "1");
assert!(format!("{:x}", 1i32) == "1");
assert!(format!("{:x}", 1i64) == "1");
assert!(format!("{:X}", 1is) == "1");
assert!(format!("{:X}", 1isize) == "1");
assert!(format!("{:X}", 1i8) == "1");
assert!(format!("{:X}", 1i16) == "1");
assert!(format!("{:X}", 1i32) == "1");
assert!(format!("{:X}", 1i64) == "1");
assert!(format!("{:o}", 1is) == "1");
assert!(format!("{:o}", 1isize) == "1");
assert!(format!("{:o}", 1i8) == "1");
assert!(format!("{:o}", 1i16) == "1");
assert!(format!("{:o}", 1i32) == "1");
assert!(format!("{:o}", 1i64) == "1");

assert!(format!("{}", 1us) == "1");
assert!(format!("{}", 1usize) == "1");
assert!(format!("{}", 1u8) == "1");
assert!(format!("{}", 1u16) == "1");
assert!(format!("{}", 1u32) == "1");
assert!(format!("{}", 1u64) == "1");
assert!(format!("{:?}", 1us) == "1");
assert!(format!("{:?}", 1usize) == "1");
assert!(format!("{:?}", 1u8) == "1");
assert!(format!("{:?}", 1u16) == "1");
assert!(format!("{:?}", 1u32) == "1");
assert!(format!("{:?}", 1u64) == "1");
assert!(format!("{:b}", 1us) == "1");
assert!(format!("{:b}", 1usize) == "1");
assert!(format!("{:b}", 1u8) == "1");
assert!(format!("{:b}", 1u16) == "1");
assert!(format!("{:b}", 1u32) == "1");
assert!(format!("{:b}", 1u64) == "1");
assert!(format!("{:x}", 1us) == "1");
assert!(format!("{:x}", 1usize) == "1");
assert!(format!("{:x}", 1u8) == "1");
assert!(format!("{:x}", 1u16) == "1");
assert!(format!("{:x}", 1u32) == "1");
assert!(format!("{:x}", 1u64) == "1");
assert!(format!("{:X}", 1us) == "1");
assert!(format!("{:X}", 1usize) == "1");
assert!(format!("{:X}", 1u8) == "1");
assert!(format!("{:X}", 1u16) == "1");
assert!(format!("{:X}", 1u32) == "1");
assert!(format!("{:X}", 1u64) == "1");
assert!(format!("{:o}", 1us) == "1");
assert!(format!("{:o}", 1usize) == "1");
assert!(format!("{:o}", 1u8) == "1");
assert!(format!("{:o}", 1u16) == "1");
assert!(format!("{:o}", 1u32) == "1");
Expand Down
26 changes: 13 additions & 13 deletions src/libcoretest/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ fn test_writer_hasher() {

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

assert_eq!(hash(&5u8), 5);
assert_eq!(hash(&5u16), 5);
assert_eq!(hash(&5u32), 5);
assert_eq!(hash(&5u64), 5);
assert_eq!(hash(&5us), 5);

assert_eq!(hash(&5i8), 5);
assert_eq!(hash(&5i16), 5);
assert_eq!(hash(&5i32), 5);
assert_eq!(hash(&5i64), 5);
assert_eq!(hash(&5is), 5);
assert_eq!(hash(&5_u8), 5);
assert_eq!(hash(&5_u16), 5);
assert_eq!(hash(&5_u32), 5);
assert_eq!(hash(&5_u64), 5);
assert_eq!(hash(&5_usize), 5);

assert_eq!(hash(&5_i8), 5);
assert_eq!(hash(&5_i16), 5);
assert_eq!(hash(&5_i32), 5);
assert_eq!(hash(&5_i64), 5);
assert_eq!(hash(&5_isize), 5);

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

unsafe {
let ptr: *const i32 = mem::transmute(5us);
let ptr: *const i32 = mem::transmute(5_usize);
assert_eq!(hash(&ptr), 5);
}

unsafe {
let ptr: *mut i32 = mem::transmute(5us);
let ptr: *mut i32 = mem::transmute(5_usize);
assert_eq!(hash(&ptr), 5);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ pub mod types {
pub iSecurityScheme: c_int,
pub dwMessageSize: DWORD,
pub dwProviderReserved: DWORD,
pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1us],
pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1],
}

pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
Expand Down
8 changes: 4 additions & 4 deletions src/librbml/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,10 @@ pub mod writer {
match size {
1 => w.write_all(&[0x80u8 | (n as u8)]),
2 => w.write_all(&[0x40u8 | ((n >> 8) as u8), n as u8]),
3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8_u) as u8,
3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8) as u8,
n as u8]),
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16_u) as u8,
(n >> 8_u) as u8, n as u8]),
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16) as u8,
(n >> 8) as u8, n as u8]),
_ => Err(old_io::IoError {
kind: old_io::OtherIoError,
desc: "int too big",
Expand Down Expand Up @@ -863,7 +863,7 @@ pub mod writer {
impl<'a, W: Writer + Seek> Encoder<'a, W> {
// used internally to emit things like the vector length and so on
fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) -> EncodeResult {
assert!(v <= 0xFFFF_FFFF_u);
assert!(v <= 0xFFFF_FFFF);
self.wr_tagged_u32(t as uint, v as u32)
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,12 @@ pub struct BoxPointers;
impl BoxPointers {
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
span: Span, ty: Ty<'tcx>) {
let mut n_uniq = 0us;
let mut n_uniq: usize = 0;
ty::fold_ty(cx.tcx, ty, |t| {
match t.sty {
ty::ty_uniq(_) => {
n_uniq += 1;
}

_ => ()
};
t
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>,
pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
let mut s = typ.repr(cx).to_string();
if s.len() >= 32 {
s = (&s[0u..32]).to_string();
s = (&s[0..32]).to_string();
}
return s;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
let file = path.filename_str().unwrap();
let file = &file[3..file.len() - 5]; // chop off lib/.rlib
debug!("reading {}", file);
for i in iter::count(0us, 1) {
for i in iter::count(0, 1) {
let bc_encoded = time(sess.time_passes(),
&format!("check for {}.{}.bytecode.deflate", name, i),
(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {

pub fn env_arg_pos(&self) -> uint {
if self.caller_expects_out_pointer {
1u
1
} else {
0u
0
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
PointerCast(bcx, lval.val, type_of::type_of(bcx.ccx(), unsized_ty).ptr_to())
}
ty::UnsizeLength(..) => {
GEPi(bcx, lval.val, &[0u, 0u])
GEPi(bcx, lval.val, &[0, 0])
}
};

Expand Down
Loading

0 comments on commit 5250a82

Please sign in to comment.