mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-24 22:44:26 +00:00
Auto merge of #22497 - nikomatsakis:suffixes, r=alexcrichton
The old suffixes now issue warnings unless a feature-gate is given. Fixes #22496. r? @alexcrichton
This commit is contained in:
commit
149f002437
@ -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();
|
||||
@ -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]);
|
||||
});
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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]);'
|
||||
@ -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");
|
||||
@ -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);
|
||||
}
|
||||
```
|
||||
|
@ -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();
|
||||
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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>());
|
||||
@ -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) => {}
|
||||
@ -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;
|
||||
@ -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]>());
|
||||
|
@ -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");
|
||||
|
@ -46,17 +46,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(&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(&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_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);
|
||||
@ -76,12 +76,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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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",
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
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;
|
||||
}
|
||||
|
@ -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),
|
||||
(),
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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])
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ pub fn make_drop_glue_unboxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let not_empty = ICmp(bcx,
|
||||
llvm::IntNE,
|
||||
len,
|
||||
C_uint(ccx, 0us),
|
||||
C_uint(ccx, 0_u32),
|
||||
DebugLoc::None);
|
||||
with_cond(bcx, not_empty, |bcx| {
|
||||
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 = {
|
||||
// i = 0
|
||||
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);
|
||||
i
|
||||
@ -464,7 +464,7 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
{ // i += 1
|
||||
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);
|
||||
|
||||
Br(inc_bcx, cond_bcx.llbb, DebugLoc::None);
|
||||
|
@ -3905,12 +3905,12 @@ mod tests {
|
||||
|
||||
assert_eq!(array2.to_json(), array2);
|
||||
assert_eq!(object.to_json(), object);
|
||||
assert_eq!(3_i.to_json(), I64(3));
|
||||
assert_eq!(3_isize.to_json(), I64(3));
|
||||
assert_eq!(4_i8.to_json(), I64(4));
|
||||
assert_eq!(5_i16.to_json(), I64(5));
|
||||
assert_eq!(6_i32.to_json(), I64(6));
|
||||
assert_eq!(7_i64.to_json(), I64(7));
|
||||
assert_eq!(8_u.to_json(), U64(8));
|
||||
assert_eq!(8_usize.to_json(), U64(8));
|
||||
assert_eq!(9_u8.to_json(), U64(9));
|
||||
assert_eq!(10_u16.to_json(), U64(10));
|
||||
assert_eq!(11_u32.to_json(), U64(11));
|
||||
@ -3924,22 +3924,22 @@ mod tests {
|
||||
assert_eq!(false.to_json(), Boolean(false));
|
||||
assert_eq!("abc".to_json(), String("abc".to_string()));
|
||||
assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
|
||||
assert_eq!((1us, 2us).to_json(), array2);
|
||||
assert_eq!((1us, 2us, 3us).to_json(), array3);
|
||||
assert_eq!([1us, 2us].to_json(), array2);
|
||||
assert_eq!((&[1us, 2us, 3us]).to_json(), array3);
|
||||
assert_eq!((vec![1us, 2us]).to_json(), array2);
|
||||
assert_eq!(vec!(1us, 2us, 3us).to_json(), array3);
|
||||
assert_eq!((1_usize, 2_usize).to_json(), array2);
|
||||
assert_eq!((1_usize, 2_usize, 3_usize).to_json(), array3);
|
||||
assert_eq!([1_usize, 2_usize].to_json(), array2);
|
||||
assert_eq!((&[1_usize, 2_usize, 3_usize]).to_json(), array3);
|
||||
assert_eq!((vec![1_usize, 2_usize]).to_json(), array2);
|
||||
assert_eq!(vec!(1_usize, 2_usize, 3_usize).to_json(), array3);
|
||||
let mut tree_map = BTreeMap::new();
|
||||
tree_map.insert("a".to_string(), 1us);
|
||||
tree_map.insert("a".to_string(), 1 as usize);
|
||||
tree_map.insert("b".to_string(), 2);
|
||||
assert_eq!(tree_map.to_json(), object);
|
||||
let mut hash_map = HashMap::new();
|
||||
hash_map.insert("a".to_string(), 1us);
|
||||
hash_map.insert("a".to_string(), 1 as usize);
|
||||
hash_map.insert("b".to_string(), 2);
|
||||
assert_eq!(hash_map.to_json(), object);
|
||||
assert_eq!(Some(15).to_json(), I64(15));
|
||||
assert_eq!(Some(15us).to_json(), U64(15));
|
||||
assert_eq!(Some(15 as usize).to_json(), U64(15));
|
||||
assert_eq!(None::<int>.to_json(), Null);
|
||||
}
|
||||
|
||||
|
@ -1123,20 +1123,20 @@ mod tests {
|
||||
($_20:expr) => ({
|
||||
let _20 = $_20;
|
||||
|
||||
assert_eq!(20u, _20.to_uint().unwrap());
|
||||
assert_eq!(20u8, _20.to_u8().unwrap());
|
||||
assert_eq!(20u16, _20.to_u16().unwrap());
|
||||
assert_eq!(20u32, _20.to_u32().unwrap());
|
||||
assert_eq!(20u64, _20.to_u64().unwrap());
|
||||
assert_eq!(20, _20.to_int().unwrap());
|
||||
assert_eq!(20i8, _20.to_i8().unwrap());
|
||||
assert_eq!(20i16, _20.to_i16().unwrap());
|
||||
assert_eq!(20i32, _20.to_i32().unwrap());
|
||||
assert_eq!(20i64, _20.to_i64().unwrap());
|
||||
assert_eq!(20f32, _20.to_f32().unwrap());
|
||||
assert_eq!(20f64, _20.to_f64().unwrap());
|
||||
assert_eq!(20usize, _20.to_uint().unwrap());
|
||||
assert_eq!(20u8, _20.to_u8().unwrap());
|
||||
assert_eq!(20u16, _20.to_u16().unwrap());
|
||||
assert_eq!(20u32, _20.to_u32().unwrap());
|
||||
assert_eq!(20u64, _20.to_u64().unwrap());
|
||||
assert_eq!(20, _20.to_int().unwrap());
|
||||
assert_eq!(20i8, _20.to_i8().unwrap());
|
||||
assert_eq!(20i16, _20.to_i16().unwrap());
|
||||
assert_eq!(20i32, _20.to_i32().unwrap());
|
||||
assert_eq!(20i64, _20.to_i64().unwrap());
|
||||
assert_eq!(20f32, _20.to_f32().unwrap());
|
||||
assert_eq!(20f64, _20.to_f64().unwrap());
|
||||
|
||||
assert_eq!(_20, NumCast::from(20u).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20usize).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20u8).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20u16).unwrap());
|
||||
assert_eq!(_20, NumCast::from(20u32).unwrap());
|
||||
@ -1149,7 +1149,7 @@ mod tests {
|
||||
assert_eq!(_20, NumCast::from(20f32).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(20u16).unwrap());
|
||||
assert_eq!(_20, cast(20u32).unwrap());
|
||||
@ -1164,18 +1164,18 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[test] fn test_u8_cast() { test_cast_20!(20u8) }
|
||||
#[test] fn test_u16_cast() { test_cast_20!(20u16) }
|
||||
#[test] fn test_u32_cast() { test_cast_20!(20u32) }
|
||||
#[test] fn test_u64_cast() { test_cast_20!(20u64) }
|
||||
#[test] fn test_uint_cast() { test_cast_20!(20u) }
|
||||
#[test] fn test_i8_cast() { test_cast_20!(20i8) }
|
||||
#[test] fn test_i16_cast() { test_cast_20!(20i16) }
|
||||
#[test] fn test_i32_cast() { test_cast_20!(20i32) }
|
||||
#[test] fn test_i64_cast() { test_cast_20!(20i64) }
|
||||
#[test] fn test_int_cast() { test_cast_20!(20) }
|
||||
#[test] fn test_f32_cast() { test_cast_20!(20f32) }
|
||||
#[test] fn test_f64_cast() { test_cast_20!(20f64) }
|
||||
#[test] fn test_u8_cast() { test_cast_20!(20u8) }
|
||||
#[test] fn test_u16_cast() { test_cast_20!(20u16) }
|
||||
#[test] fn test_u32_cast() { test_cast_20!(20u32) }
|
||||
#[test] fn test_u64_cast() { test_cast_20!(20u64) }
|
||||
#[test] fn test_uint_cast() { test_cast_20!(20usize) }
|
||||
#[test] fn test_i8_cast() { test_cast_20!(20i8) }
|
||||
#[test] fn test_i16_cast() { test_cast_20!(20i16) }
|
||||
#[test] fn test_i32_cast() { test_cast_20!(20i32) }
|
||||
#[test] fn test_i64_cast() { test_cast_20!(20i64) }
|
||||
#[test] fn test_int_cast() { test_cast_20!(20) }
|
||||
#[test] fn test_f32_cast() { test_cast_20!(20f32) }
|
||||
#[test] fn test_f64_cast() { test_cast_20!(20f64) }
|
||||
|
||||
#[test]
|
||||
fn test_cast_range_int_min() {
|
||||
@ -1548,8 +1548,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_saturating_add_uint() {
|
||||
use uint::MAX;
|
||||
assert_eq!(3u.saturating_add(5u), 8u);
|
||||
assert_eq!(3u.saturating_add(MAX-1), MAX);
|
||||
assert_eq!(3_usize.saturating_add(5_usize), 8_usize);
|
||||
assert_eq!(3_usize.saturating_add(MAX-1), MAX);
|
||||
assert_eq!(MAX.saturating_add(MAX), MAX);
|
||||
assert_eq!((MAX-2).saturating_add(1), MAX-1);
|
||||
}
|
||||
@ -1557,9 +1557,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_saturating_sub_uint() {
|
||||
use uint::MAX;
|
||||
assert_eq!(5u.saturating_sub(3u), 2u);
|
||||
assert_eq!(3u.saturating_sub(5u), 0u);
|
||||
assert_eq!(0u.saturating_sub(1u), 0u);
|
||||
assert_eq!(5_usize.saturating_sub(3_usize), 2_usize);
|
||||
assert_eq!(3_usize.saturating_sub(5_usize), 0_usize);
|
||||
assert_eq!(0_usize.saturating_sub(1_usize), 0_usize);
|
||||
assert_eq!((MAX-1).saturating_sub(MAX), 0);
|
||||
}
|
||||
|
||||
@ -1602,14 +1602,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_checked_sub() {
|
||||
assert_eq!(5u.checked_sub(0), Some(5));
|
||||
assert_eq!(5u.checked_sub(1), Some(4));
|
||||
assert_eq!(5u.checked_sub(2), Some(3));
|
||||
assert_eq!(5u.checked_sub(3), Some(2));
|
||||
assert_eq!(5u.checked_sub(4), Some(1));
|
||||
assert_eq!(5u.checked_sub(5), Some(0));
|
||||
assert_eq!(5u.checked_sub(6), None);
|
||||
assert_eq!(5u.checked_sub(7), None);
|
||||
assert_eq!(5_usize.checked_sub(0), Some(5));
|
||||
assert_eq!(5_usize.checked_sub(1), Some(4));
|
||||
assert_eq!(5_usize.checked_sub(2), Some(3));
|
||||
assert_eq!(5_usize.checked_sub(3), Some(2));
|
||||
assert_eq!(5_usize.checked_sub(4), Some(1));
|
||||
assert_eq!(5_usize.checked_sub(5), Some(0));
|
||||
assert_eq!(5_usize.checked_sub(6), None);
|
||||
assert_eq!(5_usize.checked_sub(7), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1763,7 +1763,7 @@ mod bench {
|
||||
|
||||
#[bench]
|
||||
fn bench_pow_function(b: &mut Bencher) {
|
||||
let v = (0..1024u).collect::<Vec<_>>();
|
||||
b.iter(|| {v.iter().fold(0u, |old, new| old.pow(*new));});
|
||||
let v = (0..1024).collect::<Vec<_>>();
|
||||
b.iter(|| {v.iter().fold(0, |old, new| old.pow(*new));});
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ pub fn float_to_str_bytes_common<T: Float>(
|
||||
|
||||
// If limited digits, calculate one digit more for rounding.
|
||||
let (limit_digits, digit_count, exact) = match digits {
|
||||
DigAll => (false, 0u, false),
|
||||
DigAll => (false, 0, false),
|
||||
DigMax(count) => (true, count+1, false),
|
||||
DigExact(count) => (true, count+1, true)
|
||||
};
|
||||
@ -289,7 +289,7 @@ pub fn float_to_str_bytes_common<T: Float>(
|
||||
deccum = num.fract();
|
||||
if deccum != _0 || (limit_digits && exact && digit_count > 0) {
|
||||
buf.push(b'.');
|
||||
let mut dig = 0u;
|
||||
let mut dig = 0;
|
||||
|
||||
// calculate new digits while
|
||||
// - 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
|
||||
deccum = deccum.fract();
|
||||
dig += 1u;
|
||||
dig += 1;
|
||||
}
|
||||
|
||||
// If digits are limited, and that limit has been reached,
|
||||
|
@ -25,11 +25,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_from_str() {
|
||||
assert_eq!(from_str::<$T>("0"), Some(0u as $T));
|
||||
assert_eq!(from_str::<$T>("3"), Some(3u as $T));
|
||||
assert_eq!(from_str::<$T>("10"), Some(10u as $T));
|
||||
assert_eq!(from_str::<$T>("0"), Some(0 as $T));
|
||||
assert_eq!(from_str::<$T>("3"), Some(3 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::<$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);
|
||||
@ -38,12 +38,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
pub fn test_parse_bytes() {
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123u as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9u as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83u as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291u as u16));
|
||||
assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535u as u16));
|
||||
assert_eq!(FromStrRadix::from_str_radix("z", 36), Ok(35u as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123 as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9 as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83 as $T));
|
||||
assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291 as u16));
|
||||
assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535 as u16));
|
||||
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("_", 2).ok(), None::<$T>);
|
||||
|
@ -85,21 +85,21 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where
|
||||
use mem::transmute;
|
||||
|
||||
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
|
||||
assert!(size <= 8u);
|
||||
assert!(size <= 8);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_le()) }),
|
||||
4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_le()) }),
|
||||
8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_le()) }),
|
||||
1 => f(&[n as u8]),
|
||||
2 => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_le()) }),
|
||||
4 => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_le()) }),
|
||||
8 => f(unsafe { & transmute::<_, [u8; 8]>(n.to_le()) }),
|
||||
_ => {
|
||||
|
||||
let mut bytes = vec!();
|
||||
let mut i = size;
|
||||
let mut n = n;
|
||||
while i > 0u {
|
||||
while i > 0 {
|
||||
bytes.push((n & 255_u64) as u8);
|
||||
n >>= 8;
|
||||
i -= 1u;
|
||||
i -= 1;
|
||||
}
|
||||
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;
|
||||
|
||||
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
|
||||
assert!(size <= 8u);
|
||||
assert!(size <= 8);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_be()) }),
|
||||
4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_be()) }),
|
||||
8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_be()) }),
|
||||
1 => f(&[n as u8]),
|
||||
2 => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_be()) }),
|
||||
4 => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_be()) }),
|
||||
8 => f(unsafe { & transmute::<_, [u8; 8]>(n.to_be()) }),
|
||||
_ => {
|
||||
let mut bytes = vec!();
|
||||
let mut i = size;
|
||||
while i > 0u {
|
||||
let shift = (i - 1u) * 8u;
|
||||
while i > 0 {
|
||||
let shift = (i - 1) * 8;
|
||||
bytes.push((n >> shift) as u8);
|
||||
i -= 1u;
|
||||
i -= 1;
|
||||
}
|
||||
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 slice::SliceExt;
|
||||
|
||||
assert!(size <= 8u);
|
||||
assert!(size <= 8);
|
||||
|
||||
if data.len() - start < size {
|
||||
panic!("index out of bounds");
|
||||
|
@ -720,7 +720,7 @@ mod test {
|
||||
let buf = [5 as u8; 100].to_vec();
|
||||
{
|
||||
let mut rdr = MemReader::new(buf);
|
||||
for _i in 0u..10 {
|
||||
for _i in 0..10 {
|
||||
let mut buf = [0 as u8; 10];
|
||||
rdr.read(&mut buf).unwrap();
|
||||
assert_eq!(buf, [5; 10]);
|
||||
@ -735,7 +735,7 @@ mod test {
|
||||
let mut buf = [0 as u8; 100];
|
||||
{
|
||||
let mut wr = BufWriter::new(&mut buf);
|
||||
for _i in 0u..10 {
|
||||
for _i in 0..10 {
|
||||
wr.write(&[5; 10]).unwrap();
|
||||
}
|
||||
}
|
||||
@ -749,7 +749,7 @@ mod test {
|
||||
let buf = [5 as u8; 100];
|
||||
{
|
||||
let mut rdr = BufReader::new(&buf);
|
||||
for _i in 0u..10 {
|
||||
for _i in 0..10 {
|
||||
let mut buf = [0 as u8; 10];
|
||||
rdr.read(&mut buf).unwrap();
|
||||
assert_eq!(buf, [5; 10]);
|
||||
|
@ -1120,37 +1120,37 @@ pub trait Writer {
|
||||
/// Write a big-endian u64 (8 bytes).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
@ -1172,37 +1172,37 @@ pub trait Writer {
|
||||
/// Write a little-endian u64 (8 bytes).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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).
|
||||
#[inline]
|
||||
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
|
||||
|
@ -390,7 +390,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let _t = thread::spawn(move|| {
|
||||
for _ in 0u..times {
|
||||
for _ in 0..times {
|
||||
let mut stream = UnixStream::connect(&path2);
|
||||
match stream.write(&[100]) {
|
||||
Ok(..) => {}
|
||||
@ -555,7 +555,7 @@ mod tests {
|
||||
tx.send(UnixStream::connect(&addr2).unwrap()).unwrap();
|
||||
});
|
||||
let l = rx.recv().unwrap();
|
||||
for i in 0u..1001 {
|
||||
for i in 0..1001 {
|
||||
match a.accept() {
|
||||
Ok(..) => break,
|
||||
Err(ref e) if e.kind == TimedOut => {}
|
||||
@ -683,7 +683,7 @@ mod tests {
|
||||
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
|
||||
|
||||
s.set_timeout(Some(20));
|
||||
for i in 0u..1001 {
|
||||
for i in 0..1001 {
|
||||
match s.write(&[0; 128 * 1024]) {
|
||||
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
|
||||
Err(IoError { kind: TimedOut, .. }) => break,
|
||||
@ -727,7 +727,7 @@ mod tests {
|
||||
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
|
||||
|
||||
tx.send(()).unwrap();
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
assert!(s.write(&[0;128 * 1024]).is_ok());
|
||||
}
|
||||
}
|
||||
@ -746,7 +746,7 @@ mod tests {
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_write_timeout(Some(20));
|
||||
for i in 0u..1001 {
|
||||
for i in 0..1001 {
|
||||
match s.write(&[0; 128 * 1024]) {
|
||||
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
|
||||
Err(IoError { kind: TimedOut, .. }) => break,
|
||||
|
@ -746,7 +746,7 @@ mod test {
|
||||
#[test]
|
||||
fn multiple_connect_serial_ip4() {
|
||||
let addr = next_test_ip4();
|
||||
let max = 10u;
|
||||
let max = 10;
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
let _t = thread::spawn(move|| {
|
||||
@ -766,7 +766,7 @@ mod test {
|
||||
#[test]
|
||||
fn multiple_connect_serial_ip6() {
|
||||
let addr = next_test_ip6();
|
||||
let max = 10u;
|
||||
let max = 10;
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
let _t = thread::spawn(move|| {
|
||||
|
@ -447,7 +447,7 @@ mod test {
|
||||
let _b = UdpSocket::bind(addr2).unwrap();
|
||||
|
||||
a.set_write_timeout(Some(1000));
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
match a.send_to(&[0;4*1024], addr2) {
|
||||
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
|
||||
Err(IoError { kind: TimedOut, .. }) => break,
|
||||
|
@ -121,7 +121,7 @@ impl Timer {
|
||||
/// let mut timer = Timer::new().unwrap();
|
||||
/// 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
|
||||
/// ten_milliseconds.recv().unwrap();
|
||||
@ -173,12 +173,12 @@ impl Timer {
|
||||
/// let mut timer = Timer::new().unwrap();
|
||||
/// 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
|
||||
/// 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
|
||||
/// // previous `recv`)
|
||||
|
@ -409,7 +409,7 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
|
||||
return None;
|
||||
}
|
||||
let mut comps: Vec<&'a [u8]> = vec![];
|
||||
let mut n_up = 0u;
|
||||
let mut n_up = 0;
|
||||
let mut changed = false;
|
||||
for comp in v.split(is_sep_byte) {
|
||||
if comp.is_empty() { changed = true }
|
||||
|
@ -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 n_up = 0u;
|
||||
let mut n_up = 0;
|
||||
let mut changed = false;
|
||||
for comp in s_.split(f) {
|
||||
if comp.is_empty() { changed = true }
|
||||
|
@ -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`.
|
||||
///
|
||||
@ -1442,7 +1442,7 @@ mod tests {
|
||||
|
||||
fn make_rand_name() -> String {
|
||||
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>());
|
||||
assert!(getenv(&n).is_none());
|
||||
n
|
||||
@ -1522,7 +1522,7 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_env_getenv() {
|
||||
let e = env();
|
||||
assert!(e.len() > 0u);
|
||||
assert!(e.len() > 0);
|
||||
for p in &e {
|
||||
let (n, v) = (*p).clone();
|
||||
debug!("{}", n);
|
||||
|
@ -102,7 +102,7 @@
|
||||
//! let total = 1_000_000;
|
||||
//! let mut in_circle = 0;
|
||||
//!
|
||||
//! for _ in 0u..total {
|
||||
//! for _ in 0..total {
|
||||
//! let a = between.ind_sample(&mut rng);
|
||||
//! let b = between.ind_sample(&mut rng);
|
||||
//! if a*a + b*b <= 1. {
|
||||
@ -176,7 +176,7 @@
|
||||
//! }
|
||||
//!
|
||||
//! 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() {
|
||||
@ -483,14 +483,14 @@ mod test {
|
||||
#[test]
|
||||
fn test_gen_range() {
|
||||
let mut r = thread_rng();
|
||||
for _ in 0u..1000 {
|
||||
for _ in 0..1000 {
|
||||
let a = r.gen_range(-3, 42);
|
||||
assert!(a >= -3 && a < 42);
|
||||
assert_eq!(r.gen_range(0, 1), 0);
|
||||
assert_eq!(r.gen_range(-12, -11), -12);
|
||||
}
|
||||
|
||||
for _ in 0u..1000 {
|
||||
for _ in 0..1000 {
|
||||
let a = r.gen_range(10, 42);
|
||||
assert!(a >= 10 && a < 42);
|
||||
assert_eq!(r.gen_range(0, 1), 0);
|
||||
@ -510,7 +510,7 @@ mod test {
|
||||
#[should_fail]
|
||||
fn test_gen_range_panic_uint() {
|
||||
let mut r = thread_rng();
|
||||
r.gen_range(5us, 2us);
|
||||
r.gen_range(5, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -377,7 +377,7 @@ mod test {
|
||||
fn test_os_rng_tasks() {
|
||||
|
||||
let mut txs = vec!();
|
||||
for _ in 0u..20 {
|
||||
for _ in 0..20 {
|
||||
let (tx, rx) = channel();
|
||||
txs.push(tx);
|
||||
|
||||
@ -391,7 +391,7 @@ mod test {
|
||||
thread::yield_now();
|
||||
let mut v = [0u8; 1000];
|
||||
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
r.next_u32();
|
||||
thread::yield_now();
|
||||
r.next_u64();
|
||||
|
@ -18,7 +18,7 @@ use sync::{Mutex, Condvar};
|
||||
/// use std::thread;
|
||||
///
|
||||
/// let barrier = Arc::new(Barrier::new(10));
|
||||
/// for _ in 0u..10 {
|
||||
/// for _ in 0..10 {
|
||||
/// let c = barrier.clone();
|
||||
/// // The same messages will be printed together.
|
||||
/// // You will NOT see any interleaving.
|
||||
@ -120,7 +120,7 @@ mod tests {
|
||||
let barrier = Arc::new(Barrier::new(N));
|
||||
let (tx, rx) = channel();
|
||||
|
||||
for _ in 0u..N - 1 {
|
||||
for _ in 0..N - 1 {
|
||||
let c = barrier.clone();
|
||||
let tx = tx.clone();
|
||||
thread::spawn(move|| {
|
||||
@ -138,7 +138,7 @@ mod tests {
|
||||
let mut leader_found = barrier.wait().is_leader();
|
||||
|
||||
// Now, the barrier is cleared and we should get data.
|
||||
for _ in 0u..N - 1 {
|
||||
for _ in 0..N - 1 {
|
||||
if rx.recv().unwrap() {
|
||||
assert!(!leader_found);
|
||||
leader_found = true;
|
||||
|
@ -1147,9 +1147,9 @@ mod test {
|
||||
fn stress() {
|
||||
let (tx, rx) = channel::<int>();
|
||||
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);
|
||||
}
|
||||
t.join().ok().unwrap();
|
||||
@ -1209,7 +1209,7 @@ mod test {
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
}
|
||||
});
|
||||
for _ in 0u..40 {
|
||||
for _ in 0..40 {
|
||||
tx.send(1).unwrap();
|
||||
}
|
||||
t.join().ok().unwrap();
|
||||
@ -1530,7 +1530,7 @@ mod test {
|
||||
tx2.send(()).unwrap();
|
||||
});
|
||||
// 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
|
||||
let t = tx.clone();
|
||||
@ -1654,9 +1654,9 @@ mod sync_tests {
|
||||
fn stress() {
|
||||
let (tx, rx) = sync_channel::<int>(0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1893,8 +1893,8 @@ mod sync_tests {
|
||||
fn recv_a_lot() {
|
||||
// Regression test that we don't run out of stack in scheduler context
|
||||
let (tx, rx) = sync_channel(10000);
|
||||
for _ in 0u..10000 { tx.send(()).unwrap(); }
|
||||
for _ in 0u..10000 { rx.recv().unwrap(); }
|
||||
for _ in 0..10000 { tx.send(()).unwrap(); }
|
||||
for _ in 0..10000 { rx.recv().unwrap(); }
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1994,7 +1994,7 @@ mod sync_tests {
|
||||
tx2.send(()).unwrap();
|
||||
});
|
||||
// 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
|
||||
let t = tx.clone();
|
||||
@ -2082,7 +2082,7 @@ mod sync_tests {
|
||||
rx2.recv().unwrap();
|
||||
}
|
||||
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
repro()
|
||||
}
|
||||
}
|
||||
|
@ -171,8 +171,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
let nthreads = 8u;
|
||||
let nmsgs = 1000u;
|
||||
let nthreads = 8;
|
||||
let nmsgs = 1000;
|
||||
let q = Queue::new();
|
||||
match q.pop() {
|
||||
Empty => {}
|
||||
@ -192,7 +192,7 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while i < nthreads * nmsgs {
|
||||
match q.pop() {
|
||||
Empty | Inconsistent => {},
|
||||
|
@ -428,10 +428,10 @@ mod test {
|
||||
let (tx3, rx3) = channel::<int>();
|
||||
|
||||
let _t = thread::spawn(move|| {
|
||||
for _ in 0u..20 { thread::yield_now(); }
|
||||
for _ in 0..20 { thread::yield_now(); }
|
||||
tx1.send(1).unwrap();
|
||||
rx3.recv().unwrap();
|
||||
for _ in 0u..20 { thread::yield_now(); }
|
||||
for _ in 0..20 { thread::yield_now(); }
|
||||
});
|
||||
|
||||
select! {
|
||||
@ -452,7 +452,7 @@ mod test {
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
|
||||
let _t = thread::spawn(move|| {
|
||||
for _ in 0u..20 { thread::yield_now(); }
|
||||
for _ in 0..20 { thread::yield_now(); }
|
||||
tx1.send(1).unwrap();
|
||||
tx2.send(2).unwrap();
|
||||
rx3.recv().unwrap();
|
||||
@ -557,7 +557,7 @@ mod test {
|
||||
tx3.send(()).unwrap();
|
||||
});
|
||||
|
||||
for _ in 0u..1000 { thread::yield_now(); }
|
||||
for _ in 0..1000 { thread::yield_now(); }
|
||||
drop(tx1.clone());
|
||||
tx2.send(()).unwrap();
|
||||
rx3.recv().unwrap();
|
||||
@ -670,7 +670,7 @@ mod test {
|
||||
tx2.send(()).unwrap();
|
||||
});
|
||||
|
||||
for _ in 0u..100 { thread::yield_now() }
|
||||
for _ in 0..100 { thread::yield_now() }
|
||||
tx1.send(()).unwrap();
|
||||
rx2.recv().unwrap();
|
||||
}
|
||||
@ -690,7 +690,7 @@ mod test {
|
||||
tx2.send(()).unwrap();
|
||||
});
|
||||
|
||||
for _ in 0u..100 { thread::yield_now() }
|
||||
for _ in 0..100 { thread::yield_now() }
|
||||
tx1.send(()).unwrap();
|
||||
rx2.recv().unwrap();
|
||||
}
|
||||
@ -709,7 +709,7 @@ mod test {
|
||||
tx2.send(()).unwrap();
|
||||
});
|
||||
|
||||
for _ in 0u..100 { thread::yield_now() }
|
||||
for _ in 0..100 { thread::yield_now() }
|
||||
tx1.send(()).unwrap();
|
||||
rx2.recv().unwrap();
|
||||
}
|
||||
@ -727,7 +727,7 @@ mod test {
|
||||
fn sync2() {
|
||||
let (tx, rx) = sync_channel::<int>(0);
|
||||
let _t = thread::spawn(move|| {
|
||||
for _ in 0u..100 { thread::yield_now() }
|
||||
for _ in 0..100 { thread::yield_now() }
|
||||
tx.send(1).unwrap();
|
||||
});
|
||||
select! {
|
||||
|
@ -325,7 +325,7 @@ mod test {
|
||||
let (tx, rx) = channel();
|
||||
let q2 = q.clone();
|
||||
let _t = thread::spawn(move|| {
|
||||
for _ in 0u..100000 {
|
||||
for _ in 0..100000 {
|
||||
loop {
|
||||
match q2.pop() {
|
||||
Some(1) => break,
|
||||
|
@ -60,7 +60,7 @@ use sys_common::mutex as sys;
|
||||
/// let data = Arc::new(Mutex::new(0));
|
||||
///
|
||||
/// let (tx, rx) = channel();
|
||||
/// for _ in 0u..10 {
|
||||
/// for _ in 0..10 {
|
||||
/// let (data, tx) = (data.clone(), tx.clone());
|
||||
/// thread::spawn(move || {
|
||||
/// // 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::thread;
|
||||
///
|
||||
/// let lock = Arc::new(Mutex::new(0u));
|
||||
/// let lock = Arc::new(Mutex::new(0_u32));
|
||||
/// let lock2 = lock.clone();
|
||||
///
|
||||
/// let _ = thread::spawn(move || -> () {
|
||||
|
@ -147,10 +147,10 @@ mod test {
|
||||
static mut run: bool = false;
|
||||
|
||||
let (tx, rx) = channel();
|
||||
for _ in 0u..10 {
|
||||
for _ in 0..10 {
|
||||
let tx = tx.clone();
|
||||
thread::spawn(move|| {
|
||||
for _ in 0u..4 { thread::yield_now() }
|
||||
for _ in 0..4 { thread::yield_now() }
|
||||
unsafe {
|
||||
O.call_once(|| {
|
||||
assert!(!run);
|
||||
@ -170,7 +170,7 @@ mod test {
|
||||
assert!(run);
|
||||
}
|
||||
|
||||
for _ in 0u..10 {
|
||||
for _ in 0..10 {
|
||||
rx.recv().unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ mod tests {
|
||||
|
||||
thread::spawn(move|| {
|
||||
let mut lock = arc2.write().unwrap();
|
||||
for _ in 0u..10 {
|
||||
for _ in 0..10 {
|
||||
let tmp = *lock;
|
||||
*lock = -1;
|
||||
thread::yield_now();
|
||||
@ -514,7 +514,7 @@ mod tests {
|
||||
|
||||
// Readers try to catch the writer in the act
|
||||
let mut children = Vec::new();
|
||||
for _ in 0u..5 {
|
||||
for _ in 0..5 {
|
||||
let arc3 = arc.clone();
|
||||
children.push(thread::spawn(move|| {
|
||||
let lock = arc3.read().unwrap();
|
||||
|
@ -63,17 +63,17 @@ impl<'a> Drop for Sentinel<'a> {
|
||||
/// use std::iter::AdditiveIterator;
|
||||
/// use std::sync::mpsc::channel;
|
||||
///
|
||||
/// let pool = TaskPool::new(4u);
|
||||
/// let pool = TaskPool::new(4);
|
||||
///
|
||||
/// let (tx, rx) = channel();
|
||||
/// for _ in 0..8u {
|
||||
/// for _ in 0..8 {
|
||||
/// let tx = tx.clone();
|
||||
/// 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 {
|
||||
// How the threadpool communicates with subthreads.
|
||||
@ -142,7 +142,7 @@ mod test {
|
||||
use super::*;
|
||||
use sync::mpsc::channel;
|
||||
|
||||
const TEST_TASKS: uint = 4u;
|
||||
const TEST_TASKS: uint = 4;
|
||||
|
||||
#[test]
|
||||
fn test_works() {
|
||||
@ -154,7 +154,7 @@ mod test {
|
||||
for _ in 0..TEST_TASKS {
|
||||
let tx = tx.clone();
|
||||
pool.execute(move|| {
|
||||
tx.send(1u).unwrap();
|
||||
tx.send(1).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ mod test {
|
||||
for _ in 0..TEST_TASKS {
|
||||
let tx = tx.clone();
|
||||
pool.execute(move|| {
|
||||
tx.send(1u).unwrap();
|
||||
tx.send(1).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -175,13 +175,13 @@ pub fn current_exe() -> IoResult<Path> {
|
||||
let mut sz: libc::size_t = 0;
|
||||
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
|
||||
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 sz == 0 { return Err(IoError::last_error()); }
|
||||
let mut v: Vec<u8> = Vec::with_capacity(sz as 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,
|
||||
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 sz == 0 { return Err(IoError::last_error()); }
|
||||
v.set_len(sz as uint - 1); // chop off trailing NUL
|
||||
|
@ -105,7 +105,7 @@ pub struct WSAPROTOCOL_INFO {
|
||||
pub iSecurityScheme: libc::c_int,
|
||||
pub dwMessageSize: 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;
|
||||
|
@ -388,7 +388,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
|
||||
cmd.push('"');
|
||||
}
|
||||
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);
|
||||
}
|
||||
if quote {
|
||||
|
@ -141,10 +141,7 @@ pub fn is_path(e: P<Expr>) -> bool {
|
||||
/// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
|
||||
pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
|
||||
let s = match t {
|
||||
TyIs(true) if val.is_some() => "i",
|
||||
TyIs(true) => "int",
|
||||
TyIs(false) if val.is_some() => "is",
|
||||
TyIs(false) => "isize",
|
||||
TyIs(_) => "isize",
|
||||
TyI8 => "i8",
|
||||
TyI16 => "i16",
|
||||
TyI32 => "i32",
|
||||
@ -173,10 +170,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
|
||||
/// We want to avoid "42u" in favor of "42us". "42uint" is right out.
|
||||
pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
|
||||
let s = match t {
|
||||
TyUs(true) if val.is_some() => "u",
|
||||
TyUs(true) => "uint",
|
||||
TyUs(false) if val.is_some() => "us",
|
||||
TyUs(false) => "usize",
|
||||
TyUs(_) => "usize",
|
||||
TyU8 => "u8",
|
||||
TyU16 => "u16",
|
||||
TyU32 => "u32",
|
||||
|
@ -488,7 +488,7 @@ pub fn parse(sess: &ParseSess,
|
||||
let match_cur = ei.match_cur;
|
||||
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
|
||||
parse_nt(&mut rust_parser, span, &name_string))));
|
||||
ei.idx += 1us;
|
||||
ei.idx += 1;
|
||||
ei.match_cur += 1;
|
||||
}
|
||||
_ => panic!()
|
||||
|
@ -588,11 +588,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
match lit.node {
|
||||
ast::LitInt(_, ty) => {
|
||||
let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty {
|
||||
Some("the `i` suffix on integers is deprecated; use `is` \
|
||||
or one of the fixed-sized suffixes")
|
||||
Some("the `i` and `is` suffixes on integers are deprecated; \
|
||||
use `isize` or one of the fixed-sized suffixes")
|
||||
} else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty {
|
||||
Some("the `u` suffix on integers is deprecated; use `us` \
|
||||
or one of the fixed-sized suffixes")
|
||||
Some("the `u` and `us` suffixes on integers are deprecated; \
|
||||
use `usize` or one of the fixed-sized suffixes")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -701,18 +701,18 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
|
||||
if let Some(suf) = suffix {
|
||||
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
|
||||
ty = match suf {
|
||||
"i" => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
|
||||
"is" => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
|
||||
"isize" => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
|
||||
"i8" => ast::SignedIntLit(ast::TyI8, ast::Plus),
|
||||
"i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
|
||||
"i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
|
||||
"i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
|
||||
"u" => ast::UnsignedIntLit(ast::TyUs(true)),
|
||||
"us" => ast::UnsignedIntLit(ast::TyUs(false)),
|
||||
"usize" => ast::UnsignedIntLit(ast::TyUs(false)),
|
||||
"u8" => ast::UnsignedIntLit(ast::TyU8),
|
||||
"u16" => ast::UnsignedIntLit(ast::TyU16),
|
||||
"u32" => ast::UnsignedIntLit(ast::TyU32),
|
||||
"u64" => ast::UnsignedIntLit(ast::TyU64),
|
||||
"i" | "is" => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
|
||||
"u" | "us" => ast::UnsignedIntLit(ast::TyUs(true)),
|
||||
_ => {
|
||||
// i<digits> and u<digits> look like widths, so lets
|
||||
// give an error message along those lines
|
||||
@ -722,6 +722,8 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
|
||||
&suf[1..]));
|
||||
} else {
|
||||
sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
|
||||
sd.span_help(sp, "the suffix must be one of the integral types \
|
||||
(`u32`, `isize`, etc)");
|
||||
}
|
||||
|
||||
ty
|
||||
|
@ -168,7 +168,7 @@ pub fn mk_printer(out: Box<old_io::Writer+'static>, linewidth: usize) -> Printer
|
||||
debug!("mk_printer {}", linewidth);
|
||||
let token: Vec<Token> = repeat(Token::Eof).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 {
|
||||
out: out,
|
||||
buf_len: n,
|
||||
|
@ -185,7 +185,7 @@ pub fn parse(file: &mut old_io::Reader, longnames: bool)
|
||||
let magic = try!(file.read_le_u16());
|
||||
if magic != 0x011A {
|
||||
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;
|
||||
|
@ -939,7 +939,7 @@ mod bench {
|
||||
#[bench]
|
||||
pub fn sum_many_f64(b: &mut Bencher) {
|
||||
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(|| {
|
||||
v.sum();
|
||||
|
@ -143,9 +143,9 @@ pub fn parse_summary<R: Reader>(input: R, src: &Path) -> Result<Book, Vec<String
|
||||
path_to_root: path_to_root,
|
||||
children: vec!(),
|
||||
};
|
||||
let level = indent.chars().map(|c| {
|
||||
let level = indent.chars().map(|c| -> usize {
|
||||
match c {
|
||||
' ' => 1us,
|
||||
' ' => 1,
|
||||
'\t' => 4,
|
||||
_ => unreachable!()
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub mod kitties {
|
||||
}
|
||||
|
||||
impl cat {
|
||||
pub fn speak(&mut self) { self.meows += 1u; }
|
||||
pub fn speak(&mut self) { self.meows += 1_usize; }
|
||||
pub fn meow_count(&mut self) -> uint { self.meows }
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ pub mod kitties {
|
||||
impl cat {
|
||||
pub fn meow(&mut self) {
|
||||
println!("Meow");
|
||||
self.meows += 1u;
|
||||
if self.meows % 5u == 0u {
|
||||
self.meows += 1_usize;
|
||||
if self.meows % 5_usize == 0_usize {
|
||||
self.how_hungry += 1;
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ pub mod kitty {
|
||||
impl cat {
|
||||
fn meow(&mut self) {
|
||||
println!("Meow");
|
||||
self.meows += 1u;
|
||||
if self.meows % 5u == 0u {
|
||||
self.meows += 1_usize;
|
||||
if self.meows % 5_usize == 0_usize {
|
||||
self.how_hungry += 1;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl uint_helpers for uint {
|
||||
let mut i = *self;
|
||||
while i < v {
|
||||
f(i);
|
||||
i += 1u;
|
||||
i += 1_usize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
#[inline]
|
||||
pub fn iter<T, F>(v: &[T], mut f: F) where F: FnMut(&T) {
|
||||
let mut i = 0u;
|
||||
let mut i = 0_usize;
|
||||
let n = v.len();
|
||||
while i < n {
|
||||
f(&v[i]);
|
||||
i += 1u;
|
||||
i += 1_usize;
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
// same as cci_iter_lib, more-or-less, but not marked inline
|
||||
pub fn iter<F>(v: Vec<uint> , mut f: F) where F: FnMut(uint) {
|
||||
let mut i = 0u;
|
||||
let mut i = 0_usize;
|
||||
let n = v.len();
|
||||
while i < n {
|
||||
f(v[i]);
|
||||
i += 1u;
|
||||
i += 1_usize;
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,5 @@
|
||||
#![crate_type = "dylib"]
|
||||
#[macro_export]
|
||||
macro_rules! reexported {
|
||||
() => ( 3u )
|
||||
() => ( 3_usize )
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
};
|
||||
|
||||
let mut text = &*text;
|
||||
let mut total = 0u;
|
||||
let mut total = 0_usize;
|
||||
while !text.is_empty() {
|
||||
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
|
||||
Some(&(rn, val)) => {
|
||||
|
@ -14,9 +14,9 @@ use std::ops::Add;
|
||||
|
||||
#[inline]
|
||||
pub fn has_closures() -> uint {
|
||||
let x = 1u;
|
||||
let x = 1_usize;
|
||||
let mut f = move || x;
|
||||
let y = 1u;
|
||||
let y = 1_usize;
|
||||
let g = || y;
|
||||
f() + g()
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ fn read_line() {
|
||||
let mut path = Path::new(env!("CFG_SRC_DIR"));
|
||||
path.push("src/test/bench/shootout-k-nucleotide.data");
|
||||
|
||||
for _ in 0u..3 {
|
||||
for _ in 0..3 {
|
||||
let mut reader = BufferedReader::new(File::open(&path).unwrap());
|
||||
for _line in reader.lines() {
|
||||
}
|
||||
@ -88,7 +88,7 @@ fn vec_plus() {
|
||||
let mut v = Vec::new();
|
||||
let mut i = 0;
|
||||
while i < 1500 {
|
||||
let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
|
||||
let rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
|
||||
if r.gen() {
|
||||
v.extend(rv.into_iter());
|
||||
} else {
|
||||
@ -106,7 +106,7 @@ fn vec_append() {
|
||||
let mut v = Vec::new();
|
||||
let mut i = 0;
|
||||
while i < 1500 {
|
||||
let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
|
||||
let rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
|
||||
if r.gen() {
|
||||
let mut t = v.clone();
|
||||
t.push_all(&rv);
|
||||
@ -125,8 +125,8 @@ fn vec_push_all() {
|
||||
let mut r = rand::thread_rng();
|
||||
|
||||
let mut v = Vec::new();
|
||||
for i in 0u..1500 {
|
||||
let mut rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
|
||||
for i in 0..1500 {
|
||||
let mut rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
|
||||
if r.gen() {
|
||||
v.push_all(&rv);
|
||||
}
|
||||
@ -139,7 +139,7 @@ fn vec_push_all() {
|
||||
|
||||
fn is_utf8_ascii() {
|
||||
let mut v : Vec<u8> = Vec::new();
|
||||
for _ in 0u..20000 {
|
||||
for _ in 0..20000 {
|
||||
v.push('b' as u8);
|
||||
if str::from_utf8(&v).is_err() {
|
||||
panic!("from_utf8 panicked");
|
||||
@ -150,7 +150,7 @@ fn is_utf8_ascii() {
|
||||
fn is_utf8_multibyte() {
|
||||
let s = "b¢€𤭢";
|
||||
let mut v : Vec<u8> = Vec::new();
|
||||
for _ in 0u..5000 {
|
||||
for _ in 0..5000 {
|
||||
v.push_all(s.as_bytes());
|
||||
if str::from_utf8(&v).is_err() {
|
||||
panic!("from_utf8 panicked");
|
||||
|
@ -14,7 +14,7 @@ fn main() {
|
||||
let args = env::args();
|
||||
let args = if env::var_os("RUST_BENCH").is_some() {
|
||||
vec!("".to_string(), "10000000".to_string())
|
||||
} else if args.len() <= 1u {
|
||||
} else if args.len() <= 1 {
|
||||
vec!("".to_string(), "100000".to_string())
|
||||
} else {
|
||||
args.collect()
|
||||
@ -22,7 +22,7 @@ fn main() {
|
||||
|
||||
let n = args[1].parse().unwrap();
|
||||
|
||||
for i in 0u..n {
|
||||
for i in 0..n {
|
||||
let x = i.to_string();
|
||||
println!("{}", x);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ enum request {
|
||||
}
|
||||
|
||||
fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
|
||||
let mut count = 0u;
|
||||
let mut count = 0;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
match requests.recv() {
|
||||
@ -61,10 +61,10 @@ fn run(args: &[String]) {
|
||||
let dur = Duration::span(|| {
|
||||
let (to_child, to_parent, from_parent) = p.take().unwrap();
|
||||
let mut worker_results = Vec::new();
|
||||
for _ in 0u..workers {
|
||||
for _ in 0..workers {
|
||||
let to_child = to_child.clone();
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
for _ in 0..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes)).unwrap();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ fn run(args: &[String]) {
|
||||
let from_parent = if workers == 1 {
|
||||
let (to_child, from_parent) = channel();
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
for _ in 0..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes));
|
||||
}
|
||||
@ -66,10 +66,10 @@ fn run(args: &[String]) {
|
||||
from_parent
|
||||
} else {
|
||||
let (to_child, from_parent) = channel();
|
||||
for _ in 0u..workers {
|
||||
for _ in 0..workers {
|
||||
let to_child = to_child.clone();
|
||||
worker_results.push(thread::spawn(move|| {
|
||||
for _ in 0u..size / workers {
|
||||
for _ in 0..size / workers {
|
||||
//println!("worker {}: sending {} bytes", i, num_bytes);
|
||||
to_child.send(request::bytes(num_bytes));
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
|
||||
let mut num_chan = Some(num_chan);
|
||||
let mut num_port = Some(num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for j in 0u..count {
|
||||
for j in 0..count {
|
||||
//println!("task %?, iter %?", i, j);
|
||||
let num_chan2 = num_chan.take().unwrap();
|
||||
let num_port2 = num_port.take().unwrap();
|
||||
@ -84,7 +84,7 @@ fn main() {
|
||||
// create the ring
|
||||
let mut futures = Vec::new();
|
||||
|
||||
for i in 1u..num_tasks {
|
||||
for i in 1..num_tasks {
|
||||
//println!("spawning %?", i);
|
||||
let (new_chan, num_port) = init();
|
||||
let num_chan_2 = num_chan.clone();
|
||||
|
@ -104,17 +104,17 @@ fn main() {
|
||||
let mut pixels = [0f32; 256*256];
|
||||
let n2d = Noise2DContext::new();
|
||||
|
||||
for _ in 0u..100 {
|
||||
for y in 0u..256 {
|
||||
for x in 0u..256 {
|
||||
for _ in 0..100 {
|
||||
for y in 0..256 {
|
||||
for x in 0..256 {
|
||||
let v = n2d.get(x as f32 * 0.1, y as f32 * 0.1);
|
||||
pixels[y*256+x] = v * 0.5 + 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for y in 0u..256 {
|
||||
for x in 0u..256 {
|
||||
for y in 0..256 {
|
||||
for x in 0..256 {
|
||||
let idx = (pixels[y*256+x] / 0.2) as uint;
|
||||
print!("{}", symbols[idx]);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ fn main() {
|
||||
std::env::args()
|
||||
.nth(1)
|
||||
.and_then(|arg| arg.parse().ok())
|
||||
.unwrap_or(600us)
|
||||
.unwrap_or(600)
|
||||
};
|
||||
|
||||
print_complements();
|
||||
|
@ -77,7 +77,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
|
||||
fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
|
||||
let key = key.into_ascii_lowercase();
|
||||
match mm.get(key.as_bytes()) {
|
||||
option::Option::None => { return 0u; }
|
||||
option::Option::None => { return 0; }
|
||||
option::Option::Some(&num) => { return num; }
|
||||
}
|
||||
}
|
||||
@ -98,15 +98,15 @@ fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
|
||||
fn windows_with_carry<F>(bb: &[u8], nn: uint, mut it: F) -> Vec<u8> where
|
||||
F: FnMut(&[u8]),
|
||||
{
|
||||
let mut ii = 0u;
|
||||
let mut ii = 0;
|
||||
|
||||
let len = bb.len();
|
||||
while ii < len - (nn - 1u) {
|
||||
while ii < len - (nn - 1) {
|
||||
it(&bb[ii..ii+nn]);
|
||||
ii += 1u;
|
||||
ii += 1;
|
||||
}
|
||||
|
||||
return bb[len - (nn - 1u)..len].to_vec();
|
||||
return bb[len - (nn - 1)..len].to_vec();
|
||||
}
|
||||
|
||||
fn make_sequence_processor(sz: uint,
|
||||
@ -114,7 +114,7 @@ fn make_sequence_processor(sz: uint,
|
||||
to_parent: &Sender<String>) {
|
||||
let mut freqs: HashMap<Vec<u8>, uint> = HashMap::new();
|
||||
let mut carry = Vec::new();
|
||||
let mut total: uint = 0u;
|
||||
let mut total: uint = 0;
|
||||
|
||||
let mut line: Vec<u8>;
|
||||
|
||||
@ -126,20 +126,20 @@ fn make_sequence_processor(sz: uint,
|
||||
carry.push_all(&line);
|
||||
carry = windows_with_carry(&carry, sz, |window| {
|
||||
update_freq(&mut freqs, window);
|
||||
total += 1u;
|
||||
total += 1;
|
||||
});
|
||||
}
|
||||
|
||||
let buffer = match sz {
|
||||
1u => { sort_and_fmt(&freqs, total) }
|
||||
2u => { sort_and_fmt(&freqs, total) }
|
||||
3u => { format!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
|
||||
4u => { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
|
||||
6u => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
|
||||
12u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
|
||||
18u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
|
||||
1 => { sort_and_fmt(&freqs, total) }
|
||||
2 => { sort_and_fmt(&freqs, total) }
|
||||
3 => { format!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
|
||||
4 => { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
|
||||
6 => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
|
||||
12 => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
|
||||
18 => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
|
||||
"GGTATTTTAATTTATAGT") }
|
||||
_ => { "".to_string() }
|
||||
_ => { "".to_string() }
|
||||
};
|
||||
|
||||
to_parent.send(buffer).unwrap();
|
||||
@ -158,7 +158,7 @@ fn main() {
|
||||
let mut rdr = BufferedReader::new(rdr);
|
||||
|
||||
// initialize each sequence sorter
|
||||
let sizes = vec!(1u,2,3,4,6,12,18);
|
||||
let sizes: Vec<usize> = vec!(1,2,3,4,6,12,18);
|
||||
let mut streams = (0..sizes.len()).map(|_| {
|
||||
Some(channel::<String>())
|
||||
}).collect::<Vec<_>>();
|
||||
@ -177,7 +177,7 @@ fn main() {
|
||||
});
|
||||
|
||||
to_child
|
||||
}).collect::<Vec<Sender<Vec<u8> >> >();
|
||||
}).collect::<Vec<Sender<Vec<u8>>>>();
|
||||
|
||||
|
||||
// latch stores true after we've started
|
||||
@ -187,7 +187,7 @@ fn main() {
|
||||
for line in rdr.lines() {
|
||||
let line = line.unwrap().trim().to_string();
|
||||
|
||||
if line.len() == 0u { continue; }
|
||||
if line.len() == 0 { continue; }
|
||||
|
||||
match (line.as_bytes()[0] as char, proc_mode) {
|
||||
|
||||
|
@ -301,7 +301,7 @@ fn main() {
|
||||
};
|
||||
let input = Arc::new(input);
|
||||
|
||||
let nb_freqs: Vec<_> = (1u..3).map(|i| {
|
||||
let nb_freqs: Vec<_> = (1..3).map(|i| {
|
||||
let input = input.clone();
|
||||
(i, thread::scoped(move|| generate_frequencies(&input, i)))
|
||||
}).collect();
|
||||
|
@ -222,7 +222,7 @@ fn to_vec(raw_sol: &List<u64>) -> Vec<u8> {
|
||||
let mut sol = repeat('.' as u8).take(50).collect::<Vec<_>>();
|
||||
for &m in raw_sol.iter() {
|
||||
let id = '0' as u8 + get_id(m);
|
||||
for i in 0us..50 {
|
||||
for i in 0..50 {
|
||||
if m & 1 << i != 0 {
|
||||
sol[i] = id;
|
||||
}
|
||||
@ -297,7 +297,7 @@ fn search(
|
||||
let masks_at = &masks[i];
|
||||
|
||||
// for every unused piece
|
||||
for id in (0us..10).filter(|&id| board & (1 << (id + 50)) == 0) {
|
||||
for id in (0..10).filter(|&id| board & (1 << (id + 50)) == 0) {
|
||||
// for each mask that fits on the board
|
||||
for m in masks_at[id].iter().filter(|&m| board & *m == 0) {
|
||||
// This check is too costly.
|
||||
|
@ -69,7 +69,7 @@ fn spectralnorm(n: uint) -> f64 {
|
||||
let mut u = repeat(1.0).take(n).collect::<Vec<_>>();
|
||||
let mut v = u.clone();
|
||||
let mut tmp = v.clone();
|
||||
for _ in 0u..10 {
|
||||
for _ in 0..10 {
|
||||
mult_AtAv(&u, &mut v, &mut tmp);
|
||||
mult_AtAv(&v, &mut u, &mut tmp);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ impl Sudoku {
|
||||
}
|
||||
|
||||
pub fn from_vec(vec: &[[u8;9];9]) -> Sudoku {
|
||||
let g = (0..9u).map(|i| {
|
||||
(0..9u).map(|j| { vec[i][j] }).collect()
|
||||
let g = (0..9).map(|i| {
|
||||
(0..9).map(|j| { vec[i][j] }).collect()
|
||||
}).collect();
|
||||
return Sudoku::new(g)
|
||||
}
|
||||
@ -68,7 +68,7 @@ impl Sudoku {
|
||||
.split(',')
|
||||
.collect();
|
||||
|
||||
if comps.len() == 3u {
|
||||
if comps.len() == 3 {
|
||||
let row = comps[0].parse::<u8>().unwrap();
|
||||
let col = comps[1].parse::<u8>().unwrap();
|
||||
g[row as uint][col as uint] = comps[2].parse().unwrap();
|
||||
@ -102,7 +102,7 @@ impl Sudoku {
|
||||
}
|
||||
}
|
||||
|
||||
let mut ptr = 0u;
|
||||
let mut ptr = 0;
|
||||
let end = work.len();
|
||||
while ptr < end {
|
||||
let (row, col) = work[ptr];
|
||||
@ -111,11 +111,11 @@ impl Sudoku {
|
||||
(1 as u8);
|
||||
if self.next_color(row, col, the_color) {
|
||||
// yes: advance work list
|
||||
ptr = ptr + 1u;
|
||||
ptr = ptr + 1;
|
||||
} else {
|
||||
// no: redo this field aft recoloring pred; unless there is none
|
||||
if ptr == 0u { panic!("No solution found for this sudoku"); }
|
||||
ptr = ptr - 1u;
|
||||
if ptr == 0 { panic!("No solution found for this sudoku"); }
|
||||
ptr = ptr - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ use std::env;
|
||||
use std::thread;
|
||||
|
||||
fn f(n: usize) {
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while i < n {
|
||||
let _ = thread::spawn(move|| g()).join();
|
||||
i += 1u;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,6 @@ pub use use_from_trait_xc::Trait;
|
||||
|
||||
fn main() {
|
||||
match () {
|
||||
Trait { x: 42us } => () //~ ERROR use of trait `Trait` in a struct pattern
|
||||
Trait { x: 42_usize } => () //~ ERROR use of trait `Trait` in a struct pattern
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ pub fn main() {
|
||||
let x: isize;
|
||||
let y: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "=r"(5us)); //~ ERROR input operand constraint contains '='
|
||||
asm!("mov $1, $0" : "=r"(y) : "+r"(5us)); //~ ERROR input operand constraint contains '+'
|
||||
asm!("mov $1, $0" : "=r"(x) : "=r"(5_usize)); //~ ERROR operand constraint contains '='
|
||||
asm!("mov $1, $0" : "=r"(y) : "+r"(5_usize)); //~ ERROR operand constraint contains '+'
|
||||
}
|
||||
foo(x);
|
||||
foo(y);
|
||||
|
@ -21,14 +21,14 @@ pub fn main() {
|
||||
let mut x: isize = 0;
|
||||
unsafe {
|
||||
// extra colon
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5us), "0"(x) : : "cc");
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
|
||||
//~^ WARNING unrecognized option
|
||||
}
|
||||
assert_eq!(x, 5);
|
||||
|
||||
unsafe {
|
||||
// comma in place of a colon
|
||||
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8us) : "cc", "volatile");
|
||||
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
|
||||
//~^ WARNING expected a clobber, found an option
|
||||
}
|
||||
assert_eq!(x, 13);
|
||||
|
@ -21,7 +21,8 @@ pub fn main() {
|
||||
x = 1; //~ NOTE prior assignment occurs here
|
||||
foo(x);
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5us)); //~ ERROR re-assignment of immutable variable `x`
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
|
||||
//~^ ERROR re-assignment of immutable variable `x`
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ fn foo(x: isize) { println!("{}", x); }
|
||||
pub fn main() {
|
||||
let x: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "r"(x) : "r"(5us)); //~ ERROR output operand constraint lacks '='
|
||||
asm!("mov $1, $0" : "r"(x) : "r"(5_usize)); //~ ERROR output operand constraint lacks '='
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ struct cat {
|
||||
}
|
||||
|
||||
impl cat {
|
||||
pub fn speak(&self) { self.meows += 1us; }
|
||||
pub fn speak(&self) { self.meows += 1_usize; }
|
||||
}
|
||||
|
||||
fn cat(in_x : usize, in_y : isize) -> cat {
|
||||
@ -26,6 +26,6 @@ fn cat(in_x : usize, in_y : isize) -> cat {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let nyan : cat = cat(52us, 99);
|
||||
let nyan : cat = cat(52_usize, 99);
|
||||
nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
|
||||
}
|
||||
|
@ -10,5 +10,5 @@
|
||||
|
||||
fn main() {
|
||||
#[attr] //~ ERROR expected item
|
||||
let _i = 0;
|
||||
let __isize = 0;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Tests that a function with a ! annotation always actually fails
|
||||
|
||||
fn bad_bang(i: usize) -> ! {
|
||||
return 7us; //~ ERROR `return` in a function declared as diverging [E0166]
|
||||
return 7_usize; //~ ERROR `return` in a function declared as diverging [E0166]
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5us); }
|
||||
fn main() { bad_bang(5); }
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Tests that a function with a ! annotation always actually fails
|
||||
|
||||
fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function marked as diverging
|
||||
if i < 0us { } else { panic!(); }
|
||||
if i < 0_usize { } else { panic!(); }
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5us); }
|
||||
fn main() { bad_bang(5); }
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn foo<T:'static>() {
|
||||
1us.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
|
||||
1_usize.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
|
||||
}
|
||||
|
||||
trait bar {
|
||||
|
@ -21,25 +21,25 @@ fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
|
||||
fn main() {
|
||||
// By-ref captures
|
||||
{
|
||||
let mut x = 0us;
|
||||
let mut x = 0_usize;
|
||||
let _f = to_fn(|| x = 42); //~ ERROR cannot assign
|
||||
|
||||
let mut y = 0us;
|
||||
let mut y = 0_usize;
|
||||
let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
|
||||
|
||||
let mut z = 0us;
|
||||
let mut z = 0_usize;
|
||||
let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
// By-value captures
|
||||
{
|
||||
let mut x = 0us;
|
||||
let mut x = 0_usize;
|
||||
let _f = to_fn(move || x = 42); //~ ERROR cannot assign
|
||||
|
||||
let mut y = 0us;
|
||||
let mut y = 0_usize;
|
||||
let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
|
||||
|
||||
let mut z = 0us;
|
||||
let mut z = 0_usize;
|
||||
let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
|
||||
}
|
||||
}
|
||||
|
@ -56,15 +56,15 @@ impl Point {
|
||||
}
|
||||
|
||||
fn deref_imm_field(x: Own<Point>) {
|
||||
let _i = &x.y;
|
||||
let __isize = &x.y;
|
||||
}
|
||||
|
||||
fn deref_mut_field1(x: Own<Point>) {
|
||||
let _i = &mut x.y; //~ ERROR cannot borrow
|
||||
let __isize = &mut x.y; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut_field2(mut x: Own<Point>) {
|
||||
let _i = &mut x.y;
|
||||
let __isize = &mut x.y;
|
||||
}
|
||||
|
||||
fn deref_extend_field(x: &Own<Point>) -> &isize {
|
||||
@ -114,7 +114,7 @@ fn assign_field4<'a>(x: &'a mut Own<Point>) {
|
||||
// FIXME(eddyb) #12825 This shouldn't attempt to call deref_mut.
|
||||
/*
|
||||
fn deref_imm_method(x: Own<Point>) {
|
||||
let _i = x.get();
|
||||
let __isize = x.get();
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -50,15 +50,15 @@ impl Point {
|
||||
}
|
||||
|
||||
fn deref_imm_field(x: Rc<Point>) {
|
||||
let _i = &x.y;
|
||||
let __isize = &x.y;
|
||||
}
|
||||
|
||||
fn deref_mut_field1(x: Rc<Point>) {
|
||||
let _i = &mut x.y; //~ ERROR cannot borrow
|
||||
let __isize = &mut x.y; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut_field2(mut x: Rc<Point>) {
|
||||
let _i = &mut x.y; //~ ERROR cannot borrow
|
||||
let __isize = &mut x.y; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_field(x: &Rc<Point>) -> &isize {
|
||||
@ -86,7 +86,7 @@ fn assign_field3<'a>(x: &'a mut Rc<Point>) {
|
||||
}
|
||||
|
||||
fn deref_imm_method(x: Rc<Point>) {
|
||||
let _i = x.get();
|
||||
let __isize = x.get();
|
||||
}
|
||||
|
||||
fn deref_mut_method1(x: Rc<Point>) {
|
||||
|
@ -32,15 +32,15 @@ impl<T> DerefMut for Own<T> {
|
||||
}
|
||||
|
||||
fn deref_imm(x: Own<isize>) {
|
||||
let _i = &*x;
|
||||
let __isize = &*x;
|
||||
}
|
||||
|
||||
fn deref_mut1(x: Own<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
let __isize = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut2(mut x: Own<isize>) {
|
||||
let _i = &mut *x;
|
||||
let __isize = &mut *x;
|
||||
}
|
||||
|
||||
fn deref_extend<'a>(x: &'a Own<isize>) -> &'a isize {
|
||||
|
@ -26,15 +26,15 @@ impl<T> Deref for Rc<T> {
|
||||
}
|
||||
|
||||
fn deref_imm(x: Rc<isize>) {
|
||||
let _i = &*x;
|
||||
let __isize = &*x;
|
||||
}
|
||||
|
||||
fn deref_mut1(x: Rc<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
let __isize = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut2(mut x: Rc<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
let __isize = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend<'a>(x: &'a Rc<isize>) -> &'a isize {
|
||||
|
@ -11,11 +11,11 @@
|
||||
use std::iter::repeat;
|
||||
|
||||
fn main() {
|
||||
let mut vector = vec![1us, 2];
|
||||
let mut vector = vec![1, 2];
|
||||
for &x in &vector {
|
||||
let cap = vector.capacity();
|
||||
vector.extend(repeat(0)); //~ ERROR cannot borrow
|
||||
vector[1us] = 5us; //~ ERROR cannot borrow
|
||||
vector[1] = 5; //~ ERROR cannot borrow
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn separate_arms() {
|
||||
// fact no outstanding loan of x!
|
||||
x = Some(0);
|
||||
}
|
||||
Some(ref _i) => {
|
||||
Some(ref __isize) => {
|
||||
x = Some(1); //~ ERROR cannot assign
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#![allow(dead_code)]
|
||||
fn main() {
|
||||
// Original borrow ends at end of function
|
||||
let mut x = 1us;
|
||||
let mut x = 1_usize;
|
||||
let y = &mut x;
|
||||
let z = &x; //~ ERROR cannot borrow
|
||||
}
|
||||
@ -21,7 +21,7 @@ fn foo() {
|
||||
match true {
|
||||
true => {
|
||||
// Original borrow ends at end of match arm
|
||||
let mut x = 1us;
|
||||
let mut x = 1_usize;
|
||||
let y = &x;
|
||||
let z = &mut x; //~ ERROR cannot borrow
|
||||
}
|
||||
@ -33,7 +33,7 @@ fn foo() {
|
||||
fn bar() {
|
||||
// Original borrow ends at end of closure
|
||||
|| {
|
||||
let mut x = 1us;
|
||||
let mut x = 1_usize;
|
||||
let y = &mut x;
|
||||
let z = &mut x; //~ ERROR cannot borrow
|
||||
};
|
||||
|
@ -27,5 +27,5 @@ fn cat(in_x : usize) -> cat {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let nyan = cat(0us);
|
||||
let nyan = cat(0_usize);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ impl cat {
|
||||
fn sleep(&self) { loop{} }
|
||||
fn meow(&self) {
|
||||
println!("Meow");
|
||||
meows += 1us; //~ ERROR unresolved name
|
||||
meows += 1_usize; //~ ERROR unresolved name
|
||||
sleep(); //~ ERROR unresolved name
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const A: usize = { 1us; 2 };
|
||||
const A: usize = { 1_usize; 2 };
|
||||
//~^ ERROR: blocks in constants are limited to items and tail expressions
|
||||
|
||||
const B: usize = { { } 2 };
|
||||
@ -19,7 +19,7 @@ macro_rules! foo {
|
||||
}
|
||||
const C: usize = { foo!(); 2 };
|
||||
|
||||
const D: usize = { let x = 4us; 2 };
|
||||
const D: usize = { let x = 4_usize; 2 };
|
||||
//~^ ERROR: blocks in constants are limited to items and tail expressions
|
||||
|
||||
pub fn main() {
|
||||
|
@ -22,10 +22,10 @@ impl S { }
|
||||
impl T for S { }
|
||||
|
||||
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
|
||||
static s: usize = 0us;
|
||||
static s: usize = 0_usize;
|
||||
|
||||
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
|
||||
const c: usize = 0us;
|
||||
const c: usize = 0_usize;
|
||||
|
||||
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
|
||||
mod m { }
|
||||
|
@ -8,7 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused_variables)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
mod u {
|
||||
type X = uint; //~ WARN the `uint` type is deprecated
|
||||
@ -16,7 +17,8 @@ mod u {
|
||||
x: uint //~ WARN the `uint` type is deprecated
|
||||
}
|
||||
fn bar(x: uint) { //~ WARN the `uint` type is deprecated
|
||||
1u; //~ WARN the `u` suffix on integers is deprecated
|
||||
1_u; //~ WARN the `u` and `us` suffixes on integers are deprecated
|
||||
1_us; //~ WARN the `u` and `us` suffixes on integers are deprecated
|
||||
}
|
||||
}
|
||||
mod i {
|
||||
@ -25,11 +27,11 @@ mod i {
|
||||
x: int //~ WARN the `int` type is deprecated
|
||||
}
|
||||
fn bar(x: int) { //~ WARN the `int` type is deprecated
|
||||
1i; //~ WARN the `i` suffix on integers is deprecated
|
||||
1_i; //~ WARN the `i` and `is` suffixes on integers are deprecated
|
||||
1_is; //~ WARN the `i` and `is` suffixes on integers are deprecated
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// make compilation fail, after feature gating
|
||||
let () = 1u8; //~ ERROR
|
||||
#[rustc_error]
|
||||
fn main() { //~ ERROR compilation successful
|
||||
}
|
||||
|
@ -13,13 +13,13 @@
|
||||
mod circ1 {
|
||||
pub use circ2::f2;
|
||||
pub fn f1() { println!("f1"); }
|
||||
pub fn common() -> usize { return 0us; }
|
||||
pub fn common() -> usize { return 0_usize; }
|
||||
}
|
||||
|
||||
mod circ2 {
|
||||
pub use circ1::f1;
|
||||
pub fn f2() { println!("f2"); }
|
||||
pub fn common() -> usize { return 1us; }
|
||||
pub fn common() -> usize { return 1_usize; }
|
||||
}
|
||||
|
||||
mod test {
|
||||
|
@ -9,5 +9,5 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
(return)[0us]; //~ ERROR the type of this value must be known in this context
|
||||
(return)[0_usize]; //~ ERROR the type of this value must be known in this context
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ impl<T:Clone> to_opt for Option<T> {
|
||||
}
|
||||
|
||||
fn function<T:to_opt + Clone>(counter: usize, t: T) {
|
||||
if counter > 0us {
|
||||
function(counter - 1us, t.to_option());
|
||||
if counter > 0_usize {
|
||||
function(counter - 1_usize, t.to_option());
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
function(22us, 22us);
|
||||
function(22_usize, 22_usize);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user