}
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 }
}
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;
}
}
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;
}
}
let mut i = *self;
while i < v {
f(i);
- i += 1u;
+ i += 1_usize;
}
}
}
#[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;
}
}
// 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;
}
}
#![crate_type = "dylib"]
#[macro_export]
macro_rules! reexported {
- () => ( 3u )
+ () => ( 3_usize )
}
};
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)) => {
#[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()
}
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;
}
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
}
}
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);
}
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 {
}
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
}
fn main() {
#[attr] //~ ERROR expected item
- let _i = 0;
+ let __isize = 0;
}
// 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(5); }
// 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(5); }
// 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 {
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
}
}
}
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 {
// 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();
}
*/
}
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 {
}
fn deref_imm_method(x: Rc<Point>) {
- let _i = x.get();
+ let __isize = x.get();
}
fn deref_mut_method1(x: Rc<Point>) {
}
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 {
}
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 {
// fact no outstanding loan of x!
x = Some(0);
}
- Some(ref _i) => {
+ Some(ref __isize) => {
x = Some(1); //~ ERROR cannot assign
}
}
#![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
}
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
}
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
};
}
fn main() {
- let nyan = cat(0us);
+ let nyan = cat(0_usize);
}
fn sleep(&self) { loop{} }
fn meow(&self) {
println!("Meow");
- meows += 1us; //~ ERROR unresolved name
+ meows += 1_usize; //~ ERROR unresolved name
sleep(); //~ ERROR unresolved name
}
// 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 };
}
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() {
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 { }
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_usize;
}
}
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_isize;
}
}
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 {
// 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
}
}
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);
}
pub fn main() {
let v: Vec<isize> = vec!(0, 1, 2, 3, 4, 5);
let s: String = "abcdef".to_string();
- v[3us];
+ v[3_usize];
v[3];
v[3u8]; //~ERROR the trait `core::ops::Index<u8>` is not implemented
//~^ ERROR the trait `core::ops::Index<u8>` is not implemented
//~^ ERROR the trait `core::ops::Index<u32>` is not implemented
v[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented
//~^ ERROR the trait `core::ops::Index<i32>` is not implemented
- s.as_bytes()[3us];
+ s.as_bytes()[3_usize];
s.as_bytes()[3];
s.as_bytes()[3u8]; //~ERROR the trait `core::ops::Index<u8>` is not implemented
//~^ERROR the trait `core::ops::Index<u8>` is not implemented
// The expected arm type `Option<T>` has one type parameter, while
// the actual arm `Result<T, E>` has two. typeck should not be
// tricked into looking up a non-existing second type parameter.
- let _x: usize = match Some(1us) {
+ let _x: usize = match Some(1_usize) {
Ok(u) => u,
//~^ ERROR mismatched types
//~| expected `core::option::Option<usize>`
}
fn main() {
- let x = 1us;
+ let x = 1_usize;
let y: Foo;
// `x { ... }` should not be interpreted as a struct literal here
#![feature(box_syntax)]
fn main() {
- let _foo = &[1us, 2] as [usize];
+ let _foo = &[1_usize, 2] as [usize];
//~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]`
//~^^ HELP consider using an implicit coercion to `&[usize]` instead
- let _bar = box 1us as std::fmt::Show;
+ let _bar = box 1_usize as std::fmt::Show;
//~^ ERROR cast to unsized type: `Box<usize>` as `core::fmt::Show`
//~^^ HELP did you mean `Box<core::fmt::Show>`?
- let _baz = 1us as std::fmt::Show;
+ let _baz = 1_usize as std::fmt::Show;
//~^ ERROR cast to unsized type: `usize` as `core::fmt::Show`
//~^^ HELP consider using a box or reference as appropriate
- let _quux = [1us, 2] as [usize];
+ let _quux = [1_usize, 2] as [usize];
//~^ ERROR cast to unsized type: `[usize; 2]` as `[usize]`
//~^^ HELP consider using a box or reference as appropriate
}
#![feature(box_syntax)]
fn main() {
- (|| box *[0us].as_slice())();
+ (|| box *[0_usize].as_slice())();
//~^ ERROR cannot move out of borrowed content
//~^^ ERROR cannot move a value of type [usize]
}
const A3: usize = 1;
fn main() {
- match 1us {
+ match 1_usize {
A1 => {} //~ ERROR: static variables cannot be referenced in a pattern
A2 => {} //~ ERROR: static variables cannot be referenced in a pattern
A3 => {}
#[cfg(target_pointer_width = "64")]
fn main() {
- let n = 0us;
- let a = box [&n; 0xF000000000000000us];
- println!("{}", a[0xFFFFFFu]);
+ let n = 0_usize;
+ let a = box [&n; 0xF000000000000000_usize];
+ println!("{}", a[0xFFFFFF_usize]);
}
#[cfg(target_pointer_width = "32")]
fn main() {
- let n = 0us;
- let a = box [&n; 0xFFFFFFFFu];
- println!("{}", a[0xFFFFFFu]);
+ let n = 0_usize;
+ let a = box [&n; 0xFFFFFFFF_usize];
+ println!("{}", a[0xFFFFFF_usize]);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub static X: usize = 1us;
+pub static X: usize = 1_usize;
fn main() {
- match 1us {
+ match 1_usize {
self::X => { },
//~^ ERROR static variables cannot be referenced in a pattern, use a `const` instead
_ => { },
// error-pattern:no valid digits found for number
fn main() {
- log(error, 0bu);
+ log(error, 0b_usize);
}
AbstractRenderer
//~^ ERROR: the trait `core::marker::Sized` is not implemented
{
- match 0us {
+ match 0_usize {
_ => unimplemented!()
}
}
}
fn main() {
- let f = Foo::Variant(42us); //~ ERROR uses it like a function
+ let f = Foo::Variant(42_usize); //~ ERROR uses it like a function
}
}
fn main() {
- let s = &mut 1us;
+ let s = &mut 1_usize;
MyPtr(s).poke(s);
//~^ ERROR cannot borrow `*s` as mutable more than once at a time
use std::cell::RefCell;
fn main() {
- let mut y = 1us;
+ let mut y = 1_usize;
let c = RefCell::new(vec![]);
c.push(box || y = 0);
c.push(box || y = 0);
}
fn ufcs() {
- let mut y = 1us;
+ let mut y = 1_usize;
let c = RefCell::new(vec![]);
Push::push(&c, box || y = 0);
fn foo<T>(&self, _: &T) {}
}
-#[inline(never)] fn foo(b: &Bar) { b.foo(&0us) }
+#[inline(never)] fn foo(b: &Bar) { b.foo(&0_usize) }
fn main() {
let mut thing = Thing;
fn fail_len(v: Vec<isize> ) -> usize {
let mut i = 3;
panic!();
- for x in &v { i += 1us; }
+ for x in &v { i += 1_usize; }
//~^ ERROR: unreachable statement
return i;
}
fn bar(int_param: usize) {}
fn main() {
- let foo: [u8; 4] = [1u8; 4us];
+ let foo: [u8; 4] = [1u8; 4_usize];
bar(foo);
//~^ ERROR mismatched types
//~| expected `usize`
// except according to those terms.
fn main() {
- let _i = 18446744073709551616; // 2^64
+ let __isize = 18446744073709551616; // 2^64
//~^ ERROR int literal is too large
}
// except according to those terms.
fn main() {
- let _i = 0xff_ffff_ffff_ffff_ffff_is;
+ let __isize = 0xff_ffff_ffff_ffff_ffff__isize;
//~^ ERROR int literal is too large
}
impl CtxtFn for usize {
fn f8(self, i: usize) -> usize {
- i * 4us
+ i * 4_usize
}
fn f9(i: usize) -> usize {
- i * 4us
+ i * 4_usize
}
}
impl OtherTrait for usize {
fn f9(i: usize) -> usize {
- i * 8us
+ i * 8_usize
}
}
//~^ ERROR attempted to divide with overflow in a constant expression
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow in a constant expression
- assert!(thread::spawn(move|| { 1is / 0; }).join().is_err());
+ assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero in a constant expression
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero in a constant expression
//~^ ERROR attempted remainder with overflow in a constant expression
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
//~^ ERROR attempted remainder with overflow in a constant expression
- assert!(thread::spawn(move|| { 1is % 0; }).join().is_err());
+ assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempted remainder with a divisor of zero in a constant expression
// except according to those terms.
pub extern
- "invalid-abi" //~ ERROR illegal ABI
+ "invalid-ab_isize" //~ ERROR illegal ABI
fn foo() {}
fn main() {}
fn bar<F:FnOnce() + Send>(_: F) { }
fn main() {
- let x = Rc::new(3us);
+ let x = Rc::new(3_usize);
bar(move|| foo(x));
//~^ ERROR `core::marker::Send` is not implemented
}
fn main() {
field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy });
field_match_in_patterns(XYZ::Z);
- field_match_in_let(Bar { x: 42us, b: true, _guard: () });
+ field_match_in_let(Bar { x: 42_usize, b: true, _guard: () });
let _ = Baz { x: 0 };
}
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
- let n = 1is << std::isize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
- let n = 1us << std::usize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
+ let n = 1_isize << std::isize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
+ let n = 1_usize << std::usize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
}
#![allow(dead_code)]
#![feature(custom_attribute)]
-#[abi="stdcall"] extern {} //~ ERROR unused attribute
+#[ab_isize="stdcall"] extern {} //~ ERROR unused attribute
#[fixed_stack_segment] fn f() {} //~ ERROR unused attribute
fn main() { }
fn foo() {
- let mut i = 100us;
+ let mut i = 100_usize;
while i >= 0 { //~ ERROR comparison is useless due to type limits
i -= 1;
}
}
fn quy() {
- let i = -23us; //~ WARNING negation of unsigned int literal may be unintentional
+ let i = -23_usize; //~ WARNING negation of unsigned int literal may be unintentional
//~^ WARNING unused variable
}
fn quz() {
- let i = 23us;
+ let i = 23_usize;
let j = -i; //~ WARNING negation of unsigned int variable may be unintentional
//~^ WARNING unused variable
}
extern crate macro_non_reexport_2;
fn main() {
- assert_eq!(reexported!(), 3us); //~ ERROR macro undefined
+ assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined
}
extern crate macro_reexport_1;
fn main() {
- assert_eq!(reexported!(), 3us); //~ ERROR macro undefined
+ assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined
}
fn main() {
match 1 {
- 1...2us => 1, //~ ERROR mismatched types in range
+ 1...2_usize => 1, //~ ERROR mismatched types in range
_ => 2,
};
}
fn me(&self) -> usize;
}
impl me2 for usize { fn me(&self) -> usize { *self } }
-fn main() { 1us.me(); } //~ ERROR E0034
+fn main() { 1_usize.me(); } //~ ERROR E0034
impl Bar for usize {}
fn main() {
- 1us.method(); //~ ERROR E0034
+ 1_usize.method(); //~ ERROR E0034
}
}
fn main() {
- let nyan : cat = cat(52us, 99);
+ let nyan : cat = cat(52_usize, 99);
nyan.eat();
}
}
fn main() {
- let nyan : cat = cat(52us, 99);
+ let nyan : cat = cat(52_usize, 99);
nyan.how_hungry = 0; //~ ERROR cannot assign
}
//~^^^ HELP `no_method_suggested_traits::foo::PubPub`
// should have no help:
- 1us.method3(); //~ ERROR does not implement
- std::rc::Rc::new(&mut Box::new(&1us)).method3(); //~ ERROR does not implement
+ 1_usize.method3(); //~ ERROR does not implement
+ std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR does not implement
no_method_suggested_traits::Foo.method3(); //~ ERROR does not implement
std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
//~^ ERROR does not implement
Foo { first: true, second: None } => (),
Foo { first: true, second: Some(_) } => (),
Foo { first: false, second: None } => (),
- Foo { first: false, second: Some([1us, 2us, 3us, 4us]) } => ()
+ Foo { first: false, second: Some([1_usize, 2_usize, 3_usize, 4_usize]) } => ()
}
}
enum blah { a(isize, isize, usize), b(isize, isize), }
-fn main() { match blah::a(1, 1, 2us) { blah::a(_, x, y) | blah::b(x, y) => { } } }
+fn main() { match blah::a(1, 1, 2_usize) { blah::a(_, x, y) | blah::b(x, y) => { } } }
}
fn main() {
- let nyan : kitties::cat = kitties::cat(52us, 99);
+ let nyan : kitties::cat = kitties::cat(52_usize, 99);
nyan.nap();
}
use cci_class::kitties::cat;
fn main() {
- let nyan : cat = cat(52us, 99);
- assert!((nyan.meows == 52us));
+ let nyan : cat = cat(52_usize, 99);
+ assert!((nyan.meows == 52_usize));
//~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private
}
impl dog {
pub fn chase_cat(&mut self) {
let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer
- *p += 1us;
+ *p += 1_usize;
}
pub fn chase_cat_2(&mut self) {
let p: &mut usize = &mut self.cats_chased;
- *p += 1us;
+ *p += 1_usize;
}
}
fn dog() -> dog {
dog {
- cats_chased: 0us
+ cats_chased: 0_usize
}
}
pub fn chase_cat(&mut self) {
let _f = || {
let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
- *p = 3us;
+ *p = 3_usize;
};
}
}
}
fn build() {
- let x = ast::num(3us);
- let y = ast::num(4us);
+ let x = ast::num(3_usize);
+ let y = ast::num(4_usize);
let z = ast::add(&x, &y);
compute(&z);
}
marker: marker::InvariantLifetime<'a>
}
-fn to_same_lifetime<'r>(bi: invariant<'r>) {
- let bj: invariant<'r> = bi;
+fn to_same_lifetime<'r>(b_isize: invariant<'r>) {
+ let bj: invariant<'r> = b_isize;
}
-fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
- bi //~ ERROR mismatched types
+fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> {
+ b_isize //~ ERROR mismatched types
}
fn main() {
f: Box<FnOnce(&mut &'a isize) + 'static>,
}
-fn to_same_lifetime<'r>(bi: invariant<'r>) {
- let bj: invariant<'r> = bi;
+fn to_same_lifetime<'r>(b_isize: invariant<'r>) {
+ let bj: invariant<'r> = b_isize;
}
-fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
- bi //~ ERROR mismatched types
+fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> {
+ b_isize //~ ERROR mismatched types
}
fn main() {
f: Box<for<'b> FnOnce() -> &'b mut &'a isize + 'static>,
}
-fn to_same_lifetime<'r>(bi: Invariant<'r>) {
- let bj: Invariant<'r> = bi;
+fn to_same_lifetime<'r>(b_isize: Invariant<'r>) {
+ let bj: Invariant<'r> = b_isize;
}
-fn to_longer_lifetime<'r>(bi: Invariant<'r>) -> Invariant<'static> {
- bi //~ ERROR mismatched types
+fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> {
+ b_isize //~ ERROR mismatched types
}
fn main() {
fn main() {
// Unboxed closure case
{
- let mut x = 0us;
+ let mut x = 0_usize;
let mut f = || &mut x; //~ ERROR cannot infer
let x = f();
let y = f();
}
fn main() {
- let ctxt = ctxt { v: 22us };
+ let ctxt = ctxt { v: 22_usize };
let hc = has_ctxt { c: &ctxt };
- assert_eq!(get_v(box hc as Box<get_ctxt>), 22us);
+ assert_eq!(get_v(box hc as Box<get_ctxt>), 22_usize);
}
//~| expected usize
//~| found &-ptr
//~| ERROR expected positive integer for repeat count, found string
- let f = [0; -4is];
+ let f = [0; -4_isize];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `isize`
//~| expected usize
//~| found isize
//~| ERROR expected positive integer for repeat count, found negative integer
- let f = [0us; -1is];
+ let f = [0_usize; -1_isize];
//~^ ERROR mismatched types
//~| expected `usize`
//~| found `isize`
// just to ensure that this test fails to compile; when shadowed
// lifetimes become either an error or a proper lint, this will
// not be needed.
- let x: isize = 3us; //~ ERROR mismatched types
+ let x: isize = 3_usize; //~ ERROR mismatched types
}
//~| found `Bar`
//~| expected struct `Foo`
//~| found struct `Bar`
- let f_i = Foo { a: 2, ..4 }; //~ ERROR mismatched types
+ let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types
//~| expected `Foo`
//~| found `_`
//~| expected struct `Foo`
fn f() -> isize { return g(); }
-fn g() -> usize { return 0us; }
+fn g() -> usize { return 0_usize; }
fn main() { let y = f(); }
fn main() {
// By-ref cases
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn(|| drop(x)); //~ ERROR cannot move
}
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move
}
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn_once(|| drop(x)); // OK -- FnOnce
}
// By-value cases
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn(move || drop(x)); //~ ERROR cannot move
}
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move
}
{
- let x = box 0us;
+ let x = box 0_usize;
let f = to_fn_once(move || drop(x)); // this one is ok
}
}
fn set(x: &mut usize) { *x = 0; }
fn main() {
- let x = 0us;
+ let x = 0_usize;
move || x = 1; //~ ERROR cannot assign
move || set(&mut x); //~ ERROR cannot borrow
move || x = 1; //~ ERROR cannot assign
// reference cannot escape the region of that variable.
fn main() {
let _f = {
- let x = 0us;
+ let x = 0_usize;
|| x //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
};
}
// cause borrow conflicts.
fn main() {
- let mut x = 0us;
+ let mut x = 0_usize;
let f = || x += 1;
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
}
pub fn main() {
let mut f = |x: isize, y: isize| -> isize { x + y };
- let z = f(1us, 2); //~ ERROR mismatched types
+ let z = f(1_usize, 2); //~ ERROR mismatched types
println!("{}", z);
}
use std::rc::Rc;
-fn f<T:Send>(_i: T) {
+fn f<T:Send>(__isize: T) {
}
fn main() {
}
}
-fn f<T>(_i: Vec<T> , _j: Vec<T> ) {
+fn f<T>(__isize: Vec<T> , _j: Vec<T> ) {
}
fn clone<T: Clone>(t: &T) -> T { t.clone() }
enum foo { a(Box<foo>, isize), b(usize), }
-fn main() { match foo::b(1us) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } }
+fn main() { match foo::b(1_usize) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } }
}
fn call_it<B:TraitB>(b: B) -> isize {
- let y = 4us;
+ let y = 4_usize;
b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented
}
// error-pattern:quux
fn my_err(s: String) -> ! { println!("{}", s); panic!("quux"); }
-fn main() { 3u == my_err("bye".to_string()); }
+fn main() { 3_usize == my_err("bye".to_string()); }
use std::uint;
fn main() {
- let x = vec!(1u,2u,3u);
+ let x = vec!(1_usize,2_usize,3_usize);
// This should cause a bounds-check panic, but may not if we do our
// bounds checking by comparing a scaled index value to the vector's
// length (in bytes), because the scaling of the index will cause it to
// wrap around to a small number.
- let idx = uint::MAX & !(uint::MAX >> 1u);
+ let idx = uint::MAX & !(uint::MAX >> 1_usize);
println!("ov2 idx = 0x%x", idx);
// This should panic.
#[cfg(target_arch="x86")]
fn main() {
- let x = vec!(1u,2u,3u);
+ let x = vec!(1_usize,2_usize,3_usize);
// This should cause a bounds-check panic, but may not if we do our
// bounds checking by truncating the index value to the size of the
// This test is only meaningful on 32-bit hosts.
- let idx = u64::MAX & !(u64::MAX >> 1u);
+ let idx = u64::MAX & !(u64::MAX >> 1_usize);
println!("ov3 idx = 0x%8.8x%8.8x",
(idx >> 32) as uint,
idx as uint);
#[cfg(any(target_arch="x86_64", target_arch = "aarch64"))]
fn main() {
// This version just panics anyways, for symmetry on 64-bit hosts.
- let x = vec!(1u,2u,3u);
+ let x = vec!(1_usize,2_usize,3_usize);
error!("ov3 0x%x", x[200]);
}
// address of the 0th cell in the array (even though the index is
// huge).
- let x = vec!(1u,2u,3u);
+ let x = vec!(1_usize,2_usize,3_usize);
let base = x.as_ptr() as uint;
let idx = base / mem::size_of::<uint>();
// error-pattern:test
fn main() {
- let _i: int = panic!("test");
+ let __isize: int = panic!("test");
}
}
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
- if data == 1u {
+ if data == 1_usize {
data
} else {
- count(data - 1u) + count(data - 1u)
+ count(data - 1_usize) + count(data - 1_usize)
}
}
}
fn main() {
- for _ in 0..10u {
+ for _ in 0..10_usize {
task::spawn(move|| {
- let result = count(5u);
+ let result = count(5_usize);
println!("result = %?", result);
panic!();
});
// error-pattern:moop
-fn main() { for _ in 0u..10u { panic!("moop"); } }
+fn main() { for _ in 0_usize..10_usize { panic!("moop"); } }
// error-pattern:Number is odd
fn even(x: uint) -> bool {
- if x < 2u {
+ if x < 2_usize {
return false;
- } else if x == 2u { return true; } else { return even(x - 2u); }
+ } else if x == 2_usize { return true; } else { return even(x - 2_usize); }
}
fn foo(x: uint) {
}
}
-fn main() { foo(3u); }
+fn main() { foo(3_usize); }
digraph block {
N0[label="entry"];
N1[label="exit"];
- N2[label="expr 2us"];
- N3[label="expr 0us"];
- N4[label="expr 20us"];
- N5[label="expr [2us, 0us, 20us]"];
+ N2[label="expr 2usize"];
+ N3[label="expr 0usize"];
+ N4[label="expr 20usize"];
+ N5[label="expr [2usize, 0usize, 20usize]"];
N6[label="local v"];
- N7[label="stmt let v = [2us, 0us, 20us];"];
+ N7[label="stmt let v = [2usize, 0usize, 20usize];"];
N8[label="expr v"];
- N9[label="expr 20us"];
- N10[label="expr v[20us]"];
- N11[label="stmt v[20us];"];
- N12[label="block { let v = [2us, 0us, 20us]; v[20us]; }"];
+ N9[label="expr 20usize"];
+ N10[label="expr v[20usize]"];
+ N11[label="stmt v[20usize];"];
+ N12[label="block { let v = [2usize, 0usize, 20usize]; v[20usize]; }"];
N0 -> N2;
N2 -> N3;
N3 -> N4;
// except according to those terms.
pub fn expr_index_20() {
- let v = [2us, 0us, 20us];
- v[20us];
+ let v = [2_usize, 0_usize, 20_usize];
+ v[20_usize];
}
fn foo(x: &Float) {}
let _: Option<u8> = from_i32(45);
- let x = 42us;
+ let x = 42_usize;
myflate::deflate_bytes(&[]);
- let x = (3, 4us);
+ let x = (3, 4_usize);
let y = x.1;
}
pub fn dummy() {
// force the vtable to be created
- let _x = &1u as &Foo;
+ let _x = &1_usize as &Foo;
}
.write_str("mod unicode_input_multiple_files_chars;");
}
- for _ in 0u..100 {
+ for _ in 0..100 {
{
let randoms = tmpdir.join("unicode_input_multiple_files_chars.rs");
let mut w = File::create(&randoms).unwrap();
- for _ in 0u..30 {
+ for _ in 0..30 {
let _ = w.write_char(random_char());
}
}
let tmpdir = Path::new(&args[2]);
let main_file = tmpdir.join("span_main.rs");
- for _ in 0u..100 {
- let n = thread_rng().gen_range(3u, 20);
+ for _ in 0..100 {
+ let n = thread_rng().gen_range(3, 20);
{
let _ = write!(&mut File::create(&main_file).unwrap(),
struct RawT {struct_: sty, cname: Option<String>, hash: uint}
fn mk_raw_ty(st: sty, cname: Option<String>) -> RawT {
- return RawT {struct_: st, cname: cname, hash: 0u};
+ return RawT {struct_: st, cname: cname, hash: 0_usize};
}
pub fn main() { mk_raw_ty(sty::ty_nil, None::<String>); }
unsafe fn next_power_of_2(n: u32) -> u32 {
let mut tmp = n;
asm!("dec $0" : "+rm"(tmp) :: "cc");
- let mut shift = 1u;
+ let mut shift = 1_usize;
while shift <= 16 {
asm!(
"shr %cl, $2
"shl $2, $1
add $3, $1
mov $1, $0"
- : "=r"(x), "+r"(y) : "i"(3u), "ir"(7u) : "cc"
+ : "=r"(x), "+r"(y) : "i"(3_usize), "ir"(7_usize) : "cc"
);
}
assert_eq!(x, 47);
let x: int;
unsafe {
// Treat the output as initialization.
- asm!("mov $1, $0" : "=r"(x) : "r"(5u));
+ asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
}
assert_eq!(x, 5);
fn main() {
let x = get(22);
- assert_eq!(22u, x);
+ assert_eq!(22_usize, x);
}
pub fn main() {
let a = 42;
- assert!(foo2(a) == 42u);
+ assert!(foo2(a) == 42_usize);
let a = Bar;
assert!(foo2(a) == 43);
}
pub fn main() {
- let z: uint = bar(2, 4u);
+ let z: uint = bar(2, 4_usize);
}
enum CLike { A, B, C }
pub fn main() {
- let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
+ let a = &Plus(@Minus(@Val(3_usize), @Val(10_usize)), @Plus(@Val(22_usize), @Val(5_usize)));
test_rbml(a);
- let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
+ let a = &Spanned {lo: 0_usize, hi: 5_usize, node: 22_usize};
test_rbml(a);
- let a = &Point {x: 3u, y: 5u};
+ let a = &Point {x: 3_usize, y: 5_usize};
test_rbml(a);
- let a = &Top(22u);
+ let a = &Top(22_usize);
test_rbml(a);
- let a = &Bottom(222u);
+ let a = &Bottom(222_usize);
test_rbml(a);
let a = &A;
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2u }
+ fn double(self: Box<uint>) -> uint { *self * 2_usize }
}
pub fn main() {
- let x = box() (box 3u as Box<double>);
- assert_eq!(x.double(), 6u);
+ let x = box() (box 3_usize as Box<double>);
+ assert_eq!(x.double(), 6_usize);
}
}
impl double for Box<uint> {
- fn double(self) -> uint { *self * 2u }
+ fn double(self) -> uint { *self * 2_usize }
}
pub fn main() {
- let x = box 3u;
- assert_eq!(x.double(), 6u);
+ let x = box 3_usize;
+ assert_eq!(x.double(), 6_usize);
}
}
impl double for Box<uint> {
- fn double(self: Box<Box<uint>>) -> uint { **self * 2u }
+ fn double(self: Box<Box<uint>>) -> uint { **self * 2_usize }
}
pub fn main() {
- let x = box box box box box 3u;
- assert_eq!(x.double(), 6u);
+ let x = box box box box box 3_usize;
+ assert_eq!(x.double(), 6_usize);
}
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2u }
+ fn double(self: Box<uint>) -> uint { *self * 2_usize }
}
pub fn main() {
- let x = box box 3u;
- assert_eq!(x.double(), 6u);
+ let x = box box 3_usize;
+ assert_eq!(x.double(), 6_usize);
}
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2u }
+ fn double(self: Box<uint>) -> uint { *self * 2_usize }
}
pub fn main() {
- let x = box 3u;
- assert_eq!(x.double(), 6u);
+ let x = box 3_usize;
+ assert_eq!(x.double(), 6_usize);
}
}
pub fn main() {
- let x = box 3u;
+ let x = box 3_usize;
assert_eq!(x.foo(), "box 3".to_string());
}
fn test_ptr() {
unsafe {
- let p1: *const u8 = ::std::mem::transmute(0u);
- let p2: *const u8 = ::std::mem::transmute(0u);
- let p3: *const u8 = ::std::mem::transmute(1u);
+ let p1: *const u8 = ::std::mem::transmute(0_usize);
+ let p2: *const u8 = ::std::mem::transmute(0_usize);
+ let p3: *const u8 = ::std::mem::transmute(1_usize);
assert_eq!(p1, p2);
assert!(p1 != p3);
#[cfg(any(target_arch = "x86", target_arch = "arm"))]
fn target() {
- assert_eq!(-1000 as uint >> 3u, 536870787u);
+ assert_eq!(-1000 as uint >> 3_usize, 536870787_usize);
}
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
fn target() {
- assert_eq!(-1000 as uint >> 3u, 2305843009213693827u);
+ assert_eq!(-1000 as uint >> 3_usize, 2305843009213693827_usize);
}
fn general() {
println!("{}", b);
assert_eq!(b, 1);
assert_eq!(a, 2);
- assert_eq!(!0xf0i & 0xff, 0xf);
- assert_eq!(0xf0i | 0xf, 0xff);
- assert_eq!(0xfi << 4, 0xf0);
- assert_eq!(0xf0i >> 4, 0xf);
+ assert_eq!(!0xf0_isize & 0xff, 0xf);
+ assert_eq!(0xf0_isize | 0xf, 0xff);
+ assert_eq!(0xf_isize << 4, 0xf0);
+ assert_eq!(0xf0_isize >> 4, 0xf);
assert_eq!(-16 >> 2, -4);
- assert_eq!(0b1010_1010i | 0b0101_0101, 0xff);
+ assert_eq!(0b1010_1010_isize | 0b0101_0101, 0xff);
}
pub fn main() {
}
pub fn main() {
- let x = asBlock(|| 22u);
- assert_eq!(x, 22u);
+ let x = asBlock(|| 22_usize);
+ assert_eq!(x, 22_usize);
}
fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&int) -> bool {
let l = x.values.len();
- (0u..l).all(|i| f(&x.values[i]))
+ (0_usize..l).all(|i| f(&x.values[i]))
}
pub fn main() {
let buf = vec!(97u8, 98, 99, 100);
assert_eq!(match &buf[0..3] {
- b"def" => 1u,
- b"abc" => 2u,
- _ => 3u
+ b"def" => 1_usize,
+ b"abc" => 2_usize,
+ _ => 3_usize
}, 2);
let expected: &[_] = &[97u8, 92u8, 110u8];
}
fn main() {
- let mut sum = 0u;
- let elems = [ 1u, 2, 3, 4, 5 ];
+ let mut sum = 0_usize;
+ let elems = [ 1_usize, 2, 3, 4, 5 ];
each(&elems, |val| sum += *val);
assert_eq!(sum, 15);
}
}
fn main() {
- let mut sum = 0u;
- let elems = [ 1u, 2, 3, 4, 5 ];
+ let mut sum = 0_usize;
+ let elems = [ 1_usize, 2, 3, 4, 5 ];
each(&elems, |val: &uint| sum += *val);
assert_eq!(sum, 15);
}
use cci_borrow_lib::foo;
pub fn main() {
- let p = box 22u;
+ let p = box 22_usize;
let r = foo(&*p);
println!("r={}", r);
- assert_eq!(r, 22u);
+ assert_eq!(r, 22_usize);
}
//let bt0 = sys::frame_address();
//println!("%?", bt0);
- 3u.to(10u, |i| {
+ 3_usize.to(10_usize, |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
// actually working.
//let bt0 = sys::frame_address();
//println!("%?", bt0);
- iter(vec!(1u, 2u, 3u), |i| {
+ iter(vec!(1_usize, 2_usize, 3_usize), |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
}
pub fn main() {
- let nyan: Box<ToString> = box cat(0u, 2, "nyan".to_string()) as Box<ToString>;
+ let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>;
print_out(nyan, "nyan".to_string());
}
impl dog {
fn bark(&mut self) -> int {
println!("Woof {} {}", self.barks, self.volume);
- self.barks += 1u;
- if self.barks % 3u == 0u {
+ self.barks += 1_usize;
+ if self.barks % 3_usize == 0_usize {
self.volume += 1;
}
- if self.barks % 10u == 0u {
+ if self.barks % 10_usize == 0_usize {
self.volume -= 2;
}
println!("Grrr {} {}", self.barks, self.volume);
fn dog() -> dog {
dog {
volume: 0,
- barks: 0u
+ barks: 0_usize
}
}
impl cat {
fn meow(&mut self) -> uint {
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;
}
self.meows
fn annoy_neighbors(critter: &mut noisy) {
- for _i in 0u..10 { critter.speak(); }
+ for _i in 0_usize..10 { critter.speak(); }
}
pub fn main() {
- let mut nyan: cat = cat(0u, 2, "nyan".to_string());
+ let mut nyan: cat = cat(0_usize, 2, "nyan".to_string());
let mut whitefang: dog = dog();
annoy_neighbors(&mut nyan);
annoy_neighbors(&mut whitefang);
- assert_eq!(nyan.meow_count(), 10u);
+ assert_eq!(nyan.meow_count(), 10_usize);
assert_eq!(whitefang.volume, 1);
}
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;
}
}
pub fn main() {
- let mut nyan = cat(0u, 2, "nyan".to_string());
+ let mut nyan = cat(0_usize, 2, "nyan".to_string());
let mut nyan: &mut noisy = &mut nyan;
nyan.speak();
}
fn cat(done: extern fn(uint)) -> cat {
cat {
- meows: 0u,
+ meows: 0_usize,
done: done
}
}
pub fn cat(in_name: String) -> cat {
cat {
name: in_name,
- meows: 0u
+ meows: 0_usize
}
}
}
pub fn main() {
let mut nyan: cat<String> = cat::new(0, 2, "nyan".to_string());
- for _ in 1u..5 { nyan.speak(); }
+ for _ in 1_usize..5 { nyan.speak(); }
assert!(*nyan.find(&1).unwrap() == "nyan".to_string());
assert_eq!(nyan.find(&10), None);
let mut spotty: cat<cat_type> = cat::new(2, 57, cat_type::tuxedo);
- for _ in 0u..6 { spotty.speak(); }
+ for _ in 0_usize..6 { spotty.speak(); }
assert_eq!(spotty.len(), 8);
assert!((spotty.contains_key(&2)));
assert_eq!(spotty.get(&3), &cat_type::tuxedo);
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;
}
}
pub fn main() {
- let mut nyan = cat(0u, 2, "nyan".to_string());
+ let mut nyan = cat(0_usize, 2, "nyan".to_string());
nyan.eat();
assert!((!nyan.eat()));
- for _ in 1u..10u { nyan.speak(); };
+ for _ in 1_usize..10_usize { nyan.speak(); };
assert!((nyan.eat()));
}
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;
}
}
}
pub fn main() {
- let mut nyan = cat(0u, 2, "nyan".to_string());
+ let mut nyan = cat(0_usize, 2, "nyan".to_string());
nyan.eat();
assert!((!nyan.eat()));
- for _ in 1u..10u {
+ for _ in 1_usize..10_usize {
make_speak(nyan.clone());
}
}
use cci_class_2::kitties::cat;
pub fn main() {
- let nyan : cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let nyan : cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
use cci_class_3::kitties::cat;
pub fn main() {
- let mut nyan : cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let mut nyan : cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
- assert_eq!(nyan.meow_count(), 53u);
+ assert_eq!(nyan.meow_count(), 53_usize);
}
}
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 }
}
}
pub fn main() {
- let mut nyan: cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let mut nyan: cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
- assert_eq!(nyan.meow_count(), 53u);
+ assert_eq!(nyan.meow_count(), 53_usize);
}
use cci_class_6::kitties::cat;
pub fn main() {
- let mut nyan : cat<char> = cat::<char>(52u, 99, vec!('p'));
- let mut kitty = cat(1000u, 2, vec!("tabby".to_string()));
+ let mut nyan : cat<char> = cat::<char>(52_usize, 99, vec!('p'));
+ let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
- nyan.speak(vec!(1u,2u,3u));
- assert_eq!(nyan.meow_count(), 55u);
+ nyan.speak(vec!(1_usize,2_usize,3_usize));
+ assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
- assert_eq!(kitty.meow_count(), 1004u);
+ assert_eq!(kitty.meow_count(), 1004_usize);
}
}
pub fn main() {
- let mut nyan : cat<int> = cat::<int>(52u, 99, vec!(9));
- let mut kitty = cat(1000u, 2, vec!("tabby".to_string()));
+ let mut nyan : cat<int> = cat::<int>(52_usize, 99, vec!(9));
+ let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1,2,3));
- assert_eq!(nyan.meow_count(), 55u);
+ assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
- assert_eq!(kitty.meow_count(), 1004u);
+ assert_eq!(kitty.meow_count(), 1004_usize);
}
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;
}
}
}
pub fn main() {
- let nyan: Box<ToString> = box cat(0u, 2, "nyan".to_string()) as Box<ToString>;
+ let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>;
print_out(nyan, "nyan".to_string());
}
}
impl<U> cat<U> {
- 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 }
}
pub fn main() {
- let _nyan : cat<int> = cat::<int>(52u, 99);
- // let mut kitty = cat(1000u, 2);
+ let _nyan : cat<int> = cat::<int>(52_usize, 99);
+ // let mut kitty = cat(1000_usize, 2);
}
use cci_class_4::kitties::cat;
pub fn main() {
- let mut nyan = cat(0u, 2, "nyan".to_string());
+ let mut nyan = cat(0_usize, 2, "nyan".to_string());
nyan.eat();
assert!((!nyan.eat()));
- for _ in 1u..10u { nyan.speak(); };
+ for _ in 1_usize..10_usize { nyan.speak(); };
assert!((nyan.eat()));
}
use cci_class::kitties::cat;
pub fn main() {
- let nyan : cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let nyan : cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
}
}
pub fn main() {
- let mut nyan : cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let mut nyan : cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
}
pub fn main() {
- let nyan : cat = cat(52u, 99);
- let kitty = cat(1000u, 2);
+ let nyan : cat = cat(52_usize, 99);
+ let kitty = cat(1000_usize, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
}
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;
}
}
}
pub fn main() {
- let mut nyan = cat(0u, 2, "nyan".to_string());
+ let mut nyan = cat(0_usize, 2, "nyan".to_string());
nyan.eat();
assert!((!nyan.eat()));
- for _ in 1u..10u { nyan.speak(); };
+ for _ in 1_usize..10_usize { nyan.speak(); };
assert!((nyan.eat()));
}
}
pub fn main() {
- let mut the_vec = vec!(1u, 2, 3, 100);
+ let mut the_vec = vec!(1_usize, 2, 3, 100);
assert_eq!(the_vec.clone(), bar(&mut the_vec));
assert_eq!(the_vec.clone(), bip(&the_vec));
}
}
pub fn main() {
- test_eq(0u, 0u);
+ test_eq(0_usize, 0_usize);
let value = MyType { dummy: 256 + 22 };
test_eq(value, value);
assert_eq!(concat!("qux", "quux",).to_string(), "quxquux".to_string());
assert_eq!(
- concat!(1, 2, 3u, 4f32, 4.0, 'a', true),
+ concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true),
"12344.0atrue"
);
assert!(match "12344.0atrue" {
- concat!(1, 2, 3u, 4f32, 4.0, 'a', true) => true,
+ concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true) => true,
_ => false
})
}
foo("hi".to_string());
foo(~[1, 2, 3]);
foo(F{field: 42});
- foo((1, 2u));
+ foo((1, 2_usize));
foo(@1);*/
foo(box 1);
}
fn main() {
use ::std::mem;
- mem::drop(2u);
+ mem::drop(2_usize);
}
// except according to those terms.
fn check_expr() {
- let _: & uint = &1u;
- let _: & & uint = &&1u;
- let _: & & & uint = &&&1u;
- let _: & & & uint = & &&1u;
- let _: & & & & uint = &&&&1u;
- let _: & & & & uint = & &&&1u;
- let _: & & & & & uint = &&&&&1u;
+ let _: & uint = &1_usize;
+ let _: & & uint = &&1_usize;
+ let _: & & & uint = &&&1_usize;
+ let _: & & & uint = & &&1_usize;
+ let _: & & & & uint = &&&&1_usize;
+ let _: & & & & uint = & &&&1_usize;
+ let _: & & & & & uint = &&&&&1_usize;
}
fn check_ty() {
- let _: &uint = & 1u;
- let _: &&uint = & & 1u;
- let _: &&&uint = & & & 1u;
- let _: & &&uint = & & & 1u;
- let _: &&&&uint = & & & & 1u;
- let _: & &&&uint = & & & & 1u;
- let _: &&&&&uint = & & & & & 1u;
+ let _: &uint = & 1_usize;
+ let _: &&uint = & & 1_usize;
+ let _: &&&uint = & & & 1_usize;
+ let _: & &&uint = & & & 1_usize;
+ let _: &&&&uint = & & & & 1_usize;
+ let _: & &&&uint = & & & & 1_usize;
+ let _: &&&&&uint = & & & & & 1_usize;
}
fn check_pat() {
- let &_ = & 1u;
- let &&_ = & & 1u;
- let &&&_ = & & & 1u;
- let & &&_ = & & & 1u;
- let &&&&_ = & & & & 1u;
- let & &&&_ = & & & & 1u;
- let &&&&&_ = & & & & & 1u;
+ let &_ = & 1_usize;
+ let &&_ = & & 1_usize;
+ let &&&_ = & & & 1_usize;
+ let & &&_ = & & & 1_usize;
+ let &&&&_ = & & & & 1_usize;
+ let & &&&_ = & & & & 1_usize;
+ let &&&&&_ = & & & & & 1_usize;
}
pub fn main() {}
let (sender, receiver) = channel();
{
- let v = Foo::NestedVariant(box 42u, SendOnDrop { sender: sender.clone() }, sender);
+ let v = Foo::NestedVariant(box 42_usize, SendOnDrop { sender: sender.clone() }, sender);
}
assert_eq!(receiver.recv().unwrap(), Message::DestructorRan);
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
let (sender, receiver) = channel();
let t = {
thread::spawn(move|| {
- let mut v = Foo::NestedVariant(box 42u, SendOnDrop {
+ let mut v = Foo::NestedVariant(box 42usize, SendOnDrop {
sender: sender.clone()
}, sender.clone());
- v = Foo::NestedVariant(box 42u, SendOnDrop { sender: sender.clone() }, sender.clone());
+ v = Foo::NestedVariant(box 42_usize, SendOnDrop { sender: sender.clone() }, sender.clone());
v = Foo::SimpleVariant(sender.clone());
v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
})
}
pub fn main() {
- (0u..100).map(|_| {
+ (0_usize..100).map(|_| {
Thread::scoped(move|| {
assert_eq!(count(5), 16);
})
}
pub fn main() {
- (0..10u).map(|i| {
+ (0..10_usize).map(|i| {
Thread::scoped(move|| {
let result = count(5);
println!("result = {}", result);
pub fn main() {
let len = strlen("Rust".to_string());
- assert_eq!(len, 4u);
+ assert_eq!(len, 4_usize);
}
#[start]
fn start(_argc: int, _argv: *const *const u8) -> int {
- let s = format!("{}", 1i);
+ let s = format!("{}", 1_isize);
assert_eq!(s, "1".to_string());
let s = format!("test");
assert_eq!(s, "test".to_string());
- let s = format!("{test}", test=3i);
+ let s = format!("{test}", test=3_isize);
assert_eq!(s, "3".to_string());
let s = format!("hello {}", "world");
// except according to those terms.
fn even(x: uint) -> bool {
- if x < 2u {
+ if x < 2_usize {
return false;
- } else if x == 2u { return true; } else { return even(x - 2u); }
+ } else if x == 2_usize { return true; } else { return even(x - 2_usize); }
}
fn foo(x: uint) {
}
}
-pub fn main() { foo(2u); }
+pub fn main() { foo(2_usize); }
let clause: uint;
if let None = Some("test") {
clause = 1;
- } else if 4u > 5 {
+ } else if 4_usize > 5 {
clause = 2;
} else if let Ok(()) = Err::<(),&'static str>("test") {
clause = 3;
} else {
clause = 4;
}
- assert_eq!(clause, 4u);
+ assert_eq!(clause, 4_usize);
if 3 > 4 {
panic!("bad math");
if false {
panic!("wat");
- } else if let a@Foo::Two(_) = Foo::Two(42u) {
+ } else if let a@Foo::Two(_) = Foo::Two(42_usize) {
if let Foo::Two(b) = a {
- assert_eq!(b, 42u);
+ assert_eq!(b, 42_usize);
} else {
panic!("panic in nested if-let");
}
t!(format!("{}", true), "true");
t!(format!("{}", '☃'), "☃");
t!(format!("{}", 10), "10");
- t!(format!("{}", 10u), "10");
+ t!(format!("{}", 10_usize), "10");
t!(format!("{:?}", '☃'), "'\\u{2603}'");
t!(format!("{:?}", 10), "10");
- t!(format!("{:?}", 10u), "10");
+ t!(format!("{:?}", 10_usize), "10");
t!(format!("{:?}", "true"), "\"true\"");
t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
- t!(format!("{:o}", 10u), "12");
- t!(format!("{:x}", 10u), "a");
- t!(format!("{:X}", 10u), "A");
+ t!(format!("{:o}", 10_usize), "12");
+ t!(format!("{:x}", 10_usize), "a");
+ t!(format!("{:X}", 10_usize), "A");
t!(format!("{}", "foo"), "foo");
t!(format!("{}", "foo".to_string()), "foo");
t!(format!("{:p}", 0x1234 as *const isize), "0x1234");
// make sure that format! doesn't cause spurious unused-unsafe warnings when
// it's inside of an outer unsafe block
unsafe {
- let a: isize = ::std::mem::transmute(3u);
+ let a: isize = ::std::mem::transmute(3_usize);
format!("{}", a);
}
// except according to those terms.
pub fn main() {
- let a = 0xBEEFi;
- let b = 0o755i;
- let c = 0b10101i;
- let d = -0xBEEFi;
- let e = -0o755i;
- let f = -0b10101i;
+ let a = 0xBEEF_isize;
+ let b = 0o755_isize;
+ let c = 0b10101_isize;
+ let d = -0xBEEF_isize;
+ let e = -0o755_isize;
+ let f = -0b10101_isize;
assert_eq!(a, 48879);
assert_eq!(b, 493);
#[cfg(target_arch = "x86")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 4u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::min_align_of::<u64>(), 4_usize);
}
}
#[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
}
}
}
#[cfg(target_arch = "x86")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
}
}
#[cfg(target_arch = "x86_64")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
}
}
}
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
}
}
}
fn main() {
// Generate sieve of Eratosthenes for n up to 1e6
- let n = 1000000u;
+ let n = 1000000_usize;
let mut sieve = Bitv::from_elem(n+1, true);
let limit: uint = (n as f32).sqrt() as uint;
for i in 2..limit+1 {
}
fn main() {
- let arr = [(1, 1u), (2, 2), (3, 3)];
+ let arr = [(1, 1_usize), (2, 2), (3, 3)];
let v1: Vec<&_> = arr.iter().collect();
let v2: Vec<_> = arr.iter().map(copy).collect();
foo(loop {
unsafe { libc::exit(0 as libc::c_int); }
});
- 2u + (loop {});
+ 2_usize + (loop {});
}
// except according to those terms.
fn main() {
- match ("", 1u) {
- (_, 42u) => (),
+ match ("", 1_usize) {
+ (_, 42_usize) => (),
("", _) => (),
_ => ()
}
}
fn main() {
- let x = vec!(10u,11u,12u,13u);
+ let x = vec!(10_usize,11_usize,12_usize,13_usize);
let t = third!(x);
- assert_eq!(t,12u);
+ assert_eq!(t,12_usize);
}
use std::iter::AdditiveIterator;
fn main() {
let x: [u64; 3] = [1, 2, 3];
- assert_eq!(6, (0us..3).map(|i| x[i]).sum());
+ assert_eq!(6, (0_usize..3).map(|i| x[i]).sum());
}
}
fn main() {
- let m = Mat::new(vec!(1u, 2, 3, 4, 5, 6), 3);
+ let m = Mat::new(vec!(1_usize, 2, 3, 4, 5, 6), 3);
let r = m.row(1);
assert!(r.index(&2) == &6);
assert!(r[2] == 6);
- assert!(r[2u] == 6u);
+ assert!(r[2_usize] == 6_usize);
assert!(6 == r[2]);
let e = r[2];
// regression test for the model lexer handling the DOTDOTDOT syntax (#15877)
pub fn main() {
- match 5u {
- 1u...5u => {}
+ match 5_usize {
+ 1_usize...5_usize => {}
_ => panic!("should match range"),
}
- match 5u {
- 6u...7u => panic!("shouldn't match range"),
+ match 5_usize {
+ 6_usize...7_usize => panic!("shouldn't match range"),
_ => {}
}
- match 5u {
- 1u => panic!("should match non-first range"),
- 2u...6u => {}
+ match 5_usize {
+ 1_usize => panic!("should match non-first range"),
+ 2_usize...6_usize => {}
_ => panic!("math is broken")
}
match 'c' {
'a'...'z' => {}
_ => panic!("should suppport char ranges")
}
- match -3i {
+ match -3_isize {
-7...5 => {}
_ => panic!("should match signed range")
}
struct Bar<'a>;
impl<'a> i::Foo<'a, uint> for Bar<'a> {
- fn foo(&self) -> uint { 5u }
+ fn foo(&self) -> uint { 5_usize }
}
pub fn main() {
fn main() {
assert_eq!(match [0u8; 1024] {
- _ => 42u,
- }, 42u);
+ _ => 42_usize,
+ }, 42_usize);
assert_eq!(match [0u8; 1024] {
- [1, _..] => 0u,
- [0, _..] => 1u,
- _ => 2u
- }, 1u);
+ [1, _..] => 0_usize,
+ [0, _..] => 1_usize,
+ _ => 2_usize
+ }, 1_usize);
}
#![feature(box_syntax)]
fn main() {
- let _ = [box 1u; 1];
+ let _ = [box 1_usize; 1];
}
#[allow(unused_must_use)]
fn main() {
- (0u..10).map(uint_to_foo);
+ (0_usize..10).map(uint_to_foo);
}
// and doesn't ICE.
fn main() {
- for &&x in Some(&0u).iter() {
+ for &&x in Some(&0_usize).iter() {
assert_eq!(x, 0)
}
}
fn main() {
let n = 0;
- let it = Some(1_us).into_iter().inspect(|_| {n;});
+ let it = Some(1_usize).into_iter().inspect(|_| {n;});
}
let mut i = lo;
while i < hi {
it(i);
- i += 1u;
+ i += 1_usize;
}
}
pub fn main() {
- let range: 'static ||uint|| = |a| range(0u, 1000u, a);
+ let range: 'static ||uint|| = |a| range(0_usize, 1000_usize, a);
let filt: 'static ||v: uint|| = |a| filter(
range,
- |&&n: uint| n % 3u != 0u && n % 5u != 0u,
+ |&&n: uint| n % 3_usize != 0_usize && n % 5_usize != 0_usize,
a);
- let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n );
+ let sum = foldl(filt, 0_usize, |accum, &&n: uint| accum + n );
println!("{}", sum);
}
}
pub fn main() {
- f(C(1u));
+ f(C(1_usize));
}
// the position of this function is significant! - if it comes before methods
// then it works, if it comes after it then it doesn't!
fn to_bools(bitv: Storage) -> Vec<bool> {
- (0us..8).map(|i| {
+ (0_usize..8).map(|i| {
let w = i / 64;
let b = i % 64;
let x = 1u64 & (bitv.storage[w] >> b);
let bools = vec!(false, false, true, false, false, true, true, false);
let bools2 = to_bools(Storage{storage: vec!(0b01100100)});
- for i in 0u..8 {
+ for i in 0_usize..8 {
println!("{} => {} vs {}", i, bools[i], bools2[i]);
}
// except according to those terms.
pub fn main() {
- let x = 1u;
+ let x = 1_usize;
let y = || x;
let _z = y();
}
// `box() (...)` syntax is needed to make pretty printer converge in one try:
let callback: SamplesFn = box() (move |buffer| {
- for i in 0u..buffer.len() {
+ for i in 0_usize..buffer.len() {
println!("{}: {}", i, buffer[i])
}
});
pub fn main() {
let i: uint = 0;
- assert!(i <= 0xFFFF_FFFF_u);
+ assert!(i <= 0xFFFF_FFFF_usize);
let i: int = 0;
- assert!(i >= -0x8000_0000_i);
- assert!(i <= 0x7FFF_FFFF_i);
+ assert!(i >= -0x8000_0000__isize);
+ assert!(i <= 0x7FFF_FFFF__isize);
}
assert_eq!(unsafe { NUM_DROPS }, 3);
{ let _x = FooBar::_Foo(Foo); }
assert_eq!(unsafe { NUM_DROPS }, 5);
- { let _x = FooBar::_Bar(42u); }
+ { let _x = FooBar::_Bar(42_usize); }
assert_eq!(unsafe { NUM_DROPS }, 6);
{ let _ = Foo; }
assert_eq!(unsafe { NUM_DROPS }, 9);
{ let _ = FooBar::_Foo(Foo); }
assert_eq!(unsafe { NUM_DROPS }, 11);
- { let _ = FooBar::_Bar(42u); }
+ { let _ = FooBar::_Bar(42_usize); }
assert_eq!(unsafe { NUM_DROPS }, 12);
}
assert!(thread::spawn(move|| { min_val::<i16>() / -1; }).join().is_err());
assert!(thread::spawn(move|| { min_val::<i32>() / -1; }).join().is_err());
assert!(thread::spawn(move|| { min_val::<i64>() / -1; }).join().is_err());
- assert!(thread::spawn(move|| { 1is / zero(); }).join().is_err());
+ assert!(thread::spawn(move|| { 1isize / zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i8 / zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i16 / zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i32 / zero(); }).join().is_err());
assert!(thread::spawn(move|| { min_val::<i16>() % -1; }).join().is_err());
assert!(thread::spawn(move|| { min_val::<i32>() % -1; }).join().is_err());
assert!(thread::spawn(move|| { min_val::<i64>() % -1; }).join().is_err());
- assert!(thread::spawn(move|| { 1is % zero(); }).join().is_err());
+ assert!(thread::spawn(move|| { 1isize % zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i8 % zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i16 % zero(); }).join().is_err());
assert!(thread::spawn(move|| { 1i32 % zero(); }).join().is_err());
struct X { pub x: uint }
impl Default for X {
fn default() -> X {
- X { x: 42u }
+ X { x: 42_usize }
}
}
#![str = "s"]
#![char = 'c']
#![int = 100]
- #![uint = 100u]
+ #![uint = 100_usize]
#![mach_int = 100u32]
#![float = 1.0]
#![mach_float = 1.0f32]
fn foo() -> Box<FnMut() -> isize + 'static> {
let k = box 22;
let _u = A {a: k.clone()};
- // FIXME(#16640) suffix in `22i` suffix shouldn't be necessary
- let result = || 22i;
+ // FIXME(#16640) suffix in `22_isize` suffix shouldn't be necessary
+ let result = || 22_isize;
box result
}
// except according to those terms.
pub fn main() {
- let x = 3u;
+ let x = 3_usize;
let ref y = x;
assert_eq!(x, *y);
}
// except according to those terms.
pub fn main() {
- let _i = 0u;
+ let _i = 0_usize;
loop {
break;
}
// except according to those terms.
pub fn main() {
- let mut i = 0u;
+ let mut i = 0_usize;
loop {
println!("a");
- i += 1u;
- if i == 10u {
+ i += 1_usize;
+ if i == 10_usize {
break;
}
}
- assert_eq!(i, 10u);
+ assert_eq!(i, 10_usize);
let mut is_even = false;
loop {
- if i == 21u {
+ if i == 21_usize {
break;
}
println!("b");
is_even = false;
- i += 1u;
- if i % 2u != 0u {
+ i += 1_usize;
+ if i % 2_usize != 0_usize {
continue;
}
is_even = true;
assert!(!is_even);
loop {
println!("c");
- if i == 22u {
+ if i == 22_usize {
break;
}
is_even = false;
- i += 1u;
- if i % 2u != 0u {
+ i += 1_usize;
+ if i % 2_usize != 0_usize {
continue;
}
is_even = true;
// except according to those terms.
fn main() {
- vec![1u, 2, 3].len();
+ vec![1_usize, 2, 3].len();
}
fn main() {
foo();
- assert_eq!(include!(concat!("", "../auxiliary/", "macro-include-items-expr.rs")), 1u);
+ assert_eq!(include!(concat!("", "../auxiliary/", "macro-include-items-expr.rs")), 1_usize);
}
pub fn main() {
assert!(overly_complicated!(f, x, Option<uint>, { return Some(x); },
- Some(8u), Some(y), y) == 8u)
+ Some(8_usize), Some(y), y) == 8_usize)
}
macro_rules! higher_order {
(subst $lhs:tt => $rhs:tt) => ({
macro_rules! anon { $lhs => $rhs }
- anon!(1u, 2u, "foo")
+ anon!(1_usize, 2_usize, "foo")
});
}
}
pub fn main() {
- assert_eq!(1u, f(Some('x')));
- assert_eq!(2u, f(Some('y')));
- assert_eq!(3u, f(None));
+ assert_eq!(1_usize, f(Some('x')));
+ assert_eq!(2_usize, f(Some('y')));
+ assert_eq!(3_usize, f(None));
assert_eq!(1, match Some('x') {
Some(char_x!()) => 1,
extern crate macro_reexport_2_no_use;
fn main() {
- assert_eq!(reexported!(), 3u);
+ assert_eq!(reexported!(), 3_usize);
}
extern crate macro_reexport_2;
fn main() {
- assert_eq!(reexported!(), 3u);
+ assert_eq!(reexported!(), 3_usize);
}
// ignore-lexer-test FIXME #15877
pub fn main() {
- match 5u {
- 1u...5u => {}
+ match 5_usize {
+ 1_usize...5_usize => {}
_ => panic!("should match range"),
}
- match 5u {
- 6u...7u => panic!("shouldn't match range"),
+ match 5_usize {
+ 6_usize...7_usize => panic!("shouldn't match range"),
_ => {}
}
- match 5u {
- 1u => panic!("should match non-first range"),
- 2u...6u => {}
+ match 5_usize {
+ 1_usize => panic!("should match non-first range"),
+ 2_usize...6_usize => {}
_ => panic!("math is broken")
}
match 'c' {
assert_eq!(match_vecs_snoc::<uint>(&[], &[]), "both empty");
assert_eq!(match_vecs_snoc(&[1, 2, 3], &[]), "one empty");
- assert_eq!(match_nested_vecs_cons(None, Ok::<&[_], ()>(&[4u, 2u])),
+ assert_eq!(match_nested_vecs_cons(None, Ok::<&[_], ()>(&[4_usize, 2_usize])),
"None, Ok(at least two elements)");
assert_eq!(match_nested_vecs_cons::<uint>(None, Err(())), "None, Ok(less than one element)");
assert_eq!(match_nested_vecs_cons::<bool>(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])),
assert_eq!(match_nested_vecs_cons(Some::<&[_]>(&[(42, ())]), Ok::<&[_], ()>(&[(1, ())])),
"Some(non-empty), any");
- assert_eq!(match_nested_vecs_snoc(None, Ok::<&[_], ()>(&[4u, 2u])),
+ assert_eq!(match_nested_vecs_snoc(None, Ok::<&[_], ()>(&[4_usize, 2_usize])),
"None, Ok(at least two elements)");
assert_eq!(match_nested_vecs_snoc::<uint>(None, Err(())), "None, Ok(less than one element)");
assert_eq!(match_nested_vecs_snoc::<bool>(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])),
x.foo(&x);
- unsafe { assert!(COUNT == 2u*3*3*3*5*5*5*7*7*7); }
+ unsafe { assert!(COUNT == 2_usize*3*3*3*5*5*5*7*7*7); }
}
fn call_foo_copy() -> int {
let mut x = Vec::new();
let y = x.foo();
- x.push(0u);
+ x.push(0_usize);
y
}
pub fn main() {
let x = box Triple{x: 1, y: 2, z: 3};
- for _ in 0u..10000u {
+ for _ in 0_usize..10000_usize {
assert_eq!(test(true, x.clone()), 2);
}
assert_eq!(test(false, x), 5);
}
pub fn main() {
- test_eq(22u, 0u);
+ test_eq(22_usize, 0_usize);
let value = MyType { dummy: 256 + 22 };
test_eq(value, value.dummy);
// uints
// num
- assert_eq!(15_usize.add(6us), 21_usize);
+ assert_eq!(15_usize.add(6_usize), 21_usize);
assert_eq!(15_u8.add(6u8), 21_u8);
assert_eq!(15_u16.add(6u16), 21_u16);
assert_eq!(15_u32.add(6u32), 21_u32);
}
pub fn main() {
- let mut x = 22_u;
+ let mut x = 22_usize;
let obj = &mut x as &mut Foo;
do_it_mut(obj);
- do_it_imm(obj, 23u);
+ do_it_imm(obj, 23_usize);
do_it_mut(obj);
}
box BarStruct{ x: 2 } as Box<FooTrait>
);
- for i in 0u..foos.len() {
+ for i in 0_usize..foos.len() {
assert_eq!(i, foos[i].foo());
}
}
pub fn main() {
assert_eq!(or_alt(blah::c), 0);
- assert_eq!(or_alt(blah::a(10, 100, 0u)), 110);
+ assert_eq!(or_alt(blah::a(10, 100, 0_usize)), 110);
assert_eq!(or_alt(blah::b(20, 200)), 220);
}
// Regression test for issue #152.
pub fn main() {
- let mut b: uint = 1u;
- while b <= 32u {
- 0u << b;
- b <<= 1u;
+ let mut b: uint = 1_usize;
+ while b <= 32_usize {
+ 0_usize << b;
+ b <<= 1_usize;
println!("{}", b);
}
}
}
pub fn main() {
- let box_5 = box 5u;
- assert_eq!(Rc::new(5u).to_uint(), Some(5));
+ let box_5 = box 5_usize;
+ assert_eq!(Rc::new(5_usize).to_uint(), Some(5));
assert_eq!((box &box &Rc::new(box box &box_5)).to_uint(), Some(5));
let point = Rc::new(Point {x: 2, y: 4});
assert_eq!(point.x, 2);
assert_eq!(mem::size_of::<[Foo; 10]>(), 90);
- for i in 0u..10 {
+ for i in 0_usize..10 {
assert_eq!(foos[i], Foo { bar: 1, baz: 2});
}
pub fn bar(_offset: uint) { }
}
-pub fn main() { foo::bar(0u); }
+pub fn main() { foo::bar(0_usize); }
match Some(src) {
Some(src_id) => {
- for _i in 0u..10u {
+ for _i in 0_usize..10_usize {
let yyy = src_id;
- assert_eq!(yyy, 0u);
+ assert_eq!(yyy, 0_usize);
}
}
_ => { }
}
}
-pub fn main() { foo(0u); }
+pub fn main() { foo(0_usize); }
pub fn main() {
let mut arena = Arena::new();
let p = &mut arena;
- let x = p.alloc(|| 4u);
+ let x = p.alloc(|| 4_usize);
println!("{}", *x);
- assert_eq!(*x, 4u);
+ assert_eq!(*x, 4_usize);
}
}
pub fn main() {
- let mut nyan : cat = cat(52u, 99);
- assert_eq!(nyan.meow_count(), 52u);
+ let mut nyan : cat = cat(52_usize, 99);
+ assert_eq!(nyan.meow_count(), 52_usize);
}
impl cat {
pub fn play(&mut self) {
- self.meows += 1u;
+ self.meows += 1_usize;
self.nap();
}
}
impl cat {
- fn nap(&mut self) { for _ in 1u..10u { } }
+ fn nap(&mut self) { for _ in 1_usize..10_usize { } }
}
fn cat(in_x : uint, in_y : int) -> cat {
}
pub fn main() {
- let mut nyan : cat = cat(52u, 99);
+ let mut nyan : cat = cat(52_usize, 99);
nyan.play();
}
pub fn main() {
unsafe {
- a::free(transmute(0u));
+ a::free(transmute(0_usize));
}
}
#![feature(box_syntax)]
fn sums_to(v: Vec<int> , sum: int) -> bool {
- let mut i = 0u;
+ let mut i = 0_usize;
let mut sum0 = 0;
while i < v.len() {
sum0 += v[i];
- i += 1u;
+ i += 1_usize;
}
return sum0 == sum;
}
fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool {
- let mut i = 0u;
+ let mut i = 0_usize;
let mut sum0 = box 0;
while i < v.len() {
*sum0 += v[i];
- i += 1u;
+ i += 1_usize;
}
return *sum0 == sum;
}
fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool {
- let mut i = 0u;
+ let mut i = 0_usize;
let mut sum0 = F {f: 0};
while i < v.len() {
sum0.f += v[i];
- i += 1u;
+ i += 1_usize;
}
return sum0.f == sum;
}
struct F<T> { f: T }
fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool {
- let mut i = 0u;
+ let mut i = 0_usize;
let mut sum0 = F {f: box 0};
while i < v.len() {
*sum0.f += v[i];
- i += 1u;
+ i += 1_usize;
}
return *sum0.f == sum;
}
pub fn main() {
let mut count = 0;
- for i in 0u..10 {
+ for i in 0_usize..10 {
assert!(i >= 0 && i < 10);
count += i;
}
assert!(count == 45);
let mut count = 0;
- let mut range = 0u..10;
+ let mut range = 0_usize..10;
for i in range {
assert!(i >= 0 && i < 10);
count += i;
assert!(count == 45);
let mut count = 0;
- let mut rf = 3u..;
+ let mut rf = 3_usize..;
for i in rf.take(10) {
assert!(i >= 3 && i < 13);
count += i;
}
assert!(count == 75);
- let _ = 0u..4+4-3;
+ let _ = 0_usize..4+4-3;
let _ = 0..foo();
- let _ = ..42u;
+ let _ = ..42_usize;
// Test we can use two different types with a common supertype.
let x = &42;
// from pairs of rows (where each pair of rows is equally sized),
// and the elements of the triangle match their row-pair index.
unsafe fn sanity_check(ascend: &[*mut u8]) {
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
- for j in 0u..size {
+ for j in 0_usize..size {
assert_eq!(*p0.offset(j as int), i as u8);
assert_eq!(*p1.offset(j as int), i as u8);
}
// that at least two rows will be allocated near each other, so
// that we trigger the bug (a buffer overrun) in an observable
// way.)
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let size = idx_to_size(i);
ascend[2*i] = allocate(size, ALIGN);
ascend[2*i+1] = allocate(size, ALIGN);
}
// Initialize each pair of rows to distinct value.
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
for j in 0..size {
*p0.offset(j as int) = i as u8;
test_3(ascend); // triangle -> square
test_4(ascend); // square -> triangle
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let size = idx_to_size(i);
deallocate(ascend[2*i], size, ALIGN);
deallocate(ascend[2*i+1], size, ALIGN);
// rows as we go.
unsafe fn test_1(ascend: &mut [*mut u8]) {
let new_size = idx_to_size(COUNT-1);
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(old_size < new_size);
// Test 2: turn the square back into a triangle, top to bottom.
unsafe fn test_2(ascend: &mut [*mut u8]) {
let old_size = idx_to_size(COUNT-1);
- for i in 0u..COUNT / 2 {
+ for i in 0_usize..COUNT / 2 {
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(new_size < old_size);
// Test 3: turn triangle into a square, bottom to top.
unsafe fn test_3(ascend: &mut [*mut u8]) {
let new_size = idx_to_size(COUNT-1);
- for i in (0u..COUNT / 2).rev() {
+ for i in (0_usize..COUNT / 2).rev() {
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(old_size < new_size);
// Test 4: turn the square back into a triangle, bottom to top.
unsafe fn test_4(ascend: &mut [*mut u8]) {
let old_size = idx_to_size(COUNT-1);
- for i in (0u..COUNT / 2).rev() {
+ for i in (0_usize..COUNT / 2).rev() {
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(new_size < old_size);
#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))]
mod m {
- pub fn align() -> uint { 4u }
- pub fn size() -> uint { 8u }
+ pub fn align() -> uint { 4_usize }
+ pub fn size() -> uint { 8_usize }
}
#[cfg(target_arch = "x86_64")]
mod m {
- pub fn align() -> uint { 4u }
- pub fn size() -> uint { 8u }
+ pub fn align() -> uint { 4_usize }
+ pub fn size() -> uint { 8_usize }
}
pub fn main() {
mod m {
#[cfg(target_arch = "x86")]
pub mod m {
- pub fn align() -> uint { 4u }
- pub fn size() -> uint { 12u }
+ pub fn align() -> uint { 4_usize }
+ pub fn size() -> uint { 12_usize }
}
#[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))]
pub mod m {
- pub fn align() -> uint { 8u }
- pub fn size() -> uint { 16u }
+ pub fn align() -> uint { 8_usize }
+ pub fn size() -> uint { 16_usize }
}
}
mod m {
#[cfg(target_arch = "x86")]
pub mod m {
- pub fn align() -> uint { 8u }
- pub fn size() -> uint { 16u }
+ pub fn align() -> uint { 8_usize }
+ pub fn size() -> uint { 16_usize }
}
#[cfg(target_arch = "x86_64")]
pub mod m {
- pub fn align() -> uint { 8u }
- pub fn size() -> uint { 16u }
+ pub fn align() -> uint { 8_usize }
+ pub fn size() -> uint { 16_usize }
}
}
mod m {
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub mod m {
- pub fn align() -> uint { 8u }
- pub fn size() -> uint { 16u }
+ pub fn align() -> uint { 8_usize }
+ pub fn size() -> uint { 16_usize }
}
}
}
pub fn main() {
- assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4u)), 10);
- assert_eq!(m(t3::c(T2 {x: t1::b(10u), y: 5}, 4u)), 19);
+ assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4_usize)), 10);
+ assert_eq!(m(t3::c(T2 {x: t1::b(10_usize), y: 5}, 4_usize)), 19);
}
}
pub fn main() {
- let p = box 22u;
+ let p = box 22_usize;
let r = foo(&*p);
println!("r={}", r);
- assert_eq!(r, 22u);
+ assert_eq!(r, 22_usize);
}
}
pub fn main() {
- let p = box 3u;
+ let p = box 3_usize;
let r = foo(&*p);
- assert_eq!(r, 3u);
+ assert_eq!(r, 3_usize);
}
fn bar(x: &uint) -> uint { *x }
pub fn main() {
- let p = box 3u;
+ let p = box 3_usize;
assert_eq!(bar(foo(&*p)), 3);
}
pub fn main() {
let mut x = 4;
- for i in 0u..3 {
+ for i in 0_usize..3 {
// ensure that the borrow in this alt
// does not interfere with the swap
// below. note that it would it you
}
pub fn main() {
- let x = 3u;
- assert_eq!(parameterized(&x), 3u);
+ let x = 3_usize;
+ assert_eq!(parameterized(&x), 3_usize);
}
// This version does not yet work (associated type issues)...
#[cfg(cannot_use_this_yet)]
fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
- let one = [1u];
+ let one = [1_usize];
assert_eq!(map.borrow().get("one"), Some(&one[]));
}
// ... and this version does not work (the lifetime of `one` is
// supposed to match the lifetime `'a`) ...
fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
- let one = [1u];
+ let one = [1_usize];
assert_eq!(map.borrow().get("one"), Some(&one.as_slice()));
}
let fromp = CString::from_slice(test_file.as_vec());
let modebuf = CString::from_slice(b"w+b");
let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
- assert!((ostream as uint != 0u));
+ assert!((ostream as uint != 0_usize));
let s = "hello".to_string();
let buf = CString::from_slice(b"hello");
let write_len = libc::fwrite(buf.as_ptr() as *mut _,
- 1u as libc::size_t,
- (s.len() + 1u) as libc::size_t,
+ 1_usize as libc::size_t,
+ (s.len() + 1_usize) as libc::size_t,
ostream);
assert_eq!(write_len, (s.len() + 1) as libc::size_t);
- assert_eq!(libc::fclose(ostream), (0u as libc::c_int));
+ assert_eq!(libc::fclose(ostream), (0_usize as libc::c_int));
let new_path = tmpdir.join_many(&["quux", "blat"]);
fs::mkdir_recursive(&new_path, old_io::USER_RWX);
fn my_err(s: String) -> ! { println!("{}", s); panic!(); }
fn okay(i: uint) -> int {
- if i == 3u {
+ if i == 3_usize {
my_err("I don't like three".to_string());
} else {
return 42;
}
}
-pub fn main() { okay(4u); }
+pub fn main() { okay(4_usize); }
fn test<F>(f: F) -> uint where F: FnOnce(uint) -> uint {
- return f(22u);
+ return f(22_usize);
}
pub fn main() {
- let y = test(|x| 4u * x);
- assert_eq!(y, 88u);
+ let y = test(|x| 4_usize * x);
+ assert_eq!(y, 88_usize);
}
}
fn test_const() {
- static r1_1: uint = 10u >> 2u;
- static r2_1: uint = 10u << 4u;
+ static r1_1: uint = 10_usize >> 2_usize;
+ static r2_1: uint = 10_usize << 4_usize;
assert_eq!(r1_1, 2 as uint);
assert_eq!(r2_1, 160 as uint);
- static r1_2: u8 = 10u8 >> 2u;
- static r2_2: u8 = 10u8 << 4u;
+ static r1_2: u8 = 10u8 >> 2_usize;
+ static r2_2: u8 = 10u8 << 4_usize;
assert_eq!(r1_2, 2 as u8);
assert_eq!(r2_2, 160 as u8);
- static r1_3: int = 10 >> 2u;
- static r2_3: int = 10 << 4u;
+ static r1_3: int = 10 >> 2_usize;
+ static r2_3: int = 10 << 4_usize;
assert_eq!(r1_3, 2 as int);
assert_eq!(r2_3, 160 as int);
- static r1_4: i8 = 10i8 >> 2u;
- static r2_4: i8 = 10i8 << 4u;
+ static r1_4: i8 = 10i8 >> 2_usize;
+ static r2_4: i8 = 10i8 << 4_usize;
assert_eq!(r1_4, 2 as i8);
assert_eq!(r2_4, 160 as i8);
- static r1_5: uint = 10u >> 2u;
- static r2_5: uint = 10u << 4u;
+ static r1_5: uint = 10_usize >> 2_usize;
+ static r2_5: uint = 10_usize << 4_usize;
assert_eq!(r1_5, 2 as uint);
assert_eq!(r2_5, 160 as uint);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-enum test { thing = -5 >> 1u }
+enum test { thing = -5 >> 1_usize }
pub fn main() {
assert_eq!(test::thing as int, -3);
}
Err(..) => unreachable!(),
Ok(f) => {
let mut f = f;
- for _ in 0u..1000 {
+ for _ in 0_usize..1000 {
f.write(&[0]);
}
}
self.to_string()
}
fn multi<F>(&self, mut f: F) where F: FnMut(uint) {
- let mut c = 0u;
- while c < *self { f(c); c += 1u; }
+ let mut c = 0_usize;
+ while c < *self { f(c); c += 1_usize; }
}
}
}
pub fn main() {
- assert_eq!(10u.plus(), 30);
+ assert_eq!(10_usize.plus(), 30);
assert_eq!(("hi".to_string()).plus(), 200);
assert_eq!((vec!(1)).length_().str(), "1".to_string());
let vect = vec!(3, 4).map_(|a| *a + 4);
assert_eq!(vect[0], 7);
- let vect = (vec!(3, 4)).map_::<uint, _>(|a| *a as uint + 4u);
- assert_eq!(vect[0], 7u);
- let mut x = 0u;
- 10u.multi(|_n| x += 2u );
- assert_eq!(x, 20u);
+ let vect = (vec!(3, 4)).map_::<uint, _>(|a| *a as uint + 4_usize);
+ assert_eq!(vect[0], 7_usize);
+ let mut x = 0_usize;
+ 10_usize.multi(|_n| x += 2_usize );
+ assert_eq!(x, 20_usize);
}
impl Foo for uint {
fn foo() -> uint {
- 5u
+ 5_usize
}
}
}
// Make sure we properly handle repeated self-appends.
let mut a: String = "A".to_string();
let mut i = 20;
- let mut expected_len = 1u;
+ let mut expected_len = 1_usize;
while i > 0 {
println!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = format!("{}{}", a, a);
i -= 1;
- expected_len *= 2u;
+ expected_len *= 2_usize;
}
}
extern crate libc;
pub fn main() {
- let f = 1u as *const libc::FILE;
+ let f = 1_usize as *const libc::FILE;
println!("{:?}", f as int);
println!("{:?}", f as uint);
println!("{:?}", f as i8);
println!("{:?}", 1 as f32);
println!("{:?}", 1 as f64);
- println!("{:?}", 1u as int);
- println!("{:?}", 1u as uint);
- println!("{:?}", 1u as *const libc::FILE);
- println!("{:?}", 1u as i8);
- println!("{:?}", 1u as i16);
- println!("{:?}", 1u as i32);
- println!("{:?}", 1u as i64);
- println!("{:?}", 1u as u8);
- println!("{:?}", 1u as u16);
- println!("{:?}", 1u as u32);
- println!("{:?}", 1u as u64);
- println!("{:?}", 1u as f32);
- println!("{:?}", 1u as f64);
+ println!("{:?}", 1_usize as int);
+ println!("{:?}", 1_usize as uint);
+ println!("{:?}", 1_usize as *const libc::FILE);
+ println!("{:?}", 1_usize as i8);
+ println!("{:?}", 1_usize as i16);
+ println!("{:?}", 1_usize as i32);
+ println!("{:?}", 1_usize as i64);
+ println!("{:?}", 1_usize as u8);
+ println!("{:?}", 1_usize as u16);
+ println!("{:?}", 1_usize as u32);
+ println!("{:?}", 1_usize as u64);
+ println!("{:?}", 1_usize as f32);
+ println!("{:?}", 1_usize as f64);
println!("{:?}", 1i8 as int);
println!("{:?}", 1i8 as uint);
{
assert!(file!().ends_with("includeme.fragment"));
- assert!(line!() == 5u);
+ assert!(line!() == 5_usize);
format!("victory robot {}", line!())
}
fn is_8_byte_aligned(u: &Tag<u64>) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & 7u) == 0u;
+ return (p & 7_usize) == 0_usize;
}
pub fn main() {
fn is_aligned<A>(amnt: uint, u: &A) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & (amnt-1u)) == 0u;
+ return (p & (amnt-1_usize)) == 0_usize;
}
fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool {
pub fn main() {
let x = mk_rec(22u64, 23u64);
- assert!(is_aligned(8u, &x.tA));
- assert!(variant_data_is_aligned(8u, &x.tA));
- assert!(is_aligned(8u, &x.tB));
- assert!(variant_data_is_aligned(8u, &x.tB));
+ assert!(is_aligned(8_usize, &x.tA));
+ assert!(variant_data_is_aligned(8_usize, &x.tA));
+ assert!(is_aligned(8_usize, &x.tB));
+ assert!(variant_data_is_aligned(8_usize, &x.tB));
let x = mk_rec(22u64, 23u32);
- assert!(is_aligned(8u, &x.tA));
- assert!(variant_data_is_aligned(8u, &x.tA));
- assert!(is_aligned(8u, &x.tB));
- assert!(variant_data_is_aligned(4u, &x.tB));
+ assert!(is_aligned(8_usize, &x.tA));
+ assert!(variant_data_is_aligned(8_usize, &x.tA));
+ assert!(is_aligned(8_usize, &x.tB));
+ assert!(variant_data_is_aligned(4_usize, &x.tB));
let x = mk_rec(22u32, 23u64);
- assert!(is_aligned(8u, &x.tA));
- assert!(variant_data_is_aligned(4u, &x.tA));
- assert!(is_aligned(8u, &x.tB));
- assert!(variant_data_is_aligned(8u, &x.tB));
+ assert!(is_aligned(8_usize, &x.tA));
+ assert!(variant_data_is_aligned(4_usize, &x.tA));
+ assert!(is_aligned(8_usize, &x.tB));
+ assert!(variant_data_is_aligned(8_usize, &x.tB));
let x = mk_rec(22u32, 23u32);
- assert!(is_aligned(4u, &x.tA));
- assert!(variant_data_is_aligned(4u, &x.tA));
- assert!(is_aligned(4u, &x.tB));
- assert!(variant_data_is_aligned(4u, &x.tB));
+ assert!(is_aligned(4_usize, &x.tA));
+ assert!(variant_data_is_aligned(4_usize, &x.tA));
+ assert!(is_aligned(4_usize, &x.tB));
+ assert!(variant_data_is_aligned(4_usize, &x.tB));
let x = mk_rec(22f64, 23f64);
- assert!(is_aligned(8u, &x.tA));
- assert!(variant_data_is_aligned(8u, &x.tA));
- assert!(is_aligned(8u, &x.tB));
- assert!(variant_data_is_aligned(8u, &x.tB));
+ assert!(is_aligned(8_usize, &x.tA));
+ assert!(variant_data_is_aligned(8_usize, &x.tA));
+ assert!(is_aligned(8_usize, &x.tB));
+ assert!(variant_data_is_aligned(8_usize, &x.tB));
}
fn is_8_byte_aligned(u: &Tag) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & 7u) == 0u;
+ return (p & 7_usize) == 0_usize;
}
pub fn main() {
});
// Sleep long enough for the task to finish.
- let mut i = 0u;
+ let mut i = 0_usize;
while i < 10000 {
Thread::yield_now();
i += 1;
rx1.recv().unwrap();
let mut v = Vec::new();
- for _ in 0u..10000 {
+ for _ in 0_usize..10000 {
match TcpStream::connect_timeout(addr, Duration::milliseconds(100)) {
Ok(e) => v.push(e),
Err(ref e) if e.kind == old_io::TimedOut => return,
let addr = rx.recv().unwrap();
let (tx, rx) = channel();
- for _ in 0u..1000 {
+ for _ in 0_usize..1000 {
let tx = tx.clone();
Builder::new().stack_size(64 * 1024).spawn(move|| {
match TcpStream::connect(addr) {
// Wait for all clients to exit, but don't wait for the server to exit. The
// server just runs infinitely.
drop(tx);
- for _ in 0u..1000 {
+ for _ in 0_usize..1000 {
rx.recv().unwrap();
}
unsafe { libc::exit(0) }
}
pub fn main () {
- assert_eq!(f::<f64, int>(0, 2u), 2u);
- assert_eq!(f::<uint, int>(0, 2u), 2u);
+ assert_eq!(f::<f64, int>(0, 2_usize), 2_usize);
+ assert_eq!(f::<uint, int>(0, 2_usize), 2_usize);
}
fn range_<F>(lo: uint, hi: uint, mut it: F) where F: FnMut(uint) {
let mut lo_ = lo;
- while lo_ < hi { it(lo_); lo_ += 1u; }
+ while lo_ < hi { it(lo_); lo_ += 1_usize; }
}
fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern fn(T) -> uint) {
- range_(0u, 256u, |_i| {
+ range_(0_usize, 256_usize, |_i| {
let _bucket: Vec<T> = Vec::new();
})
}
pub fn main() {
- let x: Vec<_> = (0u..5).collect();
+ let x: Vec<_> = (0_usize..5).collect();
let expected: &[uint] = &[0,1,2,3,4];
assert_eq!(x, expected);
- let x = (0u..5).collect::<Vec<_>>();
+ let x = (0_usize..5).collect::<Vec<_>>();
assert_eq!(x, expected);
let y: _ = "hello";
assert_eq!(y.len(), 5);
- let ptr = &5u;
+ let ptr = &5_usize;
let ptr2 = ptr as *const _;
assert_eq!(ptr as *const uint as uint, ptr2 as uint);
}
fn main() {
- let mut x = 0u;
- let y = 2u;
+ let mut x = 0_usize;
+ let y = 2_usize;
call_fn(|| assert_eq!(x, 0));
call_fn_mut(|| x += y);
extern crate "unboxed-closures-cross-crate" as ubcc;
fn main() {
- assert_eq!(ubcc::has_closures(), 2u);
- assert_eq!(ubcc::has_generic_closures(2u, 3u), 5u);
+ assert_eq!(ubcc::has_closures(), 2_usize);
+ assert_eq!(ubcc::has_generic_closures(2_usize, 3_usize), 5_usize);
}
}
fn main() {
- let mut x = 0u;
- let y = 2u;
+ let mut x = 0_usize;
+ let y = 2_usize;
call_fn(|| assert_eq!(x, 0));
call_fn_mut(|| x += y);
fn main() {
{
- let mut x = 0u;
+ let mut x = 0_usize;
move || x += 1;
}
{
- let mut x = 0u;
+ let mut x = 0_usize;
move || x += 1;
}
{
- let mut x = 0u;
+ let mut x = 0_usize;
move || set(&mut x);
}
{
- let mut x = 0u;
+ let mut x = 0_usize;
move || set(&mut x);
}
}
}
pub fn main() {
- let mut a = 7u;
+ let mut a = 7_usize;
let b = &mut a;
replace_map(b, |x: uint| x * 2);
- assert_eq!(*b, 14u);
+ assert_eq!(*b, 14_usize);
}
fn null<T>() -> *const T {
unsafe {
- mem::transmute(0u)
+ mem::transmute(0_usize)
}
}
enum bar { u(Box<Foo>), w(int), }
pub fn main() {
- assert!(match bar::u(box Foo{a: 10, b: 40u}) {
+ assert!(match bar::u(box Foo{a: 10, b: 40_usize}) {
bar::u(box Foo{a: a, b: b}) => { a + (b as int) }
_ => { 66 }
} == 50);
pub fn main() {
let (tx, rx) = channel();
- let n = 100u;
- let mut expected = 0u;
- let _t = (0u..n).map(|i| {
+ let n = 100_usize;
+ let mut expected = 0_usize;
+ let _t = (0_usize..n).map(|i| {
expected += i;
let tx = tx.clone();
thread::spawn(move|| {
})
}).collect::<Vec<_>>();
- let mut actual = 0u;
- for _ in 0u..n {
+ let mut actual = 0_usize;
+ for _ in 0_usize..n {
let j = rx.recv().unwrap();
actual += *j;
}
let s: String = chs.iter().cloned().collect();
let schs: Vec<char> = s.chars().collect();
- assert!(s.len() == 10u);
- assert!(s.chars().count() == 4u);
- assert!(schs.len() == 4u);
+ assert!(s.len() == 10_usize);
+ assert!(s.chars().count() == 4_usize);
+ assert!(schs.len() == 4_usize);
assert!(schs.iter().cloned().collect::<String>() == s);
- assert!(s.char_at(0u) == 'e');
- assert!(s.char_at(1u) == 'é');
+ assert!(s.char_at(0_usize) == 'e');
+ assert!(s.char_at(1_usize) == 'é');
assert!((str::from_utf8(s.as_bytes()).is_ok()));
// invalid prefix
let 午餐 = 10;
let ארוחת_צהריי = 10;
- let غداء = 10u;
+ let غداء = 10_usize;
let լանչ = 10;
let обед = 10;
let абед = 10;
assert_eq!(x[2], 3);
assert_eq!(x[3], 4);
- assert_eq!(size_of::<[u8; 4]>(), 4u);
+ assert_eq!(size_of::<[u8; 4]>(), 4_usize);
// FIXME #10183
// FIXME #18069
//if cfg!(target_pointer_width = "64") {
- // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1u << 32));
+ // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1_usize << 32));
//}
}
// work out the total number of comparisons required to sort
// this array...
- let mut count = 0us;
+ let mut count = 0_usize;
main.clone().sort_by(|a, b| { count += 1; a.cmp(b) });
// ... and then panic on each and every single one.
fn p() -> bool { true }
let _a = (assert!((true)) == (assert!(p())));
let _c = (assert!((p())) == ());
- let _b: bool = (println!("{}", 0) == (return 0u));
+ let _b: bool = (println!("{}", 0) == (return 0_usize));
}
fn angrydome() {
-pub fn main() { let x: int = 10; while x == 10 && x == 11 { let _y = 0xf00u; } }
+pub fn main() { let x: int = 10; while x == 10 && x == 11 { let _y = 0xf00_usize; } }
#[cfg(windows)]
pub fn main() {
unsafe {
- let expected = 1234u;
+ let expected = 1234_usize;
kernel32::SetLastError(expected);
let actual = kernel32::GetLastError();
println!("actual = {}", actual);
pub fn main() {
let heap = unsafe { kernel32::GetProcessHeap() };
let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) };
- assert!(mem != 0u);
+ assert!(mem != 0_usize);
let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) };
assert!(res != 0u8);
}