Remove i, is, u, or us suffixes that are not necessary.

This commit is contained in:
Niko Matsakis 2015-02-17 09:47:49 -05:00
parent 700c518f2a
commit 2b5720a15f
54 changed files with 174 additions and 174 deletions

View file

@ -27,12 +27,12 @@
//! Some examples of the `format!` extension are: //! Some examples of the `format!` extension are:
//! //!
//! ``` //! ```
//! format!("Hello"); // => "Hello" //! format!("Hello"); // => "Hello"
//! format!("Hello, {}!", "world"); // => "Hello, world!" //! format!("Hello, {}!", "world"); // => "Hello, world!"
//! format!("The number is {}", 1); // => "The number is 1" //! 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!("{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 //! From these, you can see that the first argument is a format string. It is

View file

@ -441,18 +441,18 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
dst[0] = code as u8; dst[0] = code as u8;
Some(1) Some(1)
} else if code < MAX_TWO_B && dst.len() >= 2 { } 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; dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(2) Some(2)
} else if code < MAX_THREE_B && dst.len() >= 3 { } else if code < MAX_THREE_B && dst.len() >= 3 {
dst[0] = (code >> 12u & 0x0F_u32) as u8 | TAG_THREE_B; dst[0] = (code >> 12 & 0x0F_u32) as u8 | TAG_THREE_B;
dst[1] = (code >> 6u & 0x3F_u32) as u8 | TAG_CONT; dst[1] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT; dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(3) Some(3)
} else if dst.len() >= 4 { } else if dst.len() >= 4 {
dst[0] = (code >> 18u & 0x07_u32) as u8 | TAG_FOUR_B; dst[0] = (code >> 18 & 0x07_u32) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12u & 0x3F_u32) as u8 | TAG_CONT; dst[1] = (code >> 12 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code >> 6u & 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; dst[3] = (code & 0x3F_u32) as u8 | TAG_CONT;
Some(4) Some(4)
} else { } else {

View file

@ -1930,7 +1930,7 @@ pub mod types {
pub iSecurityScheme: c_int, pub iSecurityScheme: c_int,
pub dwMessageSize: DWORD, pub dwMessageSize: DWORD,
pub dwProviderReserved: 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; pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;

View file

@ -713,10 +713,10 @@ pub mod writer {
match size { match size {
1 => w.write_all(&[0x80u8 | (n as u8)]), 1 => w.write_all(&[0x80u8 | (n as u8)]),
2 => w.write_all(&[0x40u8 | ((n >> 8) as u8), 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]), n as u8]),
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16_u) as u8, 4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16) as u8,
(n >> 8_u) as u8, n as u8]), (n >> 8) as u8, n as u8]),
_ => Err(old_io::IoError { _ => Err(old_io::IoError {
kind: old_io::OtherIoError, kind: old_io::OtherIoError,
desc: "int too big", desc: "int too big",
@ -863,7 +863,7 @@ pub mod writer {
impl<'a, W: Writer + Seek> Encoder<'a, W> { impl<'a, W: Writer + Seek> Encoder<'a, W> {
// used internally to emit things like the vector length and so on // used internally to emit things like the vector length and so on
fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) -> EncodeResult { 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) self.wr_tagged_u32(t as uint, v as u32)
} }

View file

@ -560,7 +560,7 @@ pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>,
pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String { pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
let mut s = typ.repr(cx).to_string(); let mut s = typ.repr(cx).to_string();
if s.len() >= 32 { if s.len() >= 32 {
s = (&s[0u..32]).to_string(); s = (&s[0..32]).to_string();
} }
return s; return s;
} }

View file

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

View file

@ -443,9 +443,9 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
pub fn env_arg_pos(&self) -> uint { pub fn env_arg_pos(&self) -> uint {
if self.caller_expects_out_pointer { if self.caller_expects_out_pointer {
1u 1
} else { } else {
0u 0
} }
} }

View file

@ -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()) PointerCast(bcx, lval.val, type_of::type_of(bcx.ccx(), unsized_ty).ptr_to())
} }
ty::UnsizeLength(..) => { ty::UnsizeLength(..) => {
GEPi(bcx, lval.val, &[0u, 0u]) GEPi(bcx, lval.val, &[0, 0])
} }
}; };

View file

@ -76,7 +76,7 @@ pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let not_empty = ICmp(bcx, let not_empty = ICmp(bcx,
llvm::IntNE, llvm::IntNE,
len, len,
C_uint(ccx, 0us), C_uint(ccx, 0_u32),
DebugLoc::None); DebugLoc::None);
with_cond(bcx, not_empty, |bcx| { with_cond(bcx, not_empty, |bcx| {
let llalign = C_uint(ccx, machine::llalign_of_min(ccx, llty)); let llalign = C_uint(ccx, machine::llalign_of_min(ccx, llty));
@ -436,7 +436,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
let loop_counter = { let loop_counter = {
// i = 0 // i = 0
let i = alloca(loop_bcx, bcx.ccx().int_type(), "__i"); let i = alloca(loop_bcx, bcx.ccx().int_type(), "__i");
Store(loop_bcx, C_uint(bcx.ccx(), 0us), i); Store(loop_bcx, C_uint(bcx.ccx(), 0_u32), i);
Br(loop_bcx, cond_bcx.llbb, DebugLoc::None); Br(loop_bcx, cond_bcx.llbb, DebugLoc::None);
i i
@ -464,7 +464,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
{ // i += 1 { // i += 1
let i = Load(inc_bcx, loop_counter); let i = Load(inc_bcx, loop_counter);
let plusone = Add(inc_bcx, i, C_uint(bcx.ccx(), 1us), DebugLoc::None); let plusone = Add(inc_bcx, i, C_uint(bcx.ccx(), 1_u32), DebugLoc::None);
Store(inc_bcx, plusone, loop_counter); Store(inc_bcx, plusone, loop_counter);
Br(inc_bcx, cond_bcx.llbb, DebugLoc::None); Br(inc_bcx, cond_bcx.llbb, DebugLoc::None);

View file

@ -1149,7 +1149,7 @@ mod tests {
assert_eq!(_20, NumCast::from(20f32).unwrap()); assert_eq!(_20, NumCast::from(20f32).unwrap());
assert_eq!(_20, NumCast::from(20f64).unwrap()); assert_eq!(_20, NumCast::from(20f64).unwrap());
assert_eq!(_20, cast(20u).unwrap()); assert_eq!(_20, cast(20usize).unwrap());
assert_eq!(_20, cast(20u8).unwrap()); assert_eq!(_20, cast(20u8).unwrap());
assert_eq!(_20, cast(20u16).unwrap()); assert_eq!(_20, cast(20u16).unwrap());
assert_eq!(_20, cast(20u32).unwrap()); assert_eq!(_20, cast(20u32).unwrap());
@ -1763,7 +1763,7 @@ mod bench {
#[bench] #[bench]
fn bench_pow_function(b: &mut Bencher) { fn bench_pow_function(b: &mut Bencher) {
let v = (0..1024u).collect::<Vec<_>>(); let v = (0..1024).collect::<Vec<_>>();
b.iter(|| {v.iter().fold(0u, |old, new| old.pow(*new));}); b.iter(|| {v.iter().fold(0, |old, new| old.pow(*new));});
} }
} }

View file

@ -262,7 +262,7 @@ pub fn float_to_str_bytes_common<T: Float>(
// If limited digits, calculate one digit more for rounding. // If limited digits, calculate one digit more for rounding.
let (limit_digits, digit_count, exact) = match digits { let (limit_digits, digit_count, exact) = match digits {
DigAll => (false, 0u, false), DigAll => (false, 0, false),
DigMax(count) => (true, count+1, false), DigMax(count) => (true, count+1, false),
DigExact(count) => (true, count+1, true) DigExact(count) => (true, count+1, true)
}; };
@ -289,7 +289,7 @@ pub fn float_to_str_bytes_common<T: Float>(
deccum = num.fract(); deccum = num.fract();
if deccum != _0 || (limit_digits && exact && digit_count > 0) { if deccum != _0 || (limit_digits && exact && digit_count > 0) {
buf.push(b'.'); buf.push(b'.');
let mut dig = 0u; let mut dig = 0;
// calculate new digits while // calculate new digits while
// - there is no limit and there are digits left // - there is no limit and there are digits left
@ -314,7 +314,7 @@ pub fn float_to_str_bytes_common<T: Float>(
// Decrease the deccumulator one fractional digit at a time // Decrease the deccumulator one fractional digit at a time
deccum = deccum.fract(); deccum = deccum.fract();
dig += 1u; dig += 1;
} }
// If digits are limited, and that limit has been reached, // If digits are limited, and that limit has been reached,

View file

@ -25,11 +25,11 @@ mod tests {
#[test] #[test]
pub fn test_from_str() { pub fn test_from_str() {
assert_eq!(from_str::<$T>("0"), Some(0u as $T)); assert_eq!(from_str::<$T>("0"), Some(0 as $T));
assert_eq!(from_str::<$T>("3"), Some(3u as $T)); assert_eq!(from_str::<$T>("3"), Some(3 as $T));
assert_eq!(from_str::<$T>("10"), Some(10u as $T)); assert_eq!(from_str::<$T>("10"), Some(10 as $T));
assert_eq!(from_str::<u32>("123456789"), Some(123456789 as u32)); assert_eq!(from_str::<u32>("123456789"), Some(123456789 as u32));
assert_eq!(from_str::<$T>("00100"), Some(100u as $T)); assert_eq!(from_str::<$T>("00100"), Some(100 as $T));
assert_eq!(from_str::<$T>(""), None); assert_eq!(from_str::<$T>(""), None);
assert_eq!(from_str::<$T>(" "), None); assert_eq!(from_str::<$T>(" "), None);
@ -38,12 +38,12 @@ mod tests {
#[test] #[test]
pub fn test_parse_bytes() { pub fn test_parse_bytes() {
assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123u as $T)); assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123 as $T));
assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9u as $T)); assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9 as $T));
assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83u as $T)); assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83 as $T));
assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291u as u16)); assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291 as u16));
assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535u as u16)); assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535 as u16));
assert_eq!(FromStrRadix::from_str_radix("z", 36), Ok(35u as $T)); assert_eq!(FromStrRadix::from_str_radix("z", 36), Ok(35 as $T));
assert_eq!(FromStrRadix::from_str_radix("Z", 10).ok(), None::<$T>); assert_eq!(FromStrRadix::from_str_radix("Z", 10).ok(), None::<$T>);
assert_eq!(FromStrRadix::from_str_radix("_", 2).ok(), None::<$T>); assert_eq!(FromStrRadix::from_str_radix("_", 2).ok(), None::<$T>);

View file

@ -85,21 +85,21 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where
use mem::transmute; use mem::transmute;
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics // LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
assert!(size <= 8u); assert!(size <= 8);
match size { match size {
1u => f(&[n as u8]), 1 => f(&[n as u8]),
2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_le()) }), 2 => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_le()) }),
4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_le()) }), 4 => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_le()) }),
8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_le()) }), 8 => f(unsafe { & transmute::<_, [u8; 8]>(n.to_le()) }),
_ => { _ => {
let mut bytes = vec!(); let mut bytes = vec!();
let mut i = size; let mut i = size;
let mut n = n; let mut n = n;
while i > 0u { while i > 0 {
bytes.push((n & 255_u64) as u8); bytes.push((n & 255_u64) as u8);
n >>= 8; n >>= 8;
i -= 1u; i -= 1;
} }
f(&bytes) f(&bytes)
} }
@ -126,19 +126,19 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where
use mem::transmute; use mem::transmute;
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics // LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
assert!(size <= 8u); assert!(size <= 8);
match size { match size {
1u => f(&[n as u8]), 1 => f(&[n as u8]),
2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_be()) }), 2 => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_be()) }),
4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_be()) }), 4 => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_be()) }),
8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_be()) }), 8 => f(unsafe { & transmute::<_, [u8; 8]>(n.to_be()) }),
_ => { _ => {
let mut bytes = vec!(); let mut bytes = vec!();
let mut i = size; let mut i = size;
while i > 0u { while i > 0 {
let shift = (i - 1u) * 8u; let shift = (i - 1) * 8;
bytes.push((n >> shift) as u8); bytes.push((n >> shift) as u8);
i -= 1u; i -= 1;
} }
f(&bytes) f(&bytes)
} }
@ -160,7 +160,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
use ptr::{copy_nonoverlapping_memory}; use ptr::{copy_nonoverlapping_memory};
use slice::SliceExt; use slice::SliceExt;
assert!(size <= 8u); assert!(size <= 8);
if data.len() - start < size { if data.len() - start < size {
panic!("index out of bounds"); panic!("index out of bounds");

View file

@ -720,7 +720,7 @@ mod test {
let buf = [5 as u8; 100].to_vec(); let buf = [5 as u8; 100].to_vec();
{ {
let mut rdr = MemReader::new(buf); let mut rdr = MemReader::new(buf);
for _i in 0u..10 { for _i in 0..10 {
let mut buf = [0 as u8; 10]; let mut buf = [0 as u8; 10];
rdr.read(&mut buf).unwrap(); rdr.read(&mut buf).unwrap();
assert_eq!(buf, [5; 10]); assert_eq!(buf, [5; 10]);
@ -735,7 +735,7 @@ mod test {
let mut buf = [0 as u8; 100]; let mut buf = [0 as u8; 100];
{ {
let mut wr = BufWriter::new(&mut buf); let mut wr = BufWriter::new(&mut buf);
for _i in 0u..10 { for _i in 0..10 {
wr.write(&[5; 10]).unwrap(); wr.write(&[5; 10]).unwrap();
} }
} }
@ -749,7 +749,7 @@ mod test {
let buf = [5 as u8; 100]; let buf = [5 as u8; 100];
{ {
let mut rdr = BufReader::new(&buf); let mut rdr = BufReader::new(&buf);
for _i in 0u..10 { for _i in 0..10 {
let mut buf = [0 as u8; 10]; let mut buf = [0 as u8; 10];
rdr.read(&mut buf).unwrap(); rdr.read(&mut buf).unwrap();
assert_eq!(buf, [5; 10]); assert_eq!(buf, [5; 10]);

View file

@ -1120,37 +1120,37 @@ pub trait Writer {
/// Write a big-endian u64 (8 bytes). /// Write a big-endian u64 (8 bytes).
#[inline] #[inline]
fn write_be_u64(&mut self, n: u64) -> IoResult<()> { fn write_be_u64(&mut self, n: u64) -> IoResult<()> {
extensions::u64_to_be_bytes(n, 8u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n, 8, |v| self.write_all(v))
} }
/// Write a big-endian u32 (4 bytes). /// Write a big-endian u32 (4 bytes).
#[inline] #[inline]
fn write_be_u32(&mut self, n: u32) -> IoResult<()> { fn write_be_u32(&mut self, n: u32) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n as u64, 4, |v| self.write_all(v))
} }
/// Write a big-endian u16 (2 bytes). /// Write a big-endian u16 (2 bytes).
#[inline] #[inline]
fn write_be_u16(&mut self, n: u16) -> IoResult<()> { fn write_be_u16(&mut self, n: u16) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n as u64, 2, |v| self.write_all(v))
} }
/// Write a big-endian i64 (8 bytes). /// Write a big-endian i64 (8 bytes).
#[inline] #[inline]
fn write_be_i64(&mut self, n: i64) -> IoResult<()> { fn write_be_i64(&mut self, n: i64) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, 8u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n as u64, 8, |v| self.write_all(v))
} }
/// Write a big-endian i32 (4 bytes). /// Write a big-endian i32 (4 bytes).
#[inline] #[inline]
fn write_be_i32(&mut self, n: i32) -> IoResult<()> { fn write_be_i32(&mut self, n: i32) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n as u64, 4, |v| self.write_all(v))
} }
/// Write a big-endian i16 (2 bytes). /// Write a big-endian i16 (2 bytes).
#[inline] #[inline]
fn write_be_i16(&mut self, n: i16) -> IoResult<()> { fn write_be_i16(&mut self, n: i16) -> IoResult<()> {
extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write_all(v)) extensions::u64_to_be_bytes(n as u64, 2, |v| self.write_all(v))
} }
/// Write a big-endian IEEE754 double-precision floating-point (8 bytes). /// Write a big-endian IEEE754 double-precision floating-point (8 bytes).
@ -1172,37 +1172,37 @@ pub trait Writer {
/// Write a little-endian u64 (8 bytes). /// Write a little-endian u64 (8 bytes).
#[inline] #[inline]
fn write_le_u64(&mut self, n: u64) -> IoResult<()> { fn write_le_u64(&mut self, n: u64) -> IoResult<()> {
extensions::u64_to_le_bytes(n, 8u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n, 8, |v| self.write_all(v))
} }
/// Write a little-endian u32 (4 bytes). /// Write a little-endian u32 (4 bytes).
#[inline] #[inline]
fn write_le_u32(&mut self, n: u32) -> IoResult<()> { fn write_le_u32(&mut self, n: u32) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n as u64, 4, |v| self.write_all(v))
} }
/// Write a little-endian u16 (2 bytes). /// Write a little-endian u16 (2 bytes).
#[inline] #[inline]
fn write_le_u16(&mut self, n: u16) -> IoResult<()> { fn write_le_u16(&mut self, n: u16) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n as u64, 2, |v| self.write_all(v))
} }
/// Write a little-endian i64 (8 bytes). /// Write a little-endian i64 (8 bytes).
#[inline] #[inline]
fn write_le_i64(&mut self, n: i64) -> IoResult<()> { fn write_le_i64(&mut self, n: i64) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, 8u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n as u64, 8, |v| self.write_all(v))
} }
/// Write a little-endian i32 (4 bytes). /// Write a little-endian i32 (4 bytes).
#[inline] #[inline]
fn write_le_i32(&mut self, n: i32) -> IoResult<()> { fn write_le_i32(&mut self, n: i32) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n as u64, 4, |v| self.write_all(v))
} }
/// Write a little-endian i16 (2 bytes). /// Write a little-endian i16 (2 bytes).
#[inline] #[inline]
fn write_le_i16(&mut self, n: i16) -> IoResult<()> { fn write_le_i16(&mut self, n: i16) -> IoResult<()> {
extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write_all(v)) extensions::u64_to_le_bytes(n as u64, 2, |v| self.write_all(v))
} }
/// Write a little-endian IEEE754 double-precision floating-point /// Write a little-endian IEEE754 double-precision floating-point

View file

@ -390,7 +390,7 @@ mod tests {
}; };
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
for _ in 0u..times { for _ in 0..times {
let mut stream = UnixStream::connect(&path2); let mut stream = UnixStream::connect(&path2);
match stream.write(&[100]) { match stream.write(&[100]) {
Ok(..) => {} Ok(..) => {}
@ -555,7 +555,7 @@ mod tests {
tx.send(UnixStream::connect(&addr2).unwrap()).unwrap(); tx.send(UnixStream::connect(&addr2).unwrap()).unwrap();
}); });
let l = rx.recv().unwrap(); let l = rx.recv().unwrap();
for i in 0u..1001 { for i in 0..1001 {
match a.accept() { match a.accept() {
Ok(..) => break, Ok(..) => break,
Err(ref e) if e.kind == TimedOut => {} Err(ref e) if e.kind == TimedOut => {}
@ -683,7 +683,7 @@ mod tests {
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
s.set_timeout(Some(20)); s.set_timeout(Some(20));
for i in 0u..1001 { for i in 0..1001 {
match s.write(&[0; 128 * 1024]) { match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,
@ -727,7 +727,7 @@ mod tests {
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut); assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
tx.send(()).unwrap(); tx.send(()).unwrap();
for _ in 0u..100 { for _ in 0..100 {
assert!(s.write(&[0;128 * 1024]).is_ok()); assert!(s.write(&[0;128 * 1024]).is_ok());
} }
} }
@ -746,7 +746,7 @@ mod tests {
let mut s = a.accept().unwrap(); let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20)); s.set_write_timeout(Some(20));
for i in 0u..1001 { for i in 0..1001 {
match s.write(&[0; 128 * 1024]) { match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,

View file

@ -746,7 +746,7 @@ mod test {
#[test] #[test]
fn multiple_connect_serial_ip4() { fn multiple_connect_serial_ip4() {
let addr = next_test_ip4(); let addr = next_test_ip4();
let max = 10u; let max = 10;
let mut acceptor = TcpListener::bind(addr).listen(); let mut acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
@ -766,7 +766,7 @@ mod test {
#[test] #[test]
fn multiple_connect_serial_ip6() { fn multiple_connect_serial_ip6() {
let addr = next_test_ip6(); let addr = next_test_ip6();
let max = 10u; let max = 10;
let mut acceptor = TcpListener::bind(addr).listen(); let mut acceptor = TcpListener::bind(addr).listen();
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {

View file

@ -447,7 +447,7 @@ mod test {
let _b = UdpSocket::bind(addr2).unwrap(); let _b = UdpSocket::bind(addr2).unwrap();
a.set_write_timeout(Some(1000)); a.set_write_timeout(Some(1000));
for _ in 0u..100 { for _ in 0..100 {
match a.send_to(&[0;4*1024], addr2) { match a.send_to(&[0;4*1024], addr2) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break, Err(IoError { kind: TimedOut, .. }) => break,

View file

@ -121,7 +121,7 @@ impl Timer {
/// let mut timer = Timer::new().unwrap(); /// let mut timer = Timer::new().unwrap();
/// let ten_milliseconds = timer.oneshot(Duration::milliseconds(10)); /// let ten_milliseconds = timer.oneshot(Duration::milliseconds(10));
/// ///
/// for _ in 0u..100 { /* do work */ } /// for _ in 0..100 { /* do work */ }
/// ///
/// // blocks until 10 ms after the `oneshot` call /// // blocks until 10 ms after the `oneshot` call
/// ten_milliseconds.recv().unwrap(); /// ten_milliseconds.recv().unwrap();
@ -173,12 +173,12 @@ impl Timer {
/// let mut timer = Timer::new().unwrap(); /// let mut timer = Timer::new().unwrap();
/// let ten_milliseconds = timer.periodic(Duration::milliseconds(10)); /// let ten_milliseconds = timer.periodic(Duration::milliseconds(10));
/// ///
/// for _ in 0u..100 { /* do work */ } /// for _ in 0..100 { /* do work */ }
/// ///
/// // blocks until 10 ms after the `periodic` call /// // blocks until 10 ms after the `periodic` call
/// ten_milliseconds.recv().unwrap(); /// ten_milliseconds.recv().unwrap();
/// ///
/// for _ in 0u..100 { /* do work */ } /// for _ in 0..100 { /* do work */ }
/// ///
/// // blocks until 20 ms after the `periodic` call (*not* 10ms after the /// // blocks until 20 ms after the `periodic` call (*not* 10ms after the
/// // previous `recv`) /// // previous `recv`)

View file

@ -409,7 +409,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
return None; return None;
} }
let mut comps: Vec<&'a [u8]> = vec![]; let mut comps: Vec<&'a [u8]> = vec![];
let mut n_up = 0u; let mut n_up = 0;
let mut changed = false; let mut changed = false;
for comp in v.split(is_sep_byte) { for comp in v.split(is_sep_byte) {
if comp.is_empty() { changed = true } if comp.is_empty() { changed = true }

View file

@ -1063,7 +1063,7 @@ fn normalize_helper<'a>(s: &'a str, prefix: Option<PathPrefix>) -> (bool, Option
}); });
} }
let mut comps: Vec<&'a str> = vec![]; let mut comps: Vec<&'a str> = vec![];
let mut n_up = 0u; let mut n_up = 0;
let mut changed = false; let mut changed = false;
for comp in s_.split(f) { for comp in s_.split(f) {
if comp.is_empty() { changed = true } if comp.is_empty() { changed = true }

View file

@ -78,7 +78,7 @@ pub fn num_cpus() -> uint {
} }
} }
pub const TMPBUF_SZ : uint = 1000u; pub const TMPBUF_SZ : uint = 1000;
/// Returns the current working directory as a `Path`. /// Returns the current working directory as a `Path`.
/// ///
@ -1442,7 +1442,7 @@ mod tests {
fn make_rand_name() -> String { fn make_rand_name() -> String {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let n = format!("TEST{}", rng.gen_ascii_chars().take(10u) let n = format!("TEST{}", rng.gen_ascii_chars().take(10)
.collect::<String>()); .collect::<String>());
assert!(getenv(&n).is_none()); assert!(getenv(&n).is_none());
n n
@ -1522,7 +1522,7 @@ mod tests {
#[ignore] #[ignore]
fn test_env_getenv() { fn test_env_getenv() {
let e = env(); let e = env();
assert!(e.len() > 0u); assert!(e.len() > 0);
for p in &e { for p in &e {
let (n, v) = (*p).clone(); let (n, v) = (*p).clone();
debug!("{}", n); debug!("{}", n);

View file

@ -102,7 +102,7 @@
//! let total = 1_000_000; //! let total = 1_000_000;
//! let mut in_circle = 0; //! let mut in_circle = 0;
//! //!
//! for _ in 0u..total { //! for _ in 0..total {
//! let a = between.ind_sample(&mut rng); //! let a = between.ind_sample(&mut rng);
//! let b = between.ind_sample(&mut rng); //! let b = between.ind_sample(&mut rng);
//! if a*a + b*b <= 1. { //! if a*a + b*b <= 1. {
@ -176,7 +176,7 @@
//! } //! }
//! //!
//! fn free_doors(blocked: &[uint]) -> Vec<uint> { //! fn free_doors(blocked: &[uint]) -> Vec<uint> {
//! (0u..3).filter(|x| !blocked.contains(x)).collect() //! (0..3).filter(|x| !blocked.contains(x)).collect()
//! } //! }
//! //!
//! fn main() { //! fn main() {
@ -483,14 +483,14 @@ mod test {
#[test] #[test]
fn test_gen_range() { fn test_gen_range() {
let mut r = thread_rng(); let mut r = thread_rng();
for _ in 0u..1000 { for _ in 0..1000 {
let a = r.gen_range(-3, 42); let a = r.gen_range(-3, 42);
assert!(a >= -3 && a < 42); assert!(a >= -3 && a < 42);
assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(0, 1), 0);
assert_eq!(r.gen_range(-12, -11), -12); assert_eq!(r.gen_range(-12, -11), -12);
} }
for _ in 0u..1000 { for _ in 0..1000 {
let a = r.gen_range(10, 42); let a = r.gen_range(10, 42);
assert!(a >= 10 && a < 42); assert!(a >= 10 && a < 42);
assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(0, 1), 0);
@ -510,7 +510,7 @@ mod test {
#[should_fail] #[should_fail]
fn test_gen_range_panic_uint() { fn test_gen_range_panic_uint() {
let mut r = thread_rng(); let mut r = thread_rng();
r.gen_range(5us, 2us); r.gen_range(5, 2);
} }
#[test] #[test]

View file

@ -377,7 +377,7 @@ mod test {
fn test_os_rng_tasks() { fn test_os_rng_tasks() {
let mut txs = vec!(); let mut txs = vec!();
for _ in 0u..20 { for _ in 0..20 {
let (tx, rx) = channel(); let (tx, rx) = channel();
txs.push(tx); txs.push(tx);
@ -391,7 +391,7 @@ mod test {
thread::yield_now(); thread::yield_now();
let mut v = [0u8; 1000]; let mut v = [0u8; 1000];
for _ in 0u..100 { for _ in 0..100 {
r.next_u32(); r.next_u32();
thread::yield_now(); thread::yield_now();
r.next_u64(); r.next_u64();

View file

@ -18,7 +18,7 @@ use sync::{Mutex, Condvar};
/// use std::thread; /// use std::thread;
/// ///
/// let barrier = Arc::new(Barrier::new(10)); /// let barrier = Arc::new(Barrier::new(10));
/// for _ in 0u..10 { /// for _ in 0..10 {
/// let c = barrier.clone(); /// let c = barrier.clone();
/// // The same messages will be printed together. /// // The same messages will be printed together.
/// // You will NOT see any interleaving. /// // You will NOT see any interleaving.
@ -120,7 +120,7 @@ mod tests {
let barrier = Arc::new(Barrier::new(N)); let barrier = Arc::new(Barrier::new(N));
let (tx, rx) = channel(); let (tx, rx) = channel();
for _ in 0u..N - 1 { for _ in 0..N - 1 {
let c = barrier.clone(); let c = barrier.clone();
let tx = tx.clone(); let tx = tx.clone();
thread::spawn(move|| { thread::spawn(move|| {
@ -138,7 +138,7 @@ mod tests {
let mut leader_found = barrier.wait().is_leader(); let mut leader_found = barrier.wait().is_leader();
// Now, the barrier is cleared and we should get data. // Now, the barrier is cleared and we should get data.
for _ in 0u..N - 1 { for _ in 0..N - 1 {
if rx.recv().unwrap() { if rx.recv().unwrap() {
assert!(!leader_found); assert!(!leader_found);
leader_found = true; leader_found = true;

View file

@ -1147,9 +1147,9 @@ mod test {
fn stress() { fn stress() {
let (tx, rx) = channel::<int>(); let (tx, rx) = channel::<int>();
let t = thread::spawn(move|| { let t = thread::spawn(move|| {
for _ in 0u..10000 { tx.send(1).unwrap(); } for _ in 0..10000 { tx.send(1).unwrap(); }
}); });
for _ in 0u..10000 { for _ in 0..10000 {
assert_eq!(rx.recv().unwrap(), 1); assert_eq!(rx.recv().unwrap(), 1);
} }
t.join().ok().unwrap(); t.join().ok().unwrap();
@ -1209,7 +1209,7 @@ mod test {
assert_eq!(rx.recv().unwrap(), 1); assert_eq!(rx.recv().unwrap(), 1);
} }
}); });
for _ in 0u..40 { for _ in 0..40 {
tx.send(1).unwrap(); tx.send(1).unwrap();
} }
t.join().ok().unwrap(); t.join().ok().unwrap();
@ -1530,7 +1530,7 @@ mod test {
tx2.send(()).unwrap(); tx2.send(()).unwrap();
}); });
// make sure the other task has gone to sleep // make sure the other task has gone to sleep
for _ in 0u..5000 { thread::yield_now(); } for _ in 0..5000 { thread::yield_now(); }
// upgrade to a shared chan and send a message // upgrade to a shared chan and send a message
let t = tx.clone(); let t = tx.clone();
@ -1654,9 +1654,9 @@ mod sync_tests {
fn stress() { fn stress() {
let (tx, rx) = sync_channel::<int>(0); let (tx, rx) = sync_channel::<int>(0);
thread::spawn(move|| { thread::spawn(move|| {
for _ in 0u..10000 { tx.send(1).unwrap(); } for _ in 0..10000 { tx.send(1).unwrap(); }
}); });
for _ in 0u..10000 { for _ in 0..10000 {
assert_eq!(rx.recv().unwrap(), 1); assert_eq!(rx.recv().unwrap(), 1);
} }
} }
@ -1893,8 +1893,8 @@ mod sync_tests {
fn recv_a_lot() { fn recv_a_lot() {
// Regression test that we don't run out of stack in scheduler context // Regression test that we don't run out of stack in scheduler context
let (tx, rx) = sync_channel(10000); let (tx, rx) = sync_channel(10000);
for _ in 0u..10000 { tx.send(()).unwrap(); } for _ in 0..10000 { tx.send(()).unwrap(); }
for _ in 0u..10000 { rx.recv().unwrap(); } for _ in 0..10000 { rx.recv().unwrap(); }
} }
#[test] #[test]
@ -1994,7 +1994,7 @@ mod sync_tests {
tx2.send(()).unwrap(); tx2.send(()).unwrap();
}); });
// make sure the other task has gone to sleep // make sure the other task has gone to sleep
for _ in 0u..5000 { thread::yield_now(); } for _ in 0..5000 { thread::yield_now(); }
// upgrade to a shared chan and send a message // upgrade to a shared chan and send a message
let t = tx.clone(); let t = tx.clone();
@ -2082,7 +2082,7 @@ mod sync_tests {
rx2.recv().unwrap(); rx2.recv().unwrap();
} }
for _ in 0u..100 { for _ in 0..100 {
repro() repro()
} }
} }

View file

@ -171,8 +171,8 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
let nthreads = 8u; let nthreads = 8;
let nmsgs = 1000u; let nmsgs = 1000;
let q = Queue::new(); let q = Queue::new();
match q.pop() { match q.pop() {
Empty => {} Empty => {}
@ -192,7 +192,7 @@ mod tests {
}); });
} }
let mut i = 0u; let mut i = 0;
while i < nthreads * nmsgs { while i < nthreads * nmsgs {
match q.pop() { match q.pop() {
Empty | Inconsistent => {}, Empty | Inconsistent => {},

View file

@ -428,10 +428,10 @@ mod test {
let (tx3, rx3) = channel::<int>(); let (tx3, rx3) = channel::<int>();
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
for _ in 0u..20 { thread::yield_now(); } for _ in 0..20 { thread::yield_now(); }
tx1.send(1).unwrap(); tx1.send(1).unwrap();
rx3.recv().unwrap(); rx3.recv().unwrap();
for _ in 0u..20 { thread::yield_now(); } for _ in 0..20 { thread::yield_now(); }
}); });
select! { select! {
@ -452,7 +452,7 @@ mod test {
let (tx3, rx3) = channel::<()>(); let (tx3, rx3) = channel::<()>();
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
for _ in 0u..20 { thread::yield_now(); } for _ in 0..20 { thread::yield_now(); }
tx1.send(1).unwrap(); tx1.send(1).unwrap();
tx2.send(2).unwrap(); tx2.send(2).unwrap();
rx3.recv().unwrap(); rx3.recv().unwrap();
@ -557,7 +557,7 @@ mod test {
tx3.send(()).unwrap(); tx3.send(()).unwrap();
}); });
for _ in 0u..1000 { thread::yield_now(); } for _ in 0..1000 { thread::yield_now(); }
drop(tx1.clone()); drop(tx1.clone());
tx2.send(()).unwrap(); tx2.send(()).unwrap();
rx3.recv().unwrap(); rx3.recv().unwrap();
@ -670,7 +670,7 @@ mod test {
tx2.send(()).unwrap(); tx2.send(()).unwrap();
}); });
for _ in 0u..100 { thread::yield_now() } for _ in 0..100 { thread::yield_now() }
tx1.send(()).unwrap(); tx1.send(()).unwrap();
rx2.recv().unwrap(); rx2.recv().unwrap();
} }
@ -690,7 +690,7 @@ mod test {
tx2.send(()).unwrap(); tx2.send(()).unwrap();
}); });
for _ in 0u..100 { thread::yield_now() } for _ in 0..100 { thread::yield_now() }
tx1.send(()).unwrap(); tx1.send(()).unwrap();
rx2.recv().unwrap(); rx2.recv().unwrap();
} }
@ -709,7 +709,7 @@ mod test {
tx2.send(()).unwrap(); tx2.send(()).unwrap();
}); });
for _ in 0u..100 { thread::yield_now() } for _ in 0..100 { thread::yield_now() }
tx1.send(()).unwrap(); tx1.send(()).unwrap();
rx2.recv().unwrap(); rx2.recv().unwrap();
} }
@ -727,7 +727,7 @@ mod test {
fn sync2() { fn sync2() {
let (tx, rx) = sync_channel::<int>(0); let (tx, rx) = sync_channel::<int>(0);
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
for _ in 0u..100 { thread::yield_now() } for _ in 0..100 { thread::yield_now() }
tx.send(1).unwrap(); tx.send(1).unwrap();
}); });
select! { select! {

View file

@ -325,7 +325,7 @@ mod test {
let (tx, rx) = channel(); let (tx, rx) = channel();
let q2 = q.clone(); let q2 = q.clone();
let _t = thread::spawn(move|| { let _t = thread::spawn(move|| {
for _ in 0u..100000 { for _ in 0..100000 {
loop { loop {
match q2.pop() { match q2.pop() {
Some(1) => break, Some(1) => break,

View file

@ -60,7 +60,7 @@ use sys_common::mutex as sys;
/// let data = Arc::new(Mutex::new(0)); /// let data = Arc::new(Mutex::new(0));
/// ///
/// let (tx, rx) = channel(); /// let (tx, rx) = channel();
/// for _ in 0u..10 { /// for _ in 0..10 {
/// let (data, tx) = (data.clone(), tx.clone()); /// let (data, tx) = (data.clone(), tx.clone());
/// thread::spawn(move || { /// thread::spawn(move || {
/// // The shared static can only be accessed once the lock is held. /// // The shared static can only be accessed once the lock is held.
@ -87,7 +87,7 @@ use sys_common::mutex as sys;
/// use std::sync::{Arc, Mutex}; /// use std::sync::{Arc, Mutex};
/// use std::thread; /// use std::thread;
/// ///
/// let lock = Arc::new(Mutex::new(0u)); /// let lock = Arc::new(Mutex::new(0_u32));
/// let lock2 = lock.clone(); /// let lock2 = lock.clone();
/// ///
/// let _ = thread::spawn(move || -> () { /// let _ = thread::spawn(move || -> () {

View file

@ -147,10 +147,10 @@ mod test {
static mut run: bool = false; static mut run: bool = false;
let (tx, rx) = channel(); let (tx, rx) = channel();
for _ in 0u..10 { for _ in 0..10 {
let tx = tx.clone(); let tx = tx.clone();
thread::spawn(move|| { thread::spawn(move|| {
for _ in 0u..4 { thread::yield_now() } for _ in 0..4 { thread::yield_now() }
unsafe { unsafe {
O.call_once(|| { O.call_once(|| {
assert!(!run); assert!(!run);
@ -170,7 +170,7 @@ mod test {
assert!(run); assert!(run);
} }
for _ in 0u..10 { for _ in 0..10 {
rx.recv().unwrap(); rx.recv().unwrap();
} }
} }

View file

@ -503,7 +503,7 @@ mod tests {
thread::spawn(move|| { thread::spawn(move|| {
let mut lock = arc2.write().unwrap(); let mut lock = arc2.write().unwrap();
for _ in 0u..10 { for _ in 0..10 {
let tmp = *lock; let tmp = *lock;
*lock = -1; *lock = -1;
thread::yield_now(); thread::yield_now();
@ -514,7 +514,7 @@ mod tests {
// Readers try to catch the writer in the act // Readers try to catch the writer in the act
let mut children = Vec::new(); let mut children = Vec::new();
for _ in 0u..5 { for _ in 0..5 {
let arc3 = arc.clone(); let arc3 = arc.clone();
children.push(thread::spawn(move|| { children.push(thread::spawn(move|| {
let lock = arc3.read().unwrap(); let lock = arc3.read().unwrap();

View file

@ -63,17 +63,17 @@ impl<'a> Drop for Sentinel<'a> {
/// use std::iter::AdditiveIterator; /// use std::iter::AdditiveIterator;
/// use std::sync::mpsc::channel; /// use std::sync::mpsc::channel;
/// ///
/// let pool = TaskPool::new(4u); /// let pool = TaskPool::new(4);
/// ///
/// let (tx, rx) = channel(); /// let (tx, rx) = channel();
/// for _ in 0..8u { /// for _ in 0..8 {
/// let tx = tx.clone(); /// let tx = tx.clone();
/// pool.execute(move|| { /// pool.execute(move|| {
/// tx.send(1u).unwrap(); /// tx.send(1_u32).unwrap();
/// }); /// });
/// } /// }
/// ///
/// assert_eq!(rx.iter().take(8u).sum(), 8u); /// assert_eq!(rx.iter().take(8).sum(), 8);
/// ``` /// ```
pub struct TaskPool { pub struct TaskPool {
// How the threadpool communicates with subthreads. // How the threadpool communicates with subthreads.
@ -142,7 +142,7 @@ mod test {
use super::*; use super::*;
use sync::mpsc::channel; use sync::mpsc::channel;
const TEST_TASKS: uint = 4u; const TEST_TASKS: uint = 4;
#[test] #[test]
fn test_works() { fn test_works() {
@ -154,7 +154,7 @@ mod test {
for _ in 0..TEST_TASKS { for _ in 0..TEST_TASKS {
let tx = tx.clone(); let tx = tx.clone();
pool.execute(move|| { pool.execute(move|| {
tx.send(1u).unwrap(); tx.send(1).unwrap();
}); });
} }
@ -183,7 +183,7 @@ mod test {
for _ in 0..TEST_TASKS { for _ in 0..TEST_TASKS {
let tx = tx.clone(); let tx = tx.clone();
pool.execute(move|| { pool.execute(move|| {
tx.send(1u).unwrap(); tx.send(1).unwrap();
}); });
} }

View file

@ -175,13 +175,13 @@ pub fn current_exe() -> IoResult<Path> {
let mut sz: libc::size_t = 0; let mut sz: libc::size_t = 0;
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
ptr::null_mut(), &mut sz, ptr::null_mut(), ptr::null_mut(), &mut sz, ptr::null_mut(),
0u as libc::size_t); 0 as libc::size_t);
if err != 0 { return Err(IoError::last_error()); } if err != 0 { return Err(IoError::last_error()); }
if sz == 0 { return Err(IoError::last_error()); } if sz == 0 { return Err(IoError::last_error()); }
let mut v: Vec<u8> = Vec::with_capacity(sz as uint); let mut v: Vec<u8> = Vec::with_capacity(sz as uint);
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
v.as_mut_ptr() as *mut libc::c_void, &mut sz, v.as_mut_ptr() as *mut libc::c_void, &mut sz,
ptr::null_mut(), 0u as libc::size_t); ptr::null_mut(), 0 as libc::size_t);
if err != 0 { return Err(IoError::last_error()); } if err != 0 { return Err(IoError::last_error()); }
if sz == 0 { return Err(IoError::last_error()); } if sz == 0 { return Err(IoError::last_error()); }
v.set_len(sz as uint - 1); // chop off trailing NUL v.set_len(sz as uint - 1); // chop off trailing NUL

View file

@ -105,7 +105,7 @@ pub struct WSAPROTOCOL_INFO {
pub iSecurityScheme: libc::c_int, pub iSecurityScheme: libc::c_int,
pub dwMessageSize: libc::DWORD, pub dwMessageSize: libc::DWORD,
pub dwProviderReserved: libc::DWORD, pub dwProviderReserved: libc::DWORD,
pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1us], pub szProtocol: [u16; (WSAPROTOCOL_LEN as usize) + 1],
} }
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;

View file

@ -388,7 +388,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
cmd.push('"'); cmd.push('"');
} }
let argvec: Vec<char> = arg.chars().collect(); let argvec: Vec<char> = arg.chars().collect();
for i in 0u..argvec.len() { for i in 0..argvec.len() {
append_char_at(cmd, &argvec, i); append_char_at(cmd, &argvec, i);
} }
if quote { if quote {

View file

@ -488,7 +488,7 @@ pub fn parse(sess: &ParseSess,
let match_cur = ei.match_cur; let match_cur = ei.match_cur;
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal( (&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
parse_nt(&mut rust_parser, span, &name_string)))); parse_nt(&mut rust_parser, span, &name_string))));
ei.idx += 1us; ei.idx += 1;
ei.match_cur += 1; ei.match_cur += 1;
} }
_ => panic!() _ => panic!()

View file

@ -168,7 +168,7 @@ pub fn mk_printer(out: Box<old_io::Writer+'static>, linewidth: usize) -> Printer
debug!("mk_printer {}", linewidth); debug!("mk_printer {}", linewidth);
let token: Vec<Token> = repeat(Token::Eof).take(n).collect(); let token: Vec<Token> = repeat(Token::Eof).take(n).collect();
let size: Vec<isize> = repeat(0).take(n).collect(); let size: Vec<isize> = repeat(0).take(n).collect();
let scan_stack: Vec<usize> = repeat(0us).take(n).collect(); let scan_stack: Vec<usize> = repeat(0).take(n).collect();
Printer { Printer {
out: out, out: out,
buf_len: n, buf_len: n,

View file

@ -185,7 +185,7 @@ pub fn parse(file: &mut old_io::Reader, longnames: bool)
let magic = try!(file.read_le_u16()); let magic = try!(file.read_le_u16());
if magic != 0x011A { if magic != 0x011A {
return Err(format!("invalid magic number: expected {:x}, found {:x}", return Err(format!("invalid magic number: expected {:x}, found {:x}",
0x011Au, magic as uint)); 0x011A as usize, magic as usize));
} }
let names_bytes = try!(file.read_le_i16()) as int; let names_bytes = try!(file.read_le_i16()) as int;

View file

@ -939,7 +939,7 @@ mod bench {
#[bench] #[bench]
pub fn sum_many_f64(b: &mut Bencher) { pub fn sum_many_f64(b: &mut Bencher) {
let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60]; let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60];
let v = (0us..500).map(|i| nums[i%5]).collect::<Vec<_>>(); let v = (0..500).map(|i| nums[i%5]).collect::<Vec<_>>();
b.iter(|| { b.iter(|| {
v.sum(); v.sum();

View file

@ -143,9 +143,9 @@ pub fn parse_summary<R: Reader>(input: R, src: &Path) -> Result<Book, Vec<String
path_to_root: path_to_root, path_to_root: path_to_root,
children: vec!(), children: vec!(),
}; };
let level = indent.chars().map(|c| { let level = indent.chars().map(|c| -> usize {
match c { match c {
' ' => 1us, ' ' => 1,
'\t' => 4, '\t' => 4,
_ => unreachable!() _ => unreachable!()
} }

View file

@ -14,4 +14,4 @@ fn bad_bang(i: usize) -> ! {
return 7us; //~ ERROR `return` in a function declared as diverging [E0166] return 7us; //~ ERROR `return` in a function declared as diverging [E0166]
} }
fn main() { bad_bang(5us); } fn main() { bad_bang(5); }

View file

@ -14,4 +14,4 @@ fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function ma
if i < 0us { } else { panic!(); } if i < 0us { } else { panic!(); }
} }
fn main() { bad_bang(5us); } fn main() { bad_bang(5); }

View file

@ -11,11 +11,11 @@
use std::iter::repeat; use std::iter::repeat;
fn main() { fn main() {
let mut vector = vec![1us, 2]; let mut vector = vec![1, 2];
for &x in &vector { for &x in &vector {
let cap = vector.capacity(); let cap = vector.capacity();
vector.extend(repeat(0)); //~ ERROR cannot borrow vector.extend(repeat(0)); //~ ERROR cannot borrow
vector[1us] = 5us; //~ ERROR cannot borrow vector[1] = 5; //~ ERROR cannot borrow
} }
} }

View file

@ -14,4 +14,4 @@ fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function ma
println!("{}", 3); println!("{}", 3);
} }
fn main() { bad_bang(5us); } fn main() { bad_bang(5); }

View file

@ -15,21 +15,21 @@
//error-pattern: unreachable //error-pattern: unreachable
fn main() { fn main() {
match 5us { match 5 {
1us ... 10us => { } 1 ... 10 => { }
5us ... 6us => { } 5 ... 6 => { }
_ => {} _ => {}
}; };
match 5us { match 5 {
3us ... 6us => { } 3 ... 6 => { }
4us ... 6us => { } 4 ... 6 => { }
_ => {} _ => {}
}; };
match 5us { match 5 {
4us ... 6us => { } 4 ... 6 => { }
4us ... 6us => { } 4 ... 6 => { }
_ => {} _ => {}
}; };

View file

@ -13,8 +13,8 @@
//error-pattern: mismatched types //error-pattern: mismatched types
fn main() { fn main() {
match 5us { match 5 {
6us ... 1us => { } 6 ... 1 => { }
_ => { } _ => { }
}; };
@ -22,8 +22,8 @@ fn main() {
"bar" ... "foo" => { } "bar" ... "foo" => { }
}; };
match 5us { match 5 {
'c' ... 100us => { } 'c' ... 100 => { }
_ => { } _ => { }
}; };
} }

View file

@ -14,7 +14,7 @@
fn test() -> _ { 5 } fn test() -> _ { 5 }
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
fn test2() -> (_, _) { (5us, 5us) } fn test2() -> (_, _) { (5, 5) }
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
//~^^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
@ -67,7 +67,7 @@ pub fn main() {
fn fn_test() -> _ { 5 } fn fn_test() -> _ { 5 }
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
fn fn_test2() -> (_, _) { (5us, 5us) } fn fn_test2() -> (_, _) { (5, 5) }
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
//~^^ ERROR the type placeholder `_` is not allowed within types on item signatures //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures

View file

@ -16,6 +16,6 @@ struct Foo<'a, T:'a> {
} }
pub fn main() { pub fn main() {
let c: Foo<_, _> = Foo { r: &5us }; let c: Foo<_, _> = Foo { r: &5 };
//~^ ERROR wrong number of type arguments: expected 1, found 2 //~^ ERROR wrong number of type arguments: expected 1, found 2
} }

View file

@ -83,8 +83,8 @@ pub type Foo = [i32; (3us as usize)];
pub struct Bar { pub struct Bar {
pub x: [i32; (3us as usize)], pub x: [i32; (3us as usize)],
} }
pub struct TupleBar([i32; (4us as usize)]); pub struct TupleBar([i32; (4 as usize)]);
pub enum Baz { BazVariant([i32; (5us as usize)]), } pub enum Baz { BazVariant([i32; (5 as usize)]), }
pub fn id<T>(x: T) -> T { (x as T) } pub fn id<T>(x: T) -> T { (x as T) }
pub fn use_id() { pub fn use_id() {
let _ = let _ =

View file

@ -17,7 +17,7 @@
pub fn foo(_: [i32; 3]) {} pub fn foo(_: [i32; 3]) {}
pub fn bar() { pub fn bar() {
const FOO: usize = 5us - 4us; const FOO: usize = 5 - 4;
let _: [(); FOO] = [()]; let _: [(); FOO] = [()];
let _ : [(); 1us] = [()]; let _ : [(); 1us] = [()];
@ -27,22 +27,22 @@ pub fn bar() {
format!("test"); format!("test");
} }
pub type Foo = [i32; 3us]; pub type Foo = [i32; 3];
pub struct Bar { pub struct Bar {
pub x: [i32; 3us] pub x: [i32; 3]
} }
pub struct TupleBar([i32; 4us]); pub struct TupleBar([i32; 4]);
pub enum Baz { pub enum Baz {
BazVariant([i32; 5us]) BazVariant([i32; 5])
} }
pub fn id<T>(x: T) -> T { x } pub fn id<T>(x: T) -> T { x }
pub fn use_id() { pub fn use_id() {
let _ = id::<[i32; 3us]>([1,2,3]); let _ = id::<[i32; 3]>([1,2,3]);
} }

View file

@ -14,7 +14,7 @@ use sub::sub2 as msalias;
use sub::sub2; use sub::sub2;
use std::old_io::stdio::println; use std::old_io::stdio::println;
static yy: usize = 25us; static yy: usize = 25;
mod sub { mod sub {
pub mod sub2 { pub mod sub2 {

View file

@ -32,7 +32,7 @@ use std::num::{from_int,from_i8,from_i32};
use std::mem::size_of; use std::mem::size_of;
static uni: &'static str = "Les Miséééééééérables"; static uni: &'static str = "Les Miséééééééérables";
static yy: usize = 25us; static yy: usize = 25;
static bob: Option<std::vec::CowVec<'static, isize>> = None; static bob: Option<std::vec::CowVec<'static, isize>> = None;

View file

@ -11,7 +11,7 @@
use std::sync::Arc; use std::sync::Arc;
fn main() { fn main() {
let x = 5us; let x = 5;
let command = Arc::new(Box::new(|| { x*2 })); let command = Arc::new(Box::new(|| { x*2 }));
assert_eq!(command(), 10); assert_eq!(command(), 10);
} }