From: Niko Matsakis Date: Mon, 21 Apr 2014 21:58:52 +0000 (-0400) Subject: librustc: Remove the fallback to `int` from typechecking. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=9e3d0b002a5c2e81d43351c9b8550a3f4ccfb8f9;p=rust.git librustc: Remove the fallback to `int` from typechecking. This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change] --- diff --git a/src/doc/guide-container.md b/src/doc/guide-container.md index 903aa868409..3fe237b1748 100644 --- a/src/doc/guide-container.md +++ b/src/doc/guide-container.md @@ -135,7 +135,7 @@ invalidation*. As long as an iterator is still in scope, the compiler will preve modification of the container through another handle. ~~~ -let mut xs = [1, 2, 3]; +let mut xs = [1i, 2, 3]; { let _it = xs.iter(); @@ -155,7 +155,7 @@ example, the `fold` method will accumulate the items yielded by an `Iterator` into a single value: ~~~ -let xs = [1, 9, 2, 3, 14, 12]; +let xs = [1i, 9, 2, 3, 14, 12]; let result = xs.iter().fold(0, |accumulator, item| accumulator - *item); assert_eq!(result, -41); ~~~ @@ -163,8 +163,8 @@ assert_eq!(result, -41); Most adaptors return an adaptor object implementing the `Iterator` trait itself: ~~~ -let xs = [1, 9, 2, 3, 14, 12]; -let ys = [5, 2, 1, 8]; +let xs = [1i, 9, 2, 3, 14, 12]; +let ys = [5i, 2, 1, 8]; let sum = xs.iter().chain(ys.iter()).fold(0, |a, b| a + *b); assert_eq!(sum, 57); ~~~ @@ -180,8 +180,8 @@ iterator adaptor named `fuse()` is provided. This returns an iterator that will never call its underlying iterator again once `None` has been returned: ~~~ -let xs = [1,2,3,4,5]; -let mut calls = 0; +let xs = [1i,2,3,4,5]; +let mut calls = 0i; { let it = xs.iter().scan((), |_, x| { @@ -209,11 +209,11 @@ assert_eq!(calls, 3); The function `range` (or `range_inclusive`) allows to simply iterate through a given range: ~~~ -for i in range(0, 5) { +for i in range(0i, 5) { print!("{} ", i) // prints "0 1 2 3 4" } -for i in std::iter::range_inclusive(0, 5) { // needs explicit import +for i in std::iter::range_inclusive(0i, 5) { // needs explicit import print!("{} ", i) // prints "0 1 2 3 4 5" } ~~~ @@ -238,7 +238,7 @@ For loops are *often* used with a temporary iterator object, as above. They can also advance the state of an iterator in a mutable location: ~~~ -let xs = [1, 2, 3, 4, 5]; +let xs = [1i, 2, 3, 4, 5]; let ys = ["foo", "bar", "baz", "foobar"]; // create an iterator yielding tuples of elements from both vectors @@ -265,7 +265,7 @@ assert!(it.next().is_none()); Iterators offer generic conversion to containers with the `collect` adaptor: ~~~ -let xs = [0, 1, 1, 2, 3, 5, 8]; +let xs = [0i, 1, 1, 2, 3, 5, 8]; let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::>(); assert_eq!(ys, vec![10, 6, 4, 2, 2, 0]); ~~~ @@ -347,7 +347,7 @@ A `DoubleEndedIterator` can have its direction changed with the `rev` adaptor, returning another `DoubleEndedIterator` with `next` and `next_back` exchanged. ~~~ -let xs = [1, 2, 3, 4, 5, 6]; +let xs = [1i, 2, 3, 4, 5, 6]; let mut it = xs.iter(); println!("{}", it.next()); // prints `Some(1)` println!("{}", it.next()); // prints `Some(2)` @@ -363,8 +363,8 @@ The `chain`, `map`, `filter`, `filter_map` and `inspect` adaptors are `DoubleEndedIterator` implementations if the underlying iterators are. ~~~ -let xs = [1, 2, 3, 4]; -let ys = [5, 6, 7, 8]; +let xs = [1i, 2, 3, 4]; +let ys = [5i, 6, 7, 8]; let mut it = xs.iter().chain(ys.iter()).map(|&x| x * 2); println!("{}", it.next()); // prints `Some(2)` @@ -380,9 +380,9 @@ mutable references. It can be used to reverse a container in-place. Note that the trailing underscore is a workaround for issue #5898 and will be removed. ~~~ -let mut ys = [1, 2, 3, 4, 5]; +let mut ys = [1i, 2, 3, 4, 5]; ys.mut_iter().reverse_(); -assert!(ys == [5, 4, 3, 2, 1]); +assert!(ys == [5i, 4, 3, 2, 1]); ~~~ ## Random-access iterators @@ -395,8 +395,8 @@ The `chain` adaptor is an implementation of `RandomAccessIterator` if the underlying iterators are. ~~~ -let xs = [1, 2, 3, 4, 5]; -let ys = [7, 9, 11]; +let xs = [1i, 2, 3, 4, 5]; +let ys = [7i, 9, 11]; let mut it = xs.iter().chain(ys.iter()); println!("{}", it.idx(0)); // prints `Some(1)` println!("{}", it.idx(5)); // prints `Some(7)` diff --git a/src/doc/guide-lifetimes.md b/src/doc/guide-lifetimes.md index 66b9ef1ea72..1f44b77d56a 100644 --- a/src/doc/guide-lifetimes.md +++ b/src/doc/guide-lifetimes.md @@ -577,7 +577,7 @@ This is equivalent to the previous definition. Named lifetime notation can also be used to control the flow of execution: ~~~ -'h: for i in range(0,10) { +'h: for i in range(0u, 10) { 'g: loop { if i % 2 == 0 { continue 'h; } if i == 9 { break 'h; } diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index 5161dbc6bbb..08652822097 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -315,7 +315,7 @@ duration a 'lifetime'. Let's try a more complex example: ~~~rust fn main() { - let mut x = box 5; + let mut x = box 5i; if *x < 10 { let y = &x; println!("Oh no: {}", y); @@ -332,7 +332,7 @@ mutated, and therefore, lets us pass. This wouldn't work: ~~~rust{.ignore} fn main() { - let mut x = box 5; + let mut x = box 5i; if *x < 10 { let y = &x; *x -= 1; diff --git a/src/doc/guide-testing.md b/src/doc/guide-testing.md index 3d6093bad25..1d6513972a6 100644 --- a/src/doc/guide-testing.md +++ b/src/doc/guide-testing.md @@ -269,7 +269,7 @@ use test::Bencher; #[bench] fn bench_xor_1000_ints(b: &mut Bencher) { b.iter(|| { - range(0, 1000).fold(0, |old, new| old ^ new); + range(0u, 1000).fold(0, |old, new| old ^ new); }); } ~~~ @@ -293,7 +293,7 @@ example above by adjusting the `bh.iter` call to # struct X; impl X { fn iter(&self, _: || -> T) {} } let b = X; b.iter(|| { // note lack of `;` (could also use an explicit `return`). - range(0, 1000).fold(0, |old, new| old ^ new) + range(0u, 1000).fold(0, |old, new| old ^ new) }); ~~~ @@ -307,7 +307,7 @@ extern crate test; # fn main() { # struct X; impl X { fn iter(&self, _: || -> T) {} } let b = X; b.iter(|| { - test::black_box(range(0, 1000).fold(0, |old, new| old ^ new)); + test::black_box(range(0u, 1000).fold(0, |old, new| old ^ new)); }); # } ~~~ diff --git a/src/doc/intro.md b/src/doc/intro.md index d30d7122986..1e577a91131 100644 --- a/src/doc/intro.md +++ b/src/doc/intro.md @@ -198,7 +198,7 @@ Typically, tasks do not share memory but instead communicate amongst each other ``` fn main() { - let numbers = vec![1,2,3]; + let numbers = vec![1i, 2i, 3i]; let (tx, rx) = channel(); tx.send(numbers); @@ -237,7 +237,7 @@ try to modify the previous example to continue using the variable `numbers`: ```ignore fn main() { - let numbers = vec![1,2,3]; + let numbers = vec![1i, 2i, 3i]; let (tx, rx) = channel(); tx.send(numbers); @@ -267,9 +267,9 @@ Let's see an example that uses the `clone` method to create copies of the data: ``` fn main() { - let numbers = vec![1,2,3]; + let numbers = vec![1i, 2i, 3i]; - for num in range(0, 3) { + for num in range(0u, 3) { let (tx, rx) = channel(); // Use `clone` to send a *copy* of the array tx.send(numbers.clone()); @@ -300,10 +300,10 @@ Here's some code: use std::sync::Arc; fn main() { - let numbers = vec![1,2,3]; + let numbers = vec![1i, 2i, 3i]; let numbers = Arc::new(numbers); - for num in range(0, 3) { + for num in range(0u, 3) { let (tx, rx) = channel(); tx.send(numbers.clone()); @@ -346,10 +346,10 @@ and modify it to mutate the shared state: use std::sync::{Arc, Mutex}; fn main() { - let numbers = vec![1,2,3]; + let numbers = vec![1i, 2i, 3i]; let numbers_lock = Arc::new(Mutex::new(numbers)); - for num in range(0, 3) { + for num in range(0u, 3) { let (tx, rx) = channel(); tx.send(numbers_lock.clone()); diff --git a/src/doc/rust.md b/src/doc/rust.md index b2c56c3a3ca..a9814dccb3f 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -955,11 +955,12 @@ use std::option::{Some, None}; # fn foo(_: T){} fn main() { - // Equivalent to 'std::iter::range_step(0, 10, 2);' - range_step(0, 10, 2); + // Equivalent to 'std::iter::range_step(0u, 10u, 2u);' + range_step(0u, 10u, 2u); - // Equivalent to 'foo(vec![std::option::Some(1.0), std::option::None]);' - foo(vec![Some(1.0), None]); + // Equivalent to 'foo(vec![std::option::Some(1.0f64), + // std::option::None]);' + foo(vec![Some(1.0f64), None]); } ~~~~ @@ -1475,7 +1476,7 @@ to pointers to the trait name, used as a type. ~~~~ # trait Shape { } # impl Shape for int { } -# let mycircle = 0; +# let mycircle = 0i; let myshape: Box = box mycircle as Box; ~~~~ @@ -3613,7 +3614,7 @@ and no-return value closure has type `proc()`. An example of creating and calling a closure: ```rust -let captured_var = 10; +let captured_var = 10i; let closure_no_args = || println!("captured_var={}", captured_var); @@ -3685,7 +3686,7 @@ fn print(a: Box) { } fn main() { - print(box 10 as Box); + print(box 10i as Box); } ~~~~ diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 67a153a6584..39d2da30fa4 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -220,7 +220,7 @@ mut` instead. ~~~~ let hi = "hi"; -let mut count = 0; +let mut count = 0i; while count < 10 { println!("count is {}", count); @@ -407,7 +407,7 @@ error when the types of the directives don't match the types of the arguments. ~~~ // `{}` will print the "default format" of a type -println!("{} is {}", "the answer", 43); +println!("{} is {}", "the answer", 43i); ~~~ ~~~~ @@ -535,7 +535,7 @@ A subpattern can also be bound to a variable, using `variable @ pattern`. For example: ~~~~ -# let age = 23; +# let age = 23i; match age { a @ 0..20 => println!("{} years old", a), _ => println!("older than 21") @@ -594,7 +594,7 @@ it finds one that can be divided by five. There is also a for-loop that can be used to iterate over a range of numbers: ~~~~ -for n in range(0, 5) { +for n in range(0u, 5) { println!("{}", n); } ~~~~ @@ -1124,7 +1124,7 @@ as it is only called a single time. Avoiding a move can be done with the library-defined `clone` method: ~~~~ -let x = box 5; +let x = box 5i; let y = x.clone(); // `y` is a newly allocated box let z = x; // no new memory allocated, `x` can no longer be used ~~~~ @@ -1356,8 +1356,8 @@ impl PartialEq for List { } } -let xs = Cons(5, box Cons(10, box Nil)); -let ys = Cons(5, box Cons(10, box Nil)); +let xs = Cons(5i, box Cons(10i, box Nil)); +let ys = Cons(5i, box Cons(10i, box Nil)); // The methods below are part of the PartialEq trait, // which we implemented on our linked list. assert!(xs.eq(&ys)); @@ -1584,7 +1584,7 @@ elements are mutable if the vector is mutable. Fixed-size strings do not exist. ~~~ // A fixed-size vector -let numbers = [1, 2, 3]; +let numbers = [1i, 2, 3]; let more_numbers = numbers; // The type of a fixed-size vector is written as `[Type, ..length]` @@ -1599,7 +1599,7 @@ the elements are mutable if the vector is mutable. use std::string::String; // A dynamically sized vector (unique vector) -let mut numbers = vec![1, 2, 3]; +let mut numbers = vec![1i, 2, 3]; numbers.push(4); numbers.push(5); @@ -1694,11 +1694,11 @@ contained value are destroyed. use std::rc::Rc; // A fixed-size array allocated in a reference-counted box -let x = Rc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +let x = Rc::new([1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]); let y = x.clone(); // a new owner let z = x; // this moves `x` into `z`, rather than creating a new owner -assert!(*z == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +assert!(*z == [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // the variable is mutable, but not the contents of the box let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); @@ -1713,11 +1713,11 @@ not have a destructor. use std::gc::GC; // A fixed-size array allocated in a garbage-collected box -let x = box(GC) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let y = x; // does not perform a move, unlike with `Rc` let z = x; -assert!(*z == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); +assert!(*z == [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]); ~~~ With shared ownership, mutability cannot be inherited so the boxes are always immutable. However, @@ -3130,7 +3130,7 @@ extern crate num; fn main() { // The rational number '1/2': - let one_half = ::num::rational::Ratio::new(1, 2); + let one_half = ::num::rational::Ratio::new(1i, 2); } ~~~ @@ -3165,7 +3165,7 @@ mod farm { fn main() { farm::dog(); - let a_third = Ratio::new(1, 3); + let a_third = Ratio::new(1i, 3); } ~~~ @@ -3292,13 +3292,13 @@ use iter_range = std::iter::range; fn main() { // `range` is imported by default - for _ in range(0, 10) {} + for _ in range(0u, 10) {} // Doesn't hinder you from importing it under a different name yourself - for _ in iter_range(0, 10) {} + for _ in iter_range(0u, 10) {} // Or from not using the automatic import. - for _ in ::std::iter::range(0, 10) {} + for _ in ::std::iter::range(0u, 10) {} } ~~~ diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 94bf3368a0a..cccd5cb63ef 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -39,7 +39,7 @@ /// let numbers = Vec::from_fn(100, |i| i as f32); /// let shared_numbers = Arc::new(numbers); /// -/// for _ in range(0, 10) { +/// for _ in range(0u, 10) { /// let child_numbers = shared_numbers.clone(); /// /// spawn(proc() { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index db6af30bce7..c6e81fa7f7c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -276,7 +276,7 @@ mod tests { #[test] fn test_clone() { - let x = Rc::new(RefCell::new(5)); + let x = Rc::new(RefCell::new(5i)); let y = x.clone(); *x.borrow_mut() = 20; assert_eq!(*y.borrow(), 20); @@ -284,13 +284,13 @@ fn test_clone() { #[test] fn test_simple() { - let x = Rc::new(5); + let x = Rc::new(5i); assert_eq!(*x, 5); } #[test] fn test_simple_clone() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.clone(); assert_eq!(*x, 5); assert_eq!(*y, 5); @@ -298,20 +298,20 @@ fn test_simple_clone() { #[test] fn test_destructor() { - let x = Rc::new(box 5); + let x = Rc::new(box 5i); assert_eq!(**x, 5); } #[test] fn test_live() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.downgrade(); assert!(y.upgrade().is_some()); } #[test] fn test_dead() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.downgrade(); drop(x); assert!(y.upgrade().is_none()); @@ -321,7 +321,7 @@ fn test_dead() { fn gc_inside() { // see issue #11532 use std::gc::GC; - let a = Rc::new(RefCell::new(box(GC) 1)); + let a = Rc::new(RefCell::new(box(GC) 1i)); assert!(a.try_borrow_mut().is_some()); } diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index ee1e0fd72cf..aacf9936cce 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -513,7 +513,7 @@ struct Point { #[test] pub fn test_copy() { let arena = TypedArena::new(); - for _ in range(0, 100000) { + for _ in range(0u, 100000) { arena.alloc(Point { x: 1, y: 2, @@ -567,7 +567,7 @@ struct Noncopy { #[test] pub fn test_noncopy() { let arena = TypedArena::new(); - for _ in range(0, 100000) { + for _ in range(0u, 100000) { arena.alloc(Noncopy { string: "hello world".to_string(), array: vec!( 1, 2, 3, 4, 5 ), diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 572178bd196..234393ce561 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -572,7 +572,7 @@ fn index(&self, i: &uint) -> bool { impl fmt::Show for Bitv { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { for bit in self.iter() { - try!(write!(fmt, "{}", if bit { 1 } else { 0 })); + try!(write!(fmt, "{}", if bit { 1u } else { 0u })); } Ok(()) } diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 82abe69a639..64bee05a379 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -785,17 +785,17 @@ mod test_btree { //Tests the functionality of the insert methods (which are unfinished). #[test] fn insert_test_one() { - let b = BTree::new(1, "abc".to_string(), 2); - let is_insert = b.insert(2, "xyz".to_string()); + let b = BTree::new(1i, "abc".to_string(), 2); + let is_insert = b.insert(2i, "xyz".to_string()); //println!("{}", is_insert.clone().to_str()); assert!(is_insert.root.is_leaf()); } #[test] fn insert_test_two() { - let leaf_elt_1 = LeafElt::new(1, "aaa".to_string()); - let leaf_elt_2 = LeafElt::new(2, "bbb".to_string()); - let leaf_elt_3 = LeafElt::new(3, "ccc".to_string()); + let leaf_elt_1 = LeafElt::new(1i, "aaa".to_string()); + let leaf_elt_2 = LeafElt::new(2i, "bbb".to_string()); + let leaf_elt_3 = LeafElt::new(3i, "ccc".to_string()); let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3)); let b = BTree::new_with_node_len(n, 3, 2); //println!("{}", b.clone().insert(4, "ddd".to_string()).to_str()); @@ -804,10 +804,10 @@ fn insert_test_two() { #[test] fn insert_test_three() { - let leaf_elt_1 = LeafElt::new(1, "aaa".to_string()); - let leaf_elt_2 = LeafElt::new(2, "bbb".to_string()); - let leaf_elt_3 = LeafElt::new(3, "ccc".to_string()); - let leaf_elt_4 = LeafElt::new(4, "ddd".to_string()); + let leaf_elt_1 = LeafElt::new(1i, "aaa".to_string()); + let leaf_elt_2 = LeafElt::new(2i, "bbb".to_string()); + let leaf_elt_3 = LeafElt::new(3i, "ccc".to_string()); + let leaf_elt_4 = LeafElt::new(4i, "ddd".to_string()); let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4)); let b = BTree::new_with_node_len(n, 3, 2); //println!("{}", b.clone().insert(5, "eee".to_string()).to_str()); @@ -816,10 +816,10 @@ fn insert_test_three() { #[test] fn insert_test_four() { - let leaf_elt_1 = LeafElt::new(1, "aaa".to_string()); - let leaf_elt_2 = LeafElt::new(2, "bbb".to_string()); - let leaf_elt_3 = LeafElt::new(3, "ccc".to_string()); - let leaf_elt_4 = LeafElt::new(4, "ddd".to_string()); + let leaf_elt_1 = LeafElt::new(1i, "aaa".to_string()); + let leaf_elt_2 = LeafElt::new(2i, "bbb".to_string()); + let leaf_elt_3 = LeafElt::new(3i, "ccc".to_string()); + let leaf_elt_4 = LeafElt::new(4i, "ddd".to_string()); let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4)); let mut b = BTree::new_with_node_len(n, 3, 2); b = b.clone().insert(5, "eee".to_string()); @@ -833,22 +833,22 @@ fn insert_test_four() { #[test] fn bsearch_test_one() { - let b = BTree::new(1, "abc".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2u); assert_eq!(Some(1), b.root.bsearch_node(2)); } #[test] fn bsearch_test_two() { - let b = BTree::new(1, "abc".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2u); assert_eq!(Some(0), b.root.bsearch_node(0)); } #[test] fn bsearch_test_three() { - let leaf_elt_1 = LeafElt::new(1, "aaa".to_string()); - let leaf_elt_2 = LeafElt::new(2, "bbb".to_string()); - let leaf_elt_3 = LeafElt::new(4, "ccc".to_string()); - let leaf_elt_4 = LeafElt::new(5, "ddd".to_string()); + let leaf_elt_1 = LeafElt::new(1i, "aaa".to_string()); + let leaf_elt_2 = LeafElt::new(2i, "bbb".to_string()); + let leaf_elt_3 = LeafElt::new(4i, "ccc".to_string()); + let leaf_elt_4 = LeafElt::new(5i, "ddd".to_string()); let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4)); let b = BTree::new_with_node_len(n, 3, 2); assert_eq!(Some(2), b.root.bsearch_node(3)); @@ -856,10 +856,10 @@ fn bsearch_test_three() { #[test] fn bsearch_test_four() { - let leaf_elt_1 = LeafElt::new(1, "aaa".to_string()); - let leaf_elt_2 = LeafElt::new(2, "bbb".to_string()); - let leaf_elt_3 = LeafElt::new(4, "ccc".to_string()); - let leaf_elt_4 = LeafElt::new(5, "ddd".to_string()); + let leaf_elt_1 = LeafElt::new(1i, "aaa".to_string()); + let leaf_elt_2 = LeafElt::new(2i, "bbb".to_string()); + let leaf_elt_3 = LeafElt::new(4i, "ccc".to_string()); + let leaf_elt_4 = LeafElt::new(5i, "ddd".to_string()); let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4)); let b = BTree::new_with_node_len(n, 3, 2); assert_eq!(Some(4), b.root.bsearch_node(800)); @@ -868,7 +868,7 @@ fn bsearch_test_four() { //Tests the functionality of the get method. #[test] fn get_test() { - let b = BTree::new(1, "abc".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); let val = b.get(1); assert_eq!(val, Some("abc".to_string())); } @@ -876,7 +876,7 @@ fn get_test() { //Tests the BTree's clone() method. #[test] fn btree_clone_test() { - let b = BTree::new(1, "abc".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); let b2 = b.clone(); assert!(b.root == b2.root) } @@ -884,31 +884,31 @@ fn btree_clone_test() { //Tests the BTree's cmp() method when one node is "less than" another. #[test] fn btree_cmp_test_less() { - let b = BTree::new(1, "abc".to_string(), 2); - let b2 = BTree::new(2, "bcd".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); + let b2 = BTree::new(2i, "bcd".to_string(), 2); assert!(&b.cmp(&b2) == &Less) } //Tests the BTree's cmp() method when two nodes are equal. #[test] fn btree_cmp_test_eq() { - let b = BTree::new(1, "abc".to_string(), 2); - let b2 = BTree::new(1, "bcd".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); + let b2 = BTree::new(1i, "bcd".to_string(), 2); assert!(&b.cmp(&b2) == &Equal) } //Tests the BTree's cmp() method when one node is "greater than" another. #[test] fn btree_cmp_test_greater() { - let b = BTree::new(1, "abc".to_string(), 2); - let b2 = BTree::new(2, "bcd".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); + let b2 = BTree::new(2i, "bcd".to_string(), 2); assert!(&b2.cmp(&b) == &Greater) } //Tests the BTree's to_str() method. #[test] fn btree_tostr_test() { - let b = BTree::new(1, "abc".to_string(), 2); + let b = BTree::new(1i, "abc".to_string(), 2); assert_eq!(b.to_str(), "Key: 1, value: abc;".to_string()) } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index ac8c5c5557e..0e6cbe4e038 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -693,7 +693,7 @@ fn test_basic() { assert_eq!(m.pop_front(), Some(box 1)); let mut n = DList::new(); - n.push_front(2); + n.push_front(2i); n.push_front(3); { assert_eq!(n.front().unwrap(), &3); @@ -713,7 +713,7 @@ fn test_basic() { #[cfg(test)] fn generate_test() -> DList { - list_from(&[0,1,2,3,4,5,6]) + list_from(&[0i,1,2,3,4,5,6]) } #[cfg(test)] @@ -726,7 +726,7 @@ fn test_append() { { let mut m = DList::new(); let mut n = DList::new(); - n.push_back(2); + n.push_back(2i); m.append(n); assert_eq!(m.len(), 1); assert_eq!(m.pop_back(), Some(2)); @@ -735,15 +735,15 @@ fn test_append() { { let mut m = DList::new(); let n = DList::new(); - m.push_back(2); + m.push_back(2i); m.append(n); assert_eq!(m.len(), 1); assert_eq!(m.pop_back(), Some(2)); check_links(&m); } - let v = vec![1,2,3,4,5]; - let u = vec![9,8,1,2,3,4,5]; + let v = vec![1i,2,3,4,5]; + let u = vec![9i,8,1,2,3,4,5]; let mut m = list_from(v.as_slice()); m.append(list_from(u.as_slice())); check_links(&m); @@ -759,15 +759,15 @@ fn test_prepend() { { let mut m = DList::new(); let mut n = DList::new(); - n.push_back(2); + n.push_back(2i); m.prepend(n); assert_eq!(m.len(), 1); assert_eq!(m.pop_back(), Some(2)); check_links(&m); } - let v = vec![1,2,3,4,5]; - let u = vec![9,8,1,2,3,4,5]; + let v = vec![1i,2,3,4,5]; + let u = vec![9i,8,1,2,3,4,5]; let mut m = list_from(v.as_slice()); m.prepend(list_from(u.as_slice())); check_links(&m); @@ -786,7 +786,7 @@ fn test_rotate() { n.rotate_forward(); check_links(&n); assert_eq!(n.len(), 0); - let v = vec![1,2,3,4,5]; + let v = vec![1i,2,3,4,5]; let mut m = list_from(v.as_slice()); m.rotate_backward(); check_links(&m); m.rotate_forward(); check_links(&m); @@ -798,7 +798,7 @@ fn test_rotate() { m.rotate_backward(); check_links(&m); m.push_front(9); check_links(&m); m.rotate_forward(); check_links(&m); - assert_eq!(vec![3,9,5,1,2], m.move_iter().collect()); + assert_eq!(vec![3i,9,5,1,2], m.move_iter().collect()); } #[test] @@ -809,7 +809,7 @@ fn test_iterator() { } let mut n = DList::new(); assert_eq!(n.iter().next(), None); - n.push_front(4); + n.push_front(4i); let mut it = n.iter(); assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(it.next().unwrap(), &4); @@ -820,7 +820,7 @@ fn test_iterator() { #[test] fn test_iterator_clone() { let mut n = DList::new(); - n.push_back(2); + n.push_back(2i); n.push_back(3); n.push_back(4); let mut it = n.iter(); @@ -835,7 +835,7 @@ fn test_iterator_clone() { fn test_iterator_double_end() { let mut n = DList::new(); assert_eq!(n.iter().next(), None); - n.push_front(4); + n.push_front(4i); n.push_front(5); n.push_front(6); let mut it = n.iter(); @@ -857,7 +857,7 @@ fn test_rev_iter() { } let mut n = DList::new(); assert_eq!(n.iter().rev().next(), None); - n.push_front(4); + n.push_front(4i); let mut it = n.iter().rev(); assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(it.next().unwrap(), &4); @@ -876,7 +876,7 @@ fn test_mut_iter() { assert_eq!(len, 0); let mut n = DList::new(); assert!(n.mut_iter().next().is_none()); - n.push_front(4); + n.push_front(4i); n.push_back(5); let mut it = n.mut_iter(); assert_eq!(it.size_hint(), (2, Some(2))); @@ -890,7 +890,7 @@ fn test_mut_iter() { fn test_iterator_mut_double_end() { let mut n = DList::new(); assert!(n.mut_iter().next_back().is_none()); - n.push_front(4); + n.push_front(4i); n.push_front(5); n.push_front(6); let mut it = n.mut_iter(); @@ -906,7 +906,7 @@ fn test_iterator_mut_double_end() { #[test] fn test_insert_prev() { - let mut m = list_from(&[0,2,4,6,8]); + let mut m = list_from(&[0i,2,4,6,8]); let len = m.len(); { let mut it = m.mut_iter(); @@ -933,8 +933,8 @@ fn test_insert_prev() { #[test] fn test_merge() { - let mut m = list_from([0, 1, 3, 5, 6, 7, 2]); - let n = list_from([-1, 0, 0, 7, 7, 9]); + let mut m = list_from([0i, 1, 3, 5, 6, 7, 2]); + let n = list_from([-1i, 0, 0, 7, 7, 9]); let len = m.len() + n.len(); m.merge(n, |a, b| a <= b); assert_eq!(m.len(), len); @@ -946,12 +946,12 @@ fn test_merge() { #[test] fn test_insert_ordered() { let mut n = DList::new(); - n.insert_ordered(1); + n.insert_ordered(1i); assert_eq!(n.len(), 1); assert_eq!(n.pop_front(), Some(1)); let mut m = DList::new(); - m.push_back(2); + m.push_back(2i); m.push_back(4); m.insert_ordered(3); check_links(&m); @@ -966,7 +966,7 @@ fn test_mut_rev_iter() { } let mut n = DList::new(); assert!(n.mut_iter().rev().next().is_none()); - n.push_front(4); + n.push_front(4i); let mut it = n.mut_iter().rev(); assert!(it.next().is_some()); assert!(it.next().is_none()); @@ -974,7 +974,7 @@ fn test_mut_rev_iter() { #[test] fn test_send() { - let n = list_from([1,2,3]); + let n = list_from([1i,2,3]); spawn(proc() { check_links(&n); assert_eq!(&[&1,&2,&3], n.iter().collect::>().as_slice()); @@ -991,15 +991,15 @@ fn test_eq() { m.push_back(1); assert!(n == m); - let n = list_from([2,3,4]); - let m = list_from([1,2,3]); + let n = list_from([2i,3,4]); + let m = list_from([1i,2,3]); assert!(n != m); } #[test] fn test_ord() { let n: DList = list_from([]); - let m = list_from([1,2,3]); + let m = list_from([1i,2,3]); assert!(n < m); assert!(m > n); assert!(n <= n); @@ -1008,7 +1008,7 @@ fn test_ord() { #[test] fn test_ord_nan() { - let nan = 0.0/0.0; + let nan = 0.0f64/0.0; let n = list_from([nan]); let m = list_from([nan]); assert!(!(n < m)); @@ -1017,21 +1017,21 @@ fn test_ord_nan() { assert!(!(n >= m)); let n = list_from([nan]); - let one = list_from([1.0]); + let one = list_from([1.0f64]); assert!(!(n < one)); assert!(!(n > one)); assert!(!(n <= one)); assert!(!(n >= one)); - let u = list_from([1.0,2.0,nan]); - let v = list_from([1.0,2.0,3.0]); + let u = list_from([1.0f64,2.0,nan]); + let v = list_from([1.0f64,2.0,3.0]); assert!(!(u < v)); assert!(!(u > v)); assert!(!(u <= v)); assert!(!(u >= v)); - let s = list_from([1.0,2.0,4.0,2.0]); - let t = list_from([1.0,2.0,3.0,2.0]); + let s = list_from([1.0f64,2.0,4.0,2.0]); + let t = list_from([1.0f64,2.0,3.0,2.0]); assert!(!(s < t)); assert!(s > one); assert!(!(s <= one)); @@ -1040,7 +1040,7 @@ fn test_ord_nan() { #[test] fn test_fuzz() { - for _ in range(0, 25) { + for _ in range(0u, 25) { fuzz_test(3); fuzz_test(16); fuzz_test(189); @@ -1049,7 +1049,7 @@ fn test_fuzz() { #[test] fn test_show() { - let list: DList = range(0, 10).collect(); + let list: DList = range(0i, 10).collect(); assert!(list.to_str().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let list: DList<&str> = vec!["just", "one", "test", "more"].iter() @@ -1097,7 +1097,7 @@ fn fuzz_test(sz: int) { #[bench] fn bench_collect_into(b: &mut test::Bencher) { - let v = &[0, ..64]; + let v = &[0i, ..64]; b.iter(|| { let _: DList = v.iter().map(|x| *x).collect(); }) @@ -1140,7 +1140,7 @@ fn bench_push_front_pop_front(b: &mut test::Bencher) { #[bench] fn bench_rotate_forward(b: &mut test::Bencher) { let mut m: DList = DList::new(); - m.push_front(0); + m.push_front(0i); m.push_front(1); b.iter(|| { m.rotate_forward(); @@ -1150,7 +1150,7 @@ fn bench_rotate_forward(b: &mut test::Bencher) { #[bench] fn bench_rotate_backward(b: &mut test::Bencher) { let mut m: DList = DList::new(); - m.push_front(0); + m.push_front(0i); m.push_front(1); b.iter(|| { m.rotate_backward(); @@ -1159,7 +1159,7 @@ fn bench_rotate_backward(b: &mut test::Bencher) { #[bench] fn bench_iter(b: &mut test::Bencher) { - let v = &[0, ..128]; + let v = &[0i, ..128]; let m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { assert!(m.iter().count() == 128); @@ -1167,7 +1167,7 @@ fn bench_iter(b: &mut test::Bencher) { } #[bench] fn bench_iter_mut(b: &mut test::Bencher) { - let v = &[0, ..128]; + let v = &[0i, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { assert!(m.mut_iter().count() == 128); @@ -1175,7 +1175,7 @@ fn bench_iter_mut(b: &mut test::Bencher) { } #[bench] fn bench_iter_rev(b: &mut test::Bencher) { - let v = &[0, ..128]; + let v = &[0i, ..128]; let m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { assert!(m.iter().rev().count() == 128); @@ -1183,7 +1183,7 @@ fn bench_iter_rev(b: &mut test::Bencher) { } #[bench] fn bench_iter_mut_rev(b: &mut test::Bencher) { - let v = &[0, ..128]; + let v = &[0i, ..128]; let mut m: DList = v.iter().map(|&x|x).collect(); b.iter(|| { assert!(m.mut_iter().rev().count() == 128); diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index f25864933f2..256621d08e5 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -255,8 +255,8 @@ mod tests { #[test] fn test_iterator() { - let data = vec!(5, 9, 3); - let iterout = [9, 5, 3]; + let data = vec!(5i, 9, 3); + let iterout = [9i, 5, 3]; let pq = PriorityQueue::from_vec(data); let mut i = 0; for el in pq.iter() { @@ -279,7 +279,7 @@ fn test_top_and_pop() { #[test] fn test_push() { - let mut heap = PriorityQueue::from_vec(vec!(2, 4, 9)); + let mut heap = PriorityQueue::from_vec(vec!(2i, 4, 9)); assert_eq!(heap.len(), 3); assert!(*heap.top().unwrap() == 9); heap.push(11); @@ -301,7 +301,7 @@ fn test_push() { #[test] fn test_push_unique() { - let mut heap = PriorityQueue::from_vec(vec!(box 2, box 4, box 9)); + let mut heap = PriorityQueue::from_vec(vec!(box 2i, box 4, box 9)); assert_eq!(heap.len(), 3); assert!(*heap.top().unwrap() == box 9); heap.push(box 11); @@ -323,7 +323,7 @@ fn test_push_unique() { #[test] fn test_push_pop() { - let mut heap = PriorityQueue::from_vec(vec!(5, 5, 2, 1, 3)); + let mut heap = PriorityQueue::from_vec(vec!(5i, 5, 2, 1, 3)); assert_eq!(heap.len(), 5); assert_eq!(heap.push_pop(6), 6); assert_eq!(heap.len(), 5); @@ -337,7 +337,7 @@ fn test_push_pop() { #[test] fn test_replace() { - let mut heap = PriorityQueue::from_vec(vec!(5, 5, 2, 1, 3)); + let mut heap = PriorityQueue::from_vec(vec!(5i, 5, 2, 1, 3)); assert_eq!(heap.len(), 5); assert_eq!(heap.replace(6).unwrap(), 5); assert_eq!(heap.len(), 5); @@ -362,18 +362,18 @@ fn check_to_vec(mut data: Vec) { #[test] fn test_to_vec() { check_to_vec(vec!()); - check_to_vec(vec!(5)); - check_to_vec(vec!(3, 2)); - check_to_vec(vec!(2, 3)); - check_to_vec(vec!(5, 1, 2)); - check_to_vec(vec!(1, 100, 2, 3)); - check_to_vec(vec!(1, 3, 5, 7, 9, 2, 4, 6, 8, 0)); - check_to_vec(vec!(2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1)); - check_to_vec(vec!(9, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0)); - check_to_vec(vec!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); - check_to_vec(vec!(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)); - check_to_vec(vec!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2)); - check_to_vec(vec!(5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1)); + check_to_vec(vec!(5i)); + check_to_vec(vec!(3i, 2)); + check_to_vec(vec!(2i, 3)); + check_to_vec(vec!(5i, 1, 2)); + check_to_vec(vec!(1i, 100, 2, 3)); + check_to_vec(vec!(1i, 3, 5, 7, 9, 2, 4, 6, 8, 0)); + check_to_vec(vec!(2i, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1)); + check_to_vec(vec!(9i, 11, 9, 9, 9, 9, 11, 2, 3, 4, 11, 9, 0, 0, 0, 0)); + check_to_vec(vec!(0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); + check_to_vec(vec!(10i, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)); + check_to_vec(vec!(0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 1, 2)); + check_to_vec(vec!(5i, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1)); } #[test] diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index d7b092b9c1c..be0d603696b 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -431,8 +431,8 @@ mod tests { fn test_simple() { let mut d = RingBuf::new(); assert_eq!(d.len(), 0u); - d.push_front(17); - d.push_front(42); + d.push_front(17i); + d.push_front(42i); d.push_back(137); assert_eq!(d.len(), 3u); d.push_back(137); @@ -588,7 +588,7 @@ fn bench_push_front(b: &mut test::Bencher) { fn bench_grow(b: &mut test::Bencher) { let mut deq = RingBuf::new(); b.iter(|| { - for _ in range(0, 65) { + for _ in range(0i, 65) { deq.push_front(1); } }) @@ -684,7 +684,7 @@ fn test_reserve() { #[test] fn test_swap() { - let mut d: RingBuf = range(0, 5).collect(); + let mut d: RingBuf = range(0i, 5).collect(); d.pop_front(); d.swap(0, 3); assert_eq!(d.iter().map(|&x|x).collect::>(), vec!(4, 2, 3, 1)); @@ -696,12 +696,12 @@ fn test_iter() { assert_eq!(d.iter().next(), None); assert_eq!(d.iter().size_hint(), (0, Some(0))); - for i in range(0, 5) { + for i in range(0i, 5) { d.push_back(i); } assert_eq!(d.iter().collect::>().as_slice(), &[&0,&1,&2,&3,&4]); - for i in range(6, 9) { + for i in range(6i, 9) { d.push_front(i); } assert_eq!(d.iter().collect::>().as_slice(), &[&8,&7,&6,&0,&1,&2,&3,&4]); @@ -721,12 +721,12 @@ fn test_rev_iter() { let mut d = RingBuf::new(); assert_eq!(d.iter().rev().next(), None); - for i in range(0, 5) { + for i in range(0i, 5) { d.push_back(i); } assert_eq!(d.iter().rev().collect::>().as_slice(), &[&4,&3,&2,&1,&0]); - for i in range(6, 9) { + for i in range(6i, 9) { d.push_front(i); } assert_eq!(d.iter().rev().collect::>().as_slice(), &[&4,&3,&2,&1,&0,&6,&7,&8]); @@ -737,7 +737,7 @@ fn test_mut_rev_iter_wrap() { let mut d = RingBuf::with_capacity(3); assert!(d.mut_iter().rev().next().is_none()); - d.push_back(1); + d.push_back(1i); d.push_back(2); d.push_back(3); assert_eq!(d.pop_front(), Some(1)); @@ -796,7 +796,7 @@ fn test_mut_rev_iter() { #[test] fn test_from_iter() { use std::iter; - let v = vec!(1,2,3,4,5,6,7); + let v = vec!(1i,2,3,4,5,6,7); let deq: RingBuf = v.iter().map(|&x| x).collect(); let u: Vec = deq.iter().map(|&x| x).collect(); assert_eq!(u, v); @@ -812,7 +812,7 @@ fn test_from_iter() { #[test] fn test_clone() { let mut d = RingBuf::new(); - d.push_front(17); + d.push_front(17i); d.push_front(42); d.push_back(137); d.push_back(137); @@ -830,7 +830,7 @@ fn test_clone() { fn test_eq() { let mut d = RingBuf::new(); assert!(d == RingBuf::with_capacity(0)); - d.push_front(137); + d.push_front(137i); d.push_front(17); d.push_front(42); d.push_back(137); @@ -849,7 +849,7 @@ fn test_eq() { #[test] fn test_show() { - let ringbuf: RingBuf = range(0, 10).collect(); + let ringbuf: RingBuf = range(0i, 10).collect(); assert!(format!("{}", ringbuf).as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter() diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index f9826fcd228..ac8ac6102f3 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -75,7 +75,7 @@ type of the vector is `int`, the element type of the iterator is `&int`. ```rust -let numbers = [0, 1, 2]; +let numbers = [0i, 1i, 2i]; for &x in numbers.iter() { println!("{} is a number!", x); } @@ -597,10 +597,10 @@ pub trait MutableOrdVector { /// # Example /// /// ```rust - /// let mut v = [-5, 4, 1, -3, 2]; + /// let mut v = [-5i, 4, 1, -3, 2]; /// /// v.sort(); - /// assert!(v == [-5, -3, 1, 2, 4]); + /// assert!(v == [-5i, -3, 1, 2, 4]); /// ``` fn sort(self); @@ -611,11 +611,11 @@ pub trait MutableOrdVector { /// # Example /// /// ```rust - /// let v = &mut [0, 1, 2]; + /// let v = &mut [0i, 1, 2]; /// v.next_permutation(); - /// assert_eq!(v, &mut [0, 2, 1]); + /// assert_eq!(v, &mut [0i, 2, 1]); /// v.next_permutation(); - /// assert_eq!(v, &mut [1, 0, 2]); + /// assert_eq!(v, &mut [1i, 0, 2]); /// ``` fn next_permutation(self) -> bool; @@ -626,11 +626,11 @@ pub trait MutableOrdVector { /// # Example /// /// ```rust - /// let v = &mut [1, 0, 2]; + /// let v = &mut [1i, 0, 2]; /// v.prev_permutation(); - /// assert_eq!(v, &mut [0, 2, 1]); + /// assert_eq!(v, &mut [0i, 2, 1]); /// v.prev_permutation(); - /// assert_eq!(v, &mut [0, 1, 2]); + /// assert_eq!(v, &mut [0i, 1, 2]); /// ``` fn prev_permutation(self) -> bool; } @@ -796,11 +796,11 @@ fn test_len_divzero() { #[test] fn test_get() { - let mut a = vec![11]; + let mut a = vec![11i]; assert_eq!(a.as_slice().get(1), None); - a = vec![11, 12]; + a = vec![11i, 12]; assert_eq!(a.as_slice().get(1).unwrap(), &12); - a = vec![11, 12, 13]; + a = vec![11i, 12, 13]; assert_eq!(a.as_slice().get(1).unwrap(), &12); } @@ -808,17 +808,17 @@ fn test_get() { fn test_head() { let mut a = vec![]; assert_eq!(a.as_slice().head(), None); - a = vec![11]; + a = vec![11i]; assert_eq!(a.as_slice().head().unwrap(), &11); - a = vec![11, 12]; + a = vec![11i, 12]; assert_eq!(a.as_slice().head().unwrap(), &11); } #[test] fn test_tail() { - let mut a = vec![11]; + let mut a = vec![11i]; assert_eq!(a.tail(), &[]); - a = vec![11, 12]; + a = vec![11i, 12]; assert_eq!(a.tail(), &[12]); } @@ -831,9 +831,9 @@ fn test_tail_empty() { #[test] fn test_tailn() { - let mut a = vec![11, 12, 13]; + let mut a = vec![11i, 12, 13]; assert_eq!(a.tailn(0), &[11, 12, 13]); - a = vec![11, 12, 13]; + a = vec![11i, 12, 13]; assert_eq!(a.tailn(2), &[13]); } @@ -846,9 +846,9 @@ fn test_tailn_empty() { #[test] fn test_init() { - let mut a = vec![11]; + let mut a = vec![11i]; assert_eq!(a.init(), &[]); - a = vec![11, 12]; + a = vec![11i, 12]; assert_eq!(a.init(), &[11]); } @@ -861,9 +861,9 @@ fn test_init_empty() { #[test] fn test_initn() { - let mut a = vec![11, 12, 13]; + let mut a = vec![11i, 12, 13]; assert_eq!(a.as_slice().initn(0), &[11, 12, 13]); - a = vec![11, 12, 13]; + a = vec![11i, 12, 13]; assert_eq!(a.as_slice().initn(2), &[11]); } @@ -878,16 +878,16 @@ fn test_initn_empty() { fn test_last() { let mut a = vec![]; assert_eq!(a.as_slice().last(), None); - a = vec![11]; + a = vec![11i]; assert_eq!(a.as_slice().last().unwrap(), &11); - a = vec![11, 12]; + a = vec![11i, 12]; assert_eq!(a.as_slice().last().unwrap(), &12); } #[test] fn test_slice() { // Test fixed length vector. - let vec_fixed = [1, 2, 3, 4]; + let vec_fixed = [1i, 2, 3, 4]; let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_owned(); assert_eq!(v_a.len(), 3u); let v_a = v_a.as_slice(); @@ -896,7 +896,7 @@ fn test_slice() { assert_eq!(v_a[2], 4); // Test on stack. - let vec_stack = &[1, 2, 3]; + let vec_stack = &[1i, 2, 3]; let v_b = vec_stack.slice(1u, 3u).to_owned(); assert_eq!(v_b.len(), 2u); let v_b = v_b.as_slice(); @@ -904,7 +904,7 @@ fn test_slice() { assert_eq!(v_b[1], 3); // Test `Box<[T]>` - let vec_unique = vec![1, 2, 3, 4, 5, 6]; + let vec_unique = vec![1i, 2, 3, 4, 5, 6]; let v_d = vec_unique.slice(1u, 6u).to_owned(); assert_eq!(v_d.len(), 5u); let v_d = v_d.as_slice(); @@ -917,7 +917,7 @@ fn test_slice() { #[test] fn test_slice_from() { - let vec = &[1, 2, 3, 4]; + let vec = &[1i, 2, 3, 4]; assert_eq!(vec.slice_from(0), vec); assert_eq!(vec.slice_from(2), &[3, 4]); assert_eq!(vec.slice_from(4), &[]); @@ -925,7 +925,7 @@ fn test_slice_from() { #[test] fn test_slice_to() { - let vec = &[1, 2, 3, 4]; + let vec = &[1i, 2, 3, 4]; assert_eq!(vec.slice_to(4), vec); assert_eq!(vec.slice_to(2), &[1, 2]); assert_eq!(vec.slice_to(0), &[]); @@ -934,7 +934,7 @@ fn test_slice_to() { #[test] fn test_pop() { - let mut v = vec![5]; + let mut v = vec![5i]; let e = v.pop(); assert_eq!(v.len(), 0); assert_eq!(e, Some(5)); @@ -946,17 +946,17 @@ fn test_pop() { #[test] fn test_swap_remove() { - let mut v = vec![1, 2, 3, 4, 5]; + let mut v = vec![1i, 2, 3, 4, 5]; let mut e = v.swap_remove(0); assert_eq!(e, Some(1)); - assert_eq!(v, vec![5, 2, 3, 4]); + assert_eq!(v, vec![5i, 2, 3, 4]); e = v.swap_remove(3); assert_eq!(e, Some(4)); - assert_eq!(v, vec![5, 2, 3]); + assert_eq!(v, vec![5i, 2, 3]); e = v.swap_remove(3); assert_eq!(e, None); - assert_eq!(v, vec![5, 2, 3]); + assert_eq!(v, vec![5i, 2, 3]); } #[test] @@ -977,12 +977,12 @@ fn test_swap_remove_noncopyable() { fn test_push() { // Test on-stack push(). let mut v = vec![]; - v.push(1); + v.push(1i); assert_eq!(v.len(), 1u); assert_eq!(v.as_slice()[0], 1); // Test on-heap push(). - v.push(2); + v.push(2i); assert_eq!(v.len(), 2u); assert_eq!(v.as_slice()[0], 1); assert_eq!(v.as_slice()[1], 2); @@ -992,7 +992,7 @@ fn test_push() { fn test_grow() { // Test on-stack grow(). let mut v = vec![]; - v.grow(2u, &1); + v.grow(2u, &1i); { let v = v.as_slice(); assert_eq!(v.len(), 2u); @@ -1001,7 +1001,7 @@ fn test_grow() { } // Test on-heap grow(). - v.grow(3u, &2); + v.grow(3u, &2i); { let v = v.as_slice(); assert_eq!(v.len(), 5u); @@ -1026,7 +1026,7 @@ fn test_grow_fn() { #[test] fn test_grow_set() { - let mut v = vec![1, 2, 3]; + let mut v = vec![1i, 2, 3]; v.grow_set(4u, &4, 5); let v = v.as_slice(); assert_eq!(v.len(), 5u); @@ -1039,7 +1039,7 @@ fn test_grow_set() { #[test] fn test_truncate() { - let mut v = vec![box 6,box 5,box 4]; + let mut v = vec![box 6i,box 5,box 4]; v.truncate(1); let v = v.as_slice(); assert_eq!(v.len(), 1); @@ -1049,7 +1049,7 @@ fn test_truncate() { #[test] fn test_clear() { - let mut v = vec![box 6,box 5,box 4]; + let mut v = vec![box 6i,box 5,box 4]; v.clear(); assert_eq!(v.len(), 0); // If the unsafe block didn't drop things properly, we blow up here. @@ -1063,22 +1063,22 @@ fn case(a: Vec, b: Vec) { assert_eq!(v, b); } case(vec![], vec![]); - case(vec![1], vec![1]); - case(vec![1,1], vec![1]); - case(vec![1,2,3], vec![1,2,3]); - case(vec![1,1,2,3], vec![1,2,3]); - case(vec![1,2,2,3], vec![1,2,3]); - case(vec![1,2,3,3], vec![1,2,3]); - case(vec![1,1,2,2,2,3,3], vec![1,2,3]); + case(vec![1u], vec![1]); + case(vec![1u,1], vec![1]); + case(vec![1u,2,3], vec![1,2,3]); + case(vec![1u,1,2,3], vec![1,2,3]); + case(vec![1u,2,2,3], vec![1,2,3]); + case(vec![1u,2,3,3], vec![1,2,3]); + case(vec![1u,1,2,2,2,3,3], vec![1,2,3]); } #[test] fn test_dedup_unique() { - let mut v0 = vec![box 1, box 1, box 2, box 3]; + let mut v0 = vec![box 1i, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![box 1, box 2, box 2, box 3]; + let mut v1 = vec![box 1i, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![box 1, box 2, box 3, box 3]; + let mut v2 = vec![box 1i, box 2, box 3, box 3]; v2.dedup(); /* * If the boxed pointers were leaked or otherwise misused, valgrind @@ -1088,11 +1088,11 @@ fn test_dedup_unique() { #[test] fn test_dedup_shared() { - let mut v0 = vec![box 1, box 1, box 2, box 3]; + let mut v0 = vec![box 1i, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![box 1, box 2, box 2, box 3]; + let mut v1 = vec![box 1i, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![box 1, box 2, box 3, box 3]; + let mut v2 = vec![box 1i, box 2, box 3, box 3]; v2.dedup(); /* * If the pointers were leaked or otherwise misused, valgrind and/or @@ -1102,14 +1102,14 @@ fn test_dedup_shared() { #[test] fn test_retain() { - let mut v = vec![1, 2, 3, 4, 5]; + let mut v = vec![1u, 2, 3, 4, 5]; v.retain(is_odd); - assert_eq!(v, vec![1, 3, 5]); + assert_eq!(v, vec![1u, 3, 5]); } #[test] fn test_element_swaps() { - let mut v = [1, 2, 3]; + let mut v = [1i, 2, 3]; for (i, (a, b)) in ElementSwaps::new(v.len()).enumerate() { v.swap(a, b); match i { @@ -1145,7 +1145,7 @@ fn test_permutations() { assert_eq!(it.next(), None); } { - let v = [1, 2, 3]; + let v = [1i, 2, 3]; let mut it = v.permutations(); let (min_size, max_opt) = it.size_hint(); assert_eq!(min_size, 3*2); @@ -1179,7 +1179,7 @@ fn test_permutations() { #[test] fn test_lexicographic_permutations() { - let v : &mut[int] = &mut[1, 2, 3, 4, 5]; + let v : &mut[int] = &mut[1i, 2, 3, 4, 5]; assert!(v.prev_permutation() == false); assert!(v.next_permutation()); assert_eq!(v, &mut[1, 2, 3, 5, 4]); @@ -1191,7 +1191,7 @@ fn test_lexicographic_permutations() { assert!(v.next_permutation()); assert_eq!(v, &mut[1, 2, 4, 5, 3]); - let v : &mut[int] = &mut[1, 0, 0, 0]; + let v : &mut[int] = &mut[1i, 0, 0, 0]; assert!(v.next_permutation() == false); assert!(v.prev_permutation()); assert_eq!(v, &mut[0, 1, 0, 0]); @@ -1210,13 +1210,13 @@ fn test_lexicographic_permutations_empty_and_short() { assert!(empty.prev_permutation() == false); assert_eq!(empty, &mut[]); - let one_elem : &mut[int] = &mut[4]; + let one_elem : &mut[int] = &mut[4i]; assert!(one_elem.prev_permutation() == false); assert_eq!(one_elem, &mut[4]); assert!(one_elem.next_permutation() == false); assert_eq!(one_elem, &mut[4]); - let two_elem : &mut[int] = &mut[1, 2]; + let two_elem : &mut[int] = &mut[1i, 2]; assert!(two_elem.prev_permutation() == false); assert_eq!(two_elem, &mut[1, 2]); assert!(two_elem.next_permutation()); @@ -1231,9 +1231,9 @@ fn test_lexicographic_permutations_empty_and_short() { #[test] fn test_position_elem() { - assert!([].position_elem(&1).is_none()); + assert!([].position_elem(&1i).is_none()); - let v1 = vec![1, 2, 3, 3, 2, 5]; + let v1 = vec![1i, 2, 3, 3, 2, 5]; assert_eq!(v1.as_slice().position_elem(&1), Some(0u)); assert_eq!(v1.as_slice().position_elem(&2), Some(1u)); assert_eq!(v1.as_slice().position_elem(&5), Some(5u)); @@ -1242,52 +1242,52 @@ fn test_position_elem() { #[test] fn test_bsearch_elem() { - assert_eq!([1,2,3,4,5].bsearch_elem(&5), Some(4)); - assert_eq!([1,2,3,4,5].bsearch_elem(&4), Some(3)); - assert_eq!([1,2,3,4,5].bsearch_elem(&3), Some(2)); - assert_eq!([1,2,3,4,5].bsearch_elem(&2), Some(1)); - assert_eq!([1,2,3,4,5].bsearch_elem(&1), Some(0)); + assert_eq!([1i,2,3,4,5].bsearch_elem(&5), Some(4)); + assert_eq!([1i,2,3,4,5].bsearch_elem(&4), Some(3)); + assert_eq!([1i,2,3,4,5].bsearch_elem(&3), Some(2)); + assert_eq!([1i,2,3,4,5].bsearch_elem(&2), Some(1)); + assert_eq!([1i,2,3,4,5].bsearch_elem(&1), Some(0)); - assert_eq!([2,4,6,8,10].bsearch_elem(&1), None); - assert_eq!([2,4,6,8,10].bsearch_elem(&5), None); - assert_eq!([2,4,6,8,10].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6,8,10].bsearch_elem(&10), Some(4)); + assert_eq!([2i,4,6,8,10].bsearch_elem(&1), None); + assert_eq!([2i,4,6,8,10].bsearch_elem(&5), None); + assert_eq!([2i,4,6,8,10].bsearch_elem(&4), Some(1)); + assert_eq!([2i,4,6,8,10].bsearch_elem(&10), Some(4)); - assert_eq!([2,4,6,8].bsearch_elem(&1), None); - assert_eq!([2,4,6,8].bsearch_elem(&5), None); - assert_eq!([2,4,6,8].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6,8].bsearch_elem(&8), Some(3)); + assert_eq!([2i,4,6,8].bsearch_elem(&1), None); + assert_eq!([2i,4,6,8].bsearch_elem(&5), None); + assert_eq!([2i,4,6,8].bsearch_elem(&4), Some(1)); + assert_eq!([2i,4,6,8].bsearch_elem(&8), Some(3)); - assert_eq!([2,4,6].bsearch_elem(&1), None); - assert_eq!([2,4,6].bsearch_elem(&5), None); - assert_eq!([2,4,6].bsearch_elem(&4), Some(1)); - assert_eq!([2,4,6].bsearch_elem(&6), Some(2)); + assert_eq!([2i,4,6].bsearch_elem(&1), None); + assert_eq!([2i,4,6].bsearch_elem(&5), None); + assert_eq!([2i,4,6].bsearch_elem(&4), Some(1)); + assert_eq!([2i,4,6].bsearch_elem(&6), Some(2)); - assert_eq!([2,4].bsearch_elem(&1), None); - assert_eq!([2,4].bsearch_elem(&5), None); - assert_eq!([2,4].bsearch_elem(&2), Some(0)); - assert_eq!([2,4].bsearch_elem(&4), Some(1)); + assert_eq!([2i,4].bsearch_elem(&1), None); + assert_eq!([2i,4].bsearch_elem(&5), None); + assert_eq!([2i,4].bsearch_elem(&2), Some(0)); + assert_eq!([2i,4].bsearch_elem(&4), Some(1)); - assert_eq!([2].bsearch_elem(&1), None); - assert_eq!([2].bsearch_elem(&5), None); - assert_eq!([2].bsearch_elem(&2), Some(0)); + assert_eq!([2i].bsearch_elem(&1), None); + assert_eq!([2i].bsearch_elem(&5), None); + assert_eq!([2i].bsearch_elem(&2), Some(0)); - assert_eq!([].bsearch_elem(&1), None); - assert_eq!([].bsearch_elem(&5), None); + assert_eq!([].bsearch_elem(&1i), None); + assert_eq!([].bsearch_elem(&5i), None); - assert!([1,1,1,1,1].bsearch_elem(&1) != None); - assert!([1,1,1,1,2].bsearch_elem(&1) != None); - assert!([1,1,1,2,2].bsearch_elem(&1) != None); - assert!([1,1,2,2,2].bsearch_elem(&1) != None); - assert_eq!([1,2,2,2,2].bsearch_elem(&1), Some(0)); + assert!([1i,1,1,1,1].bsearch_elem(&1) != None); + assert!([1i,1,1,1,2].bsearch_elem(&1) != None); + assert!([1i,1,1,2,2].bsearch_elem(&1) != None); + assert!([1i,1,2,2,2].bsearch_elem(&1) != None); + assert_eq!([1i,2,2,2,2].bsearch_elem(&1), Some(0)); - assert_eq!([1,2,3,4,5].bsearch_elem(&6), None); - assert_eq!([1,2,3,4,5].bsearch_elem(&0), None); + assert_eq!([1i,2,3,4,5].bsearch_elem(&6), None); + assert_eq!([1i,2,3,4,5].bsearch_elem(&0), None); } #[test] fn test_reverse() { - let mut v: Vec = vec![10, 20]; + let mut v: Vec = vec![10i, 20]; assert_eq!(*v.get(0), 10); assert_eq!(*v.get(1), 20); v.reverse(); @@ -1302,7 +1302,7 @@ fn test_reverse() { #[test] fn test_sort() { for len in range(4u, 25) { - for _ in range(0, 100) { + for _ in range(0i, 100) { let mut v = task_rng().gen_iter::().take(len) .collect::>(); let mut v1 = v.clone(); @@ -1329,9 +1329,9 @@ fn test_sort() { #[test] fn test_sort_stability() { - for len in range(4, 25) { - for _ in range(0 , 10) { - let mut counts = [0, .. 10]; + for len in range(4i, 25) { + for _ in range(0u, 10) { + let mut counts = [0i, .. 10]; // create a vector like [(6, 1), (5, 1), (6, 2), ...], // where the first item of each tuple is random, but @@ -1361,44 +1361,44 @@ fn test_sort_stability() { #[test] fn test_partition() { assert_eq!((vec![]).partition(|x: &int| *x < 3), (vec![], vec![])); - assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); - assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 2), (vec![1], vec![2, 3])); - assert_eq!((vec![1, 2, 3]).partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); + assert_eq!((vec![1i, 2, 3]).partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); + assert_eq!((vec![1i, 2, 3]).partition(|x: &int| *x < 2), (vec![1], vec![2, 3])); + assert_eq!((vec![1i, 2, 3]).partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); } #[test] fn test_partitioned() { assert_eq!(([]).partitioned(|x: &int| *x < 3), (vec![], vec![])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); + assert_eq!(([1i, 2, 3]).partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); + assert_eq!(([1i, 2, 3]).partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3])); + assert_eq!(([1i, 2, 3]).partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); } #[test] fn test_concat() { let v: [Vec, ..0] = []; assert_eq!(v.concat_vec(), vec![]); - assert_eq!([vec![1], vec![2,3]].concat_vec(), vec![1, 2, 3]); + assert_eq!([vec![1i], vec![2i,3i]].concat_vec(), vec![1, 2, 3]); - assert_eq!([&[1], &[2,3]].concat_vec(), vec![1, 2, 3]); + assert_eq!([&[1i], &[2i,3i]].concat_vec(), vec![1, 2, 3]); } #[test] fn test_connect() { let v: [Vec, ..0] = []; assert_eq!(v.connect_vec(&0), vec![]); - assert_eq!([vec![1], vec![2, 3]].connect_vec(&0), vec![1, 0, 2, 3]); - assert_eq!([vec![1], vec![2], vec![3]].connect_vec(&0), vec![1, 0, 2, 0, 3]); + assert_eq!([vec![1i], vec![2i, 3]].connect_vec(&0), vec![1, 0, 2, 3]); + assert_eq!([vec![1i], vec![2i], vec![3i]].connect_vec(&0), vec![1, 0, 2, 0, 3]); - assert_eq!([&[1], &[2, 3]].connect_vec(&0), vec![1, 0, 2, 3]); - assert_eq!([&[1], &[2], &[3]].connect_vec(&0), vec![1, 0, 2, 0, 3]); + assert_eq!([&[1i], &[2i, 3]].connect_vec(&0), vec![1, 0, 2, 3]); + assert_eq!([&[1i], &[2i], &[3]].connect_vec(&0), vec![1, 0, 2, 0, 3]); } #[test] fn test_shift() { - let mut x = vec![1, 2, 3]; + let mut x = vec![1i, 2, 3]; assert_eq!(x.shift(), Some(1)); - assert_eq!(&x, &vec![2, 3]); + assert_eq!(&x, &vec![2i, 3]); assert_eq!(x.shift(), Some(2)); assert_eq!(x.shift(), Some(3)); assert_eq!(x.shift(), None); @@ -1407,52 +1407,52 @@ fn test_shift() { #[test] fn test_unshift() { - let mut x = vec![1, 2, 3]; + let mut x = vec![1i, 2, 3]; x.unshift(0); assert_eq!(x, vec![0, 1, 2, 3]); } #[test] fn test_insert() { - let mut a = vec![1, 2, 4]; + let mut a = vec![1i, 2, 4]; a.insert(2, 3); assert_eq!(a, vec![1, 2, 3, 4]); - let mut a = vec![1, 2, 3]; + let mut a = vec![1i, 2, 3]; a.insert(0, 0); assert_eq!(a, vec![0, 1, 2, 3]); - let mut a = vec![1, 2, 3]; + let mut a = vec![1i, 2, 3]; a.insert(3, 4); assert_eq!(a, vec![1, 2, 3, 4]); let mut a = vec![]; - a.insert(0, 1); + a.insert(0, 1i); assert_eq!(a, vec![1]); } #[test] #[should_fail] fn test_insert_oob() { - let mut a = vec![1, 2, 3]; + let mut a = vec![1i, 2, 3]; a.insert(4, 5); } #[test] fn test_remove() { - let mut a = vec![1,2,3,4]; + let mut a = vec![1i,2,3,4]; assert_eq!(a.remove(2), Some(3)); - assert_eq!(a, vec![1,2,4]); + assert_eq!(a, vec![1i,2,4]); assert_eq!(a.remove(2), Some(4)); - assert_eq!(a, vec![1,2]); + assert_eq!(a, vec![1i,2]); assert_eq!(a.remove(2), None); - assert_eq!(a, vec![1,2]); + assert_eq!(a, vec![1i,2]); assert_eq!(a.remove(0), Some(1)); - assert_eq!(a, vec![2]); + assert_eq!(a, vec![2i]); assert_eq!(a.remove(0), Some(2)); assert_eq!(a, vec![]); @@ -1473,7 +1473,7 @@ fn test_capacity() { #[test] fn test_slice_2() { - let v = vec![1, 2, 3, 4, 5]; + let v = vec![1i, 2, 3, 4, 5]; let v = v.slice(1u, 3u); assert_eq!(v.len(), 2u); assert_eq!(v[0], 2); @@ -1486,7 +1486,7 @@ fn test_slice_2() { fn test_from_fn_fail() { Vec::from_fn(100, |v| { if v == 50 { fail!() } - box 0 + box 0i }); } @@ -1519,15 +1519,15 @@ fn test_grow_fn_fail() { if i == 50 { fail!() } - (box 0, Rc::new(0)) + (box 0i, Rc::new(0i)) }) } #[test] #[should_fail] fn test_permute_fail() { - let v = [(box 0, Rc::new(0)), (box 0, Rc::new(0)), - (box 0, Rc::new(0)), (box 0, Rc::new(0))]; + let v = [(box 0i, Rc::new(0i)), (box 0i, Rc::new(0i)), + (box 0i, Rc::new(0i)), (box 0i, Rc::new(0i))]; let mut i = 0; for _ in v.permutations() { if i == 2 { @@ -1541,24 +1541,24 @@ fn test_permute_fail() { #[should_fail] fn test_copy_memory_oob() { unsafe { - let mut a = [1, 2, 3, 4]; - let b = [1, 2, 3, 4, 5]; + let mut a = [1i, 2, 3, 4]; + let b = [1i, 2, 3, 4, 5]; a.copy_memory(b); } } #[test] fn test_total_ord() { - [1, 2, 3, 4].cmp(& &[1, 2, 3]) == Greater; - [1, 2, 3].cmp(& &[1, 2, 3, 4]) == Less; - [1, 2, 3, 4].cmp(& &[1, 2, 3, 4]) == Equal; - [1, 2, 3, 4, 5, 5, 5, 5].cmp(& &[1, 2, 3, 4, 5, 6]) == Less; - [2, 2].cmp(& &[1, 2, 3, 4]) == Greater; + [1i, 2, 3, 4].cmp(& &[1, 2, 3]) == Greater; + [1i, 2, 3].cmp(& &[1, 2, 3, 4]) == Less; + [1i, 2, 3, 4].cmp(& &[1, 2, 3, 4]) == Equal; + [1i, 2, 3, 4, 5, 5, 5, 5].cmp(& &[1, 2, 3, 4, 5, 6]) == Less; + [2i, 2].cmp(& &[1, 2, 3, 4]) == Greater; } #[test] fn test_iterator() { - let xs = [1, 2, 5, 10, 11]; + let xs = [1i, 2, 5, 10, 11]; let mut it = xs.iter(); assert_eq!(it.size_hint(), (5, Some(5))); assert_eq!(it.next().unwrap(), &1); @@ -1576,7 +1576,7 @@ fn test_iterator() { #[test] fn test_random_access_iterator() { - let xs = [1, 2, 5, 10, 11]; + let xs = [1i, 2, 5, 10, 11]; let mut it = xs.iter(); assert_eq!(it.indexable(), 5); @@ -1614,14 +1614,14 @@ fn test_random_access_iterator() { #[test] fn test_iter_size_hints() { - let mut xs = [1, 2, 5, 10, 11]; + let mut xs = [1i, 2, 5, 10, 11]; assert_eq!(xs.iter().size_hint(), (5, Some(5))); assert_eq!(xs.mut_iter().size_hint(), (5, Some(5))); } #[test] fn test_iter_clone() { - let xs = [1, 2, 5]; + let xs = [1i, 2, 5]; let mut it = xs.iter(); it.next(); let mut jt = it.clone(); @@ -1632,7 +1632,7 @@ fn test_iter_clone() { #[test] fn test_mut_iterator() { - let mut xs = [1, 2, 3, 4, 5]; + let mut xs = [1i, 2, 3, 4, 5]; for x in xs.mut_iter() { *x += 1; } @@ -1642,7 +1642,7 @@ fn test_mut_iterator() { #[test] fn test_rev_iterator() { - let xs = [1, 2, 5, 10, 11]; + let xs = [1i, 2, 5, 10, 11]; let ys = [11, 10, 5, 2, 1]; let mut i = 0; for &x in xs.iter().rev() { @@ -1781,39 +1781,39 @@ fn test_chunksator_0() { #[test] fn test_move_from() { - let mut a = [1,2,3,4,5]; - let b = vec![6,7,8]; + let mut a = [1i,2,3,4,5]; + let b = vec![6i,7,8]; assert_eq!(a.move_from(b, 0, 3), 3); - assert!(a == [6,7,8,4,5]); - let mut a = [7,2,8,1]; - let b = vec![3,1,4,1,5,9]; + assert!(a == [6i,7,8,4,5]); + let mut a = [7i,2,8,1]; + let b = vec![3i,1,4,1,5,9]; assert_eq!(a.move_from(b, 0, 6), 4); - assert!(a == [3,1,4,1]); - let mut a = [1,2,3,4]; - let b = vec![5,6,7,8,9,0]; + assert!(a == [3i,1,4,1]); + let mut a = [1i,2,3,4]; + let b = vec![5i,6,7,8,9,0]; assert_eq!(a.move_from(b, 2, 3), 1); - assert!(a == [7,2,3,4]); - let mut a = [1,2,3,4,5]; - let b = vec![5,6,7,8,9,0]; + assert!(a == [7i,2,3,4]); + let mut a = [1i,2,3,4,5]; + let b = vec![5i,6,7,8,9,0]; assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); - assert!(a == [1,2,6,7,5]); + assert!(a == [1i,2,6,7,5]); } #[test] fn test_copy_from() { - let mut a = [1,2,3,4,5]; - let b = [6,7,8]; + let mut a = [1i,2,3,4,5]; + let b = [6i,7,8]; assert_eq!(a.copy_from(b), 3); - assert!(a == [6,7,8,4,5]); - let mut c = [7,2,8,1]; - let d = [3,1,4,1,5,9]; + assert!(a == [6i,7,8,4,5]); + let mut c = [7i,2,8,1]; + let d = [3i,1,4,1,5,9]; assert_eq!(c.copy_from(d), 4); - assert!(c == [3,1,4,1]); + assert!(c == [3i,1,4,1]); } #[test] fn test_reverse_part() { - let mut values = [1,2,3,4,5]; + let mut values = [1i,2,3,4,5]; values.mut_slice(1, 4).reverse(); assert!(values == [1,4,3,2,5]); } @@ -1829,15 +1829,15 @@ macro_rules! test_show_vec( ) let empty: Vec = vec![]; test_show_vec!(empty, "[]".to_string()); - test_show_vec!(vec![1], "[1]".to_string()); - test_show_vec!(vec![1, 2, 3], "[1, 2, 3]".to_string()); + test_show_vec!(vec![1i], "[1]".to_string()); + test_show_vec!(vec![1i, 2, 3], "[1, 2, 3]".to_string()); test_show_vec!(vec![vec![], vec![1u], vec![1u, 1u]], "[[], [1], [1, 1]]".to_string()); let empty_mut: &mut [int] = &mut[]; test_show_vec!(empty_mut, "[]".to_string()); - test_show_vec!(&mut[1], "[1]".to_string()); - test_show_vec!(&mut[1, 2, 3], "[1, 2, 3]".to_string()); + test_show_vec!(&mut[1i], "[1]".to_string()); + test_show_vec!(&mut[1i, 2, 3], "[1, 2, 3]".to_string()); test_show_vec!(&mut[&mut[], &mut[1u], &mut[1u, 1u]], "[[], [1], [1, 1]]".to_string()); } @@ -1908,7 +1908,7 @@ fn test_mut_split_at() { fn test_iter_zero_sized() { let mut v = vec![Foo, Foo, Foo]; assert_eq!(v.len(), 3); - let mut cnt = 0; + let mut cnt = 0u; for f in v.iter() { assert!(*f == Foo); @@ -1946,13 +1946,13 @@ fn test_iter_zero_sized() { #[test] fn test_shrink_to_fit() { let mut xs = vec![0, 1, 2, 3]; - for i in range(4, 100) { + for i in range(4i, 100) { xs.push(i) } assert_eq!(xs.capacity(), 128); xs.shrink_to_fit(); assert_eq!(xs.capacity(), 100); - assert_eq!(xs, range(0, 100).collect::>()); + assert_eq!(xs, range(0i, 100i).collect::>()); } #[test] @@ -2011,14 +2011,14 @@ fn test_pop_ref() { #[test] fn test_mut_splitator() { - let mut xs = [0,1,0,2,3,0,0,4,5,0]; + let mut xs = [0i,1,0,2,3,0,0,4,5,0]; assert_eq!(xs.mut_split(|x| *x == 0).count(), 6); for slice in xs.mut_split(|x| *x == 0) { slice.reverse(); } assert!(xs == [0,1,0,3,2,0,0,5,4,0]); - let mut xs = [0,1,0,2,3,0,0,4,5,0,6,7]; + let mut xs = [0i,1,0,2,3,0,0,4,5,0,6,7]; for slice in xs.mut_split(|x| *x == 0).take(5) { slice.reverse(); } @@ -2027,7 +2027,7 @@ fn test_mut_splitator() { #[test] fn test_mut_splitator_rev() { - let mut xs = [1,2,0,3,4,0,0,5,6,0]; + let mut xs = [1i,2,0,3,4,0,0,5,6,0]; for slice in xs.mut_split(|x| *x == 0).rev().take(4) { slice.reverse(); } @@ -2036,7 +2036,7 @@ fn test_mut_splitator_rev() { #[test] fn test_get_mut() { - let mut v = [0,1,2]; + let mut v = [0i,1,2]; assert_eq!(v.get_mut(3), None); v.get_mut(1).map(|e| *e = 7); assert_eq!(v[1], 7); @@ -2071,7 +2071,7 @@ fn test_mut_chunks_rev() { #[test] #[should_fail] fn test_mut_chunks_0() { - let mut v = [1, 2, 3, 4]; + let mut v = [1i, 2, 3, 4]; let _it = v.mut_chunks(0); } @@ -2103,7 +2103,7 @@ fn test_mut_pop_ref() { #[test] fn test_mut_last() { - let mut x = [1, 2, 3, 4, 5]; + let mut x = [1i, 2, 3, 4, 5]; let h = x.mut_last(); assert_eq!(*h.unwrap(), 5); @@ -2140,10 +2140,10 @@ fn iterator(b: &mut Bencher) { #[bench] fn mut_iterator(b: &mut Bencher) { - let mut v = Vec::from_elem(100, 0); + let mut v = Vec::from_elem(100, 0i); b.iter(|| { - let mut i = 0; + let mut i = 0i; for x in v.mut_iter() { *x = i; i += 1; @@ -2153,7 +2153,8 @@ fn mut_iterator(b: &mut Bencher) { #[bench] fn concat(b: &mut Bencher) { - let xss: Vec> = Vec::from_fn(100, |i| range(0, i).collect()); + let xss: Vec> = + Vec::from_fn(100, |i| range(0u, i).collect()); b.iter(|| { xss.as_slice().concat_vec() }); @@ -2161,7 +2162,8 @@ fn concat(b: &mut Bencher) { #[bench] fn connect(b: &mut Bencher) { - let xss: Vec> = Vec::from_fn(100, |i| range(0, i).collect()); + let xss: Vec> = + Vec::from_fn(100, |i| range(0u, i).collect()); b.iter(|| { xss.as_slice().connect_vec(&0) }); @@ -2288,7 +2290,7 @@ fn random_inserts(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { let mut v = Vec::from_elem(30, (0u, 0u)); - for _ in range(0, 100) { + for _ in range(0u, 100) { let l = v.len(); v.insert(rng.gen::() % (l + 1), (1, 1)); @@ -2300,7 +2302,7 @@ fn random_removes(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { let mut v = Vec::from_elem(130, (0u, 0u)); - for _ in range(0, 100) { + for _ in range(0u, 100) { let l = v.len(); v.remove(rng.gen::() % l); } diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 4ae30348c3a..14e41f3fef9 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -277,7 +277,7 @@ mod test_map { #[test] fn test_find_mut() { let mut m = SmallIntMap::new(); - assert!(m.insert(1, 12)); + assert!(m.insert(1, 12i)); assert!(m.insert(2, 8)); assert!(m.insert(5, 14)); let new = 100; @@ -292,7 +292,7 @@ fn test_len() { let mut map = SmallIntMap::new(); assert_eq!(map.len(), 0); assert!(map.is_empty()); - assert!(map.insert(5, 20)); + assert!(map.insert(5, 20i)); assert_eq!(map.len(), 1); assert!(!map.is_empty()); assert!(map.insert(11, 12)); @@ -306,7 +306,7 @@ fn test_len() { #[test] fn test_clear() { let mut map = SmallIntMap::new(); - assert!(map.insert(5, 20)); + assert!(map.insert(5, 20i)); assert!(map.insert(11, 12)); assert!(map.insert(14, 22)); map.clear(); @@ -349,15 +349,15 @@ fn add_more_to_count_simple(v0: uint, v1: uint) -> uint { #[test] fn test_swap() { let mut m = SmallIntMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + assert_eq!(m.swap(1, 2i), None); + assert_eq!(m.swap(1, 3i), Some(2)); + assert_eq!(m.swap(1, 4i), Some(3)); } #[test] fn test_pop() { let mut m = SmallIntMap::new(); - m.insert(1, 2); + m.insert(1, 2i); assert_eq!(m.pop(&1), Some(2)); assert_eq!(m.pop(&1), None); } @@ -366,7 +366,7 @@ fn test_pop() { fn test_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); + assert!(m.insert(0, 1i)); assert!(m.insert(1, 2)); assert!(m.insert(3, 5)); assert!(m.insert(6, 10)); @@ -391,7 +391,7 @@ fn test_iterator() { fn test_iterator_size_hints() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); + assert!(m.insert(0, 1i)); assert!(m.insert(1, 2)); assert!(m.insert(3, 5)); assert!(m.insert(6, 10)); @@ -407,7 +407,7 @@ fn test_iterator_size_hints() { fn test_mut_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); + assert!(m.insert(0, 1i)); assert!(m.insert(1, 2)); assert!(m.insert(3, 5)); assert!(m.insert(6, 10)); @@ -430,7 +430,7 @@ fn test_mut_iterator() { fn test_rev_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); + assert!(m.insert(0, 1i)); assert!(m.insert(1, 2)); assert!(m.insert(3, 5)); assert!(m.insert(6, 10)); @@ -449,7 +449,7 @@ fn test_rev_iterator() { fn test_mut_rev_iterator() { let mut m = SmallIntMap::new(); - assert!(m.insert(0, 1)); + assert!(m.insert(0, 1i)); assert!(m.insert(1, 2)); assert!(m.insert(3, 5)); assert!(m.insert(6, 10)); @@ -471,16 +471,16 @@ fn test_mut_rev_iterator() { #[test] fn test_move_iter() { let mut m = SmallIntMap::new(); - m.insert(1, box 2); + m.insert(1, box 2i); let mut called = false; for (k, v) in m.move_iter() { assert!(!called); called = true; assert_eq!(k, 1); - assert_eq!(v, box 2); + assert_eq!(v, box 2i); } assert!(called); - m.insert(2, box 1); + m.insert(2, box 1i); } #[test] @@ -488,8 +488,8 @@ fn test_show() { let mut map = SmallIntMap::new(); let empty = SmallIntMap::::new(); - map.insert(1, 2); - map.insert(3, 4); + map.insert(1, 2i); + map.insert(3, 4i); let map_str = map.to_str(); let map_str = map_str.as_slice(); diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 02246c33317..90f08bdd9dd 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1030,16 +1030,16 @@ fn find_empty() { #[test] fn find_not_found() { let mut m = TreeMap::new(); - assert!(m.insert(1, 2)); - assert!(m.insert(5, 3)); - assert!(m.insert(9, 3)); + assert!(m.insert(1i, 2i)); + assert!(m.insert(5i, 3i)); + assert!(m.insert(9i, 3i)); assert_eq!(m.find(&2), None); } #[test] fn test_find_mut() { let mut m = TreeMap::new(); - assert!(m.insert(1, 12)); + assert!(m.insert(1i, 12i)); assert!(m.insert(2, 8)); assert!(m.insert(5, 14)); let new = 100; @@ -1052,7 +1052,7 @@ fn test_find_mut() { #[test] fn insert_replace() { let mut m = TreeMap::new(); - assert!(m.insert(5, 2)); + assert!(m.insert(5i, 2i)); assert!(m.insert(2, 9)); assert!(!m.insert(2, 11)); assert_eq!(m.find(&2).unwrap(), &11); @@ -1062,7 +1062,7 @@ fn insert_replace() { fn test_clear() { let mut m = TreeMap::new(); m.clear(); - assert!(m.insert(5, 11)); + assert!(m.insert(5i, 11i)); assert!(m.insert(12, -3)); assert!(m.insert(19, 2)); m.clear(); @@ -1159,8 +1159,8 @@ fn test_rand_int() { let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(&[42]); - for _ in range(0, 3) { - for _ in range(0, 90) { + for _ in range(0u, 3) { + for _ in range(0u, 90) { let k = rng.gen(); let v = rng.gen(); if !ctrl.iter().any(|x| x == &(k, v)) { @@ -1171,7 +1171,7 @@ fn test_rand_int() { } } - for _ in range(0, 30) { + for _ in range(0u, 30) { let r = rng.gen_range(0, ctrl.len()); let (key, _) = ctrl.remove(r).unwrap(); assert!(map.remove(&key)); @@ -1184,7 +1184,7 @@ fn test_rand_int() { #[test] fn test_len() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); + assert!(m.insert(3i, 6i)); assert_eq!(m.len(), 1); assert!(m.insert(0, 0)); assert_eq!(m.len(), 2); @@ -1204,7 +1204,7 @@ fn test_len() { fn test_iterator() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); + assert!(m.insert(3i, 6i)); assert!(m.insert(0, 0)); assert!(m.insert(4, 8)); assert!(m.insert(2, 4)); @@ -1222,11 +1222,11 @@ fn test_iterator() { #[test] fn test_interval_iteration() { let mut m = TreeMap::new(); - for i in range(1, 100) { + for i in range(1i, 100i) { assert!(m.insert(i * 2, i * 4)); } - for i in range(1, 198) { + for i in range(1i, 198i) { let mut lb_it = m.lower_bound(&i); let (&k, &v) = lb_it.next().unwrap(); let lb = i + i % 2; @@ -1247,7 +1247,7 @@ fn test_interval_iteration() { fn test_rev_iter() { let mut m = TreeMap::new(); - assert!(m.insert(3, 6)); + assert!(m.insert(3i, 6i)); assert!(m.insert(0, 0)); assert!(m.insert(4, 8)); assert!(m.insert(2, 4)); @@ -1296,19 +1296,19 @@ fn test_mut_rev_iter() { fn test_mut_interval_iter() { let mut m_lower = TreeMap::new(); let mut m_upper = TreeMap::new(); - for i in range(1, 100) { + for i in range(1i, 100i) { assert!(m_lower.insert(i * 2, i * 4)); assert!(m_upper.insert(i * 2, i * 4)); } - for i in range(1, 199) { + for i in range(1i, 199) { let mut lb_it = m_lower.mut_lower_bound(&i); let (&k, v) = lb_it.next().unwrap(); let lb = i + i % 2; assert_eq!(lb, k); *v -= k; } - for i in range(0, 198) { + for i in range(0i, 198) { let mut ub_it = m_upper.mut_upper_bound(&i); let (&k, v) = ub_it.next().unwrap(); let ub = i + 2 - i % 2; @@ -1330,7 +1330,7 @@ fn test_eq() { let mut b = TreeMap::new(); assert!(a == b); - assert!(a.insert(0, 5)); + assert!(a.insert(0i, 5i)); assert!(a != b); assert!(b.insert(0, 4)); assert!(a != b); @@ -1348,7 +1348,7 @@ fn test_lt() { let mut b = TreeMap::new(); assert!(!(a < b) && !(b < a)); - assert!(b.insert(0, 5)); + assert!(b.insert(0i, 5i)); assert!(a < b); assert!(a.insert(0, 7)); assert!(!(a < b) && b < a); @@ -1366,7 +1366,7 @@ fn test_ord() { let mut b = TreeMap::new(); assert!(a <= b && a >= b); - assert!(a.insert(1, 1)); + assert!(a.insert(1i, 1i)); assert!(a > b && a >= b); assert!(b < a && b <= a); assert!(b.insert(2, 2)); @@ -1391,7 +1391,7 @@ fn test_show() { #[test] fn test_lazy_iterator() { let mut m = TreeMap::new(); - let (x1, y1) = (2, 5); + let (x1, y1) = (2i, 5i); let (x2, y2) = (9, 12); let (x3, y3) = (20, -3); let (x4, y4) = (29, 5); @@ -1437,7 +1437,7 @@ fn test_lazy_iterator() { #[test] fn test_from_iter() { - let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; let map: TreeMap = xs.iter().map(|&x| x).collect(); @@ -1519,7 +1519,7 @@ mod test_set { fn test_clear() { let mut s = TreeSet::new(); s.clear(); - assert!(s.insert(5)); + assert!(s.insert(5i)); assert!(s.insert(12)); assert!(s.insert(19)); s.clear(); @@ -1535,8 +1535,8 @@ fn test_disjoint() { let mut ys = TreeSet::new(); assert!(xs.is_disjoint(&ys)); assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(5)); - assert!(ys.insert(11)); + assert!(xs.insert(5i)); + assert!(ys.insert(11i)); assert!(xs.is_disjoint(&ys)); assert!(ys.is_disjoint(&xs)); assert!(xs.insert(7)); @@ -1554,13 +1554,13 @@ fn test_disjoint() { #[test] fn test_subset_and_superset() { let mut a = TreeSet::new(); - assert!(a.insert(0)); + assert!(a.insert(0i)); assert!(a.insert(5)); assert!(a.insert(11)); assert!(a.insert(7)); let mut b = TreeSet::new(); - assert!(b.insert(0)); + assert!(b.insert(0i)); assert!(b.insert(7)); assert!(b.insert(19)); assert!(b.insert(250)); @@ -1584,7 +1584,7 @@ fn test_subset_and_superset() { fn test_iterator() { let mut m = TreeSet::new(); - assert!(m.insert(3)); + assert!(m.insert(3i)); assert!(m.insert(0)); assert!(m.insert(4)); assert!(m.insert(2)); @@ -1601,7 +1601,7 @@ fn test_iterator() { fn test_rev_iter() { let mut m = TreeSet::new(); - assert!(m.insert(3)); + assert!(m.insert(3i)); assert!(m.insert(0)); assert!(m.insert(4)); assert!(m.insert(2)); @@ -1616,7 +1616,7 @@ fn test_rev_iter() { #[test] fn test_move_iter() { - let s: TreeSet = range(0, 5).collect(); + let s: TreeSet = range(0i, 5).collect(); let mut n = 0; for x in s.move_iter() { @@ -1627,7 +1627,7 @@ fn test_move_iter() { #[test] fn test_move_iter_size_hint() { - let s: TreeSet = vec!(0, 1).move_iter().collect(); + let s: TreeSet = vec!(0i, 1).move_iter().collect(); let mut it = s.move_iter(); @@ -1645,7 +1645,7 @@ fn test_move_iter_size_hint() { fn test_clone_eq() { let mut m = TreeSet::new(); - m.insert(1); + m.insert(1i); m.insert(2); assert!(m.clone() == m); @@ -1762,22 +1762,22 @@ fn test_zip() { #[test] fn test_swap() { let mut m = TreeMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + assert_eq!(m.swap(1u, 2i), None); + assert_eq!(m.swap(1u, 3i), Some(2)); + assert_eq!(m.swap(1u, 4i), Some(3)); } #[test] fn test_pop() { let mut m = TreeMap::new(); - m.insert(1, 2); + m.insert(1u, 2i); assert_eq!(m.pop(&1), Some(2)); assert_eq!(m.pop(&1), None); } #[test] fn test_from_iter() { - let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + let xs = [1i, 2, 3, 4, 5, 6, 7, 8, 9]; let set: TreeSet = xs.iter().map(|&x| x).collect(); diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 3f4fdd66b80..350c284e1d3 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -682,9 +682,9 @@ fn check_integrity(trie: &TrieNode) { #[test] fn test_find_mut() { let mut m = TrieMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + assert!(m.insert(1u, 12i)); + assert!(m.insert(2u, 8i)); + assert!(m.insert(5u, 14i)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -696,7 +696,7 @@ fn test_find_mut() { fn test_find_mut_missing() { let mut m = TrieMap::new(); assert!(m.find_mut(&0).is_none()); - assert!(m.insert(1, 12)); + assert!(m.insert(1u, 12i)); assert!(m.find_mut(&0).is_none()); assert!(m.insert(2, 8)); assert!(m.find_mut(&0).is_none()); @@ -781,15 +781,15 @@ fn test_each_reverse_break() { #[test] fn test_swap() { let mut m = TrieMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + assert_eq!(m.swap(1u, 2i), None); + assert_eq!(m.swap(1u, 3i), Some(2)); + assert_eq!(m.swap(1u, 4i), Some(3)); } #[test] fn test_pop() { let mut m = TrieMap::new(); - m.insert(1, 2); + m.insert(1u, 2i); assert_eq!(m.pop(&1), Some(2)); assert_eq!(m.pop(&1), None); } @@ -943,7 +943,7 @@ mod bench_map { fn bench_iter_small(b: &mut Bencher) { let mut m = TrieMap::::new(); let mut rng = weak_rng(); - for _ in range(0, 20) { + for _ in range(0u, 20) { m.insert(rng.gen(), rng.gen()); } @@ -954,7 +954,7 @@ fn bench_iter_small(b: &mut Bencher) { fn bench_iter_large(b: &mut Bencher) { let mut m = TrieMap::::new(); let mut rng = weak_rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { m.insert(rng.gen(), rng.gen()); } @@ -965,12 +965,12 @@ fn bench_iter_large(b: &mut Bencher) { fn bench_lower_bound(b: &mut Bencher) { let mut m = TrieMap::::new(); let mut rng = weak_rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { m.insert(rng.gen(), rng.gen()); } b.iter(|| { - for _ in range(0, 10) { + for _ in range(0u, 10) { m.lower_bound(rng.gen()); } }); @@ -980,12 +980,12 @@ fn bench_lower_bound(b: &mut Bencher) { fn bench_upper_bound(b: &mut Bencher) { let mut m = TrieMap::::new(); let mut rng = weak_rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { m.insert(rng.gen(), rng.gen()); } b.iter(|| { - for _ in range(0, 10) { + for _ in range(0u, 10) { m.upper_bound(rng.gen()); } }); @@ -997,7 +997,7 @@ fn bench_insert_large(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { - for _ in range(0, 1000) { + for _ in range(0u, 1000) { m.insert(rng.gen(), [1, .. 10]); } }) @@ -1008,7 +1008,7 @@ fn bench_insert_large_low_bits(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { - for _ in range(0, 1000) { + for _ in range(0u, 1000) { // only have the last few bits set. m.insert(rng.gen::() & 0xff_ff, [1, .. 10]); } @@ -1021,7 +1021,7 @@ fn bench_insert_small(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { - for _ in range(0, 1000) { + for _ in range(0u, 1000) { m.insert(rng.gen(), ()); } }) @@ -1032,7 +1032,7 @@ fn bench_insert_small_low_bits(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { - for _ in range(0, 1000) { + for _ in range(0u, 1000) { // only have the last few bits set. m.insert(rng.gen::() & 0xff_ff, ()); } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 953fa68138a..e3ed3ffbabf 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -34,8 +34,8 @@ /// ```rust /// # use std::vec::Vec; /// let mut vec = Vec::new(); -/// vec.push(1); -/// vec.push(2); +/// vec.push(1i); +/// vec.push(2i); /// /// assert_eq!(vec.len(), 2); /// assert_eq!(vec.get(0), &1); @@ -47,7 +47,7 @@ /// The `vec!` macro is provided to make initialization more convenient: /// /// ```rust -/// let mut vec = vec!(1, 2, 3); +/// let mut vec = vec!(1i, 2i, 3i); /// vec.push(4); /// assert_eq!(vec, vec!(1, 2, 3, 4)); /// ``` @@ -147,7 +147,7 @@ pub unsafe fn from_raw_parts(length: uint, capacity: uint, /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3, 4); + /// let vec = vec!(1i, 2i, 3i, 4i); /// let (even, odd) = vec.partition(|&n| n % 2 == 0); /// assert_eq!(even, vec!(2, 4)); /// assert_eq!(odd, vec!(1, 3)); @@ -176,8 +176,8 @@ impl Vec { /// # Example /// /// ```rust - /// let vec = vec!(1, 2); - /// let vec = vec.append([3, 4]); + /// let vec = vec!(1i, 2i); + /// let vec = vec.append([3i, 4i]); /// assert_eq!(vec, vec!(1, 2, 3, 4)); /// ``` #[inline] @@ -192,7 +192,7 @@ pub fn append(mut self, second: &[T]) -> Vec { /// /// ```rust /// # use std::vec::Vec; - /// let slice = [1, 2, 3]; + /// let slice = [1i, 2, 3]; /// let vec = Vec::from_slice(slice); /// ``` #[inline] @@ -232,8 +232,8 @@ pub fn from_elem(length: uint, value: T) -> Vec { /// # Example /// /// ```rust - /// let mut vec = vec!(1); - /// vec.push_all([2, 3, 4]); + /// let mut vec = vec!(1i); + /// vec.push_all([2i, 3, 4]); /// assert_eq!(vec, vec!(1, 2, 3, 4)); /// ``` #[inline] @@ -295,10 +295,10 @@ pub fn grow_set(&mut self, index: uint, initval: &T, value: T) { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3, 4); + /// let vec = vec!(1i, 2, 3, 4); /// let (even, odd) = vec.partitioned(|&n| n % 2 == 0); - /// assert_eq!(even, vec!(2, 4)); - /// assert_eq!(odd, vec!(1, 3)); + /// assert_eq!(even, vec!(2i, 4)); + /// assert_eq!(odd, vec!(1i, 3)); /// ``` pub fn partitioned(&self, f: |&T| -> bool) -> (Vec, Vec) { let mut lefts = Vec::new(); @@ -466,7 +466,7 @@ pub fn capacity(&self) -> uint { /// /// ```rust /// # use std::vec::Vec; - /// let mut vec: Vec = vec!(1); + /// let mut vec: Vec = vec!(1i); /// vec.reserve_additional(10); /// assert!(vec.capacity() >= 11); /// ``` @@ -491,7 +491,7 @@ pub fn reserve_additional(&mut self, extra: uint) { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// vec.reserve(10); /// assert!(vec.capacity() >= 10); /// ``` @@ -533,7 +533,7 @@ pub fn reserve_exact(&mut self, capacity: uint) { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// vec.shrink_to_fit(); /// ``` pub fn shrink_to_fit(&mut self) { @@ -565,7 +565,7 @@ pub fn shrink_to_fit(&mut self) { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// assert_eq!(vec.pop(), Some(3)); /// assert_eq!(vec, vec!(1, 2)); /// ``` @@ -590,7 +590,7 @@ pub fn pop(&mut self) -> Option { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2); + /// let mut vec = vec!(1i, 2); /// vec.push(3); /// assert_eq!(vec, vec!(1, 2, 3)); /// ``` @@ -626,7 +626,7 @@ pub fn push(&mut self, value: T) { /// # Example /// /// ```rust - /// let vec = vec!(1, 2); + /// let vec = vec!(1i, 2); /// let vec = vec.append_one(3); /// assert_eq!(vec, vec!(1, 2, 3)); /// ``` @@ -644,7 +644,7 @@ pub fn append_one(mut self, x: T) -> Vec { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); + /// let mut vec = vec!(1i, 2, 3, 4); /// vec.truncate(2); /// assert_eq!(vec, vec!(1, 2)); /// ``` @@ -667,7 +667,7 @@ pub fn truncate(&mut self, len: uint) { /// ```rust /// fn foo(slice: &mut [int]) {} /// - /// let mut vec = vec!(1, 2); + /// let mut vec = vec!(1i, 2); /// foo(vec.as_mut_slice()); /// ``` #[inline] @@ -721,7 +721,7 @@ pub unsafe fn set_len(&mut self, len: uint) { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.get(1) == &2); /// ``` #[inline] @@ -738,9 +738,9 @@ pub fn get<'a>(&'a self, index: uint) -> &'a T { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// *vec.get_mut(1) = 4; - /// assert_eq!(vec, vec!(1, 4, 3)); + /// assert_eq!(vec, vec!(1i, 4, 3)); /// ``` #[inline] pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T { @@ -753,7 +753,7 @@ pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// for num in vec.iter() { /// println!("{}", *num); /// } @@ -770,7 +770,7 @@ pub fn iter<'a>(&'a self) -> Items<'a,T> { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// for num in vec.mut_iter() { /// *num = 0; /// } @@ -790,11 +790,11 @@ pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { /// ```rust /// let mut v = vec!(5i, 4, 1, 3, 2); /// v.sort_by(|a, b| a.cmp(b)); - /// assert_eq!(v, vec!(1, 2, 3, 4, 5)); + /// assert_eq!(v, vec!(1i, 2, 3, 4, 5)); /// /// // reverse sorting /// v.sort_by(|a, b| b.cmp(a)); - /// assert_eq!(v, vec!(5, 4, 3, 2, 1)); + /// assert_eq!(v, vec!(5i, 4, 3, 2, 1)); /// ``` #[inline] pub fn sort_by(&mut self, compare: |&T, &T| -> Ordering) { @@ -811,7 +811,7 @@ pub fn sort_by(&mut self, compare: |&T, &T| -> Ordering) { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3, 4); + /// let vec = vec!(1i, 2, 3, 4); /// assert!(vec.slice(0, 2) == [1, 2]); /// ``` #[inline] @@ -828,7 +828,7 @@ pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.tail() == [2, 3]); /// ``` #[inline] @@ -845,7 +845,7 @@ pub fn tail<'a>(&'a self) -> &'a [T] { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3, 4); + /// let vec = vec!(1i, 2, 3, 4); /// assert!(vec.tailn(2) == [3, 4]); /// ``` #[inline] @@ -859,7 +859,7 @@ pub fn tailn<'a>(&'a self, n: uint) -> &'a [T] { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.last() == Some(&3)); /// ``` #[inline] @@ -873,9 +873,9 @@ pub fn last<'a>(&'a self) -> Option<&'a T> { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// *vec.mut_last().unwrap() = 4; - /// assert_eq!(vec, vec!(1, 2, 4)); + /// assert_eq!(vec, vec!(1i, 2, 4)); /// ``` #[inline] pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { @@ -921,7 +921,7 @@ pub fn swap_remove(&mut self, index: uint) -> Option { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// vec.unshift(4); /// assert_eq!(vec, vec!(4, 1, 2, 3)); /// ``` @@ -941,7 +941,7 @@ pub fn unshift(&mut self, element: T) { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// assert!(vec.shift() == Some(1)); /// assert_eq!(vec, vec!(2, 3)); /// ``` @@ -960,7 +960,7 @@ pub fn shift(&mut self) -> Option { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3); + /// let mut vec = vec!(1i, 2, 3); /// vec.insert(1, 4); /// assert_eq!(vec, vec!(1, 4, 2, 3)); /// ``` @@ -992,7 +992,7 @@ pub fn insert(&mut self, index: uint, element: T) { /// # Example /// /// ```rust - /// let mut v = vec!(1, 2, 3); + /// let mut v = vec!(1i, 2, 3); /// assert_eq!(v.remove(1), Some(2)); /// assert_eq!(v, vec!(1, 3)); /// @@ -1031,7 +1031,7 @@ pub fn remove(&mut self, index: uint) -> Option { /// # Example /// /// ```rust - /// let mut vec = vec!(box 1); + /// let mut vec = vec!(box 1i); /// vec.push_all_move(vec!(box 2, box 3, box 4)); /// assert_eq!(vec, vec!(box 1, box 2, box 3, box 4)); /// ``` @@ -1050,7 +1050,7 @@ pub fn push_all_move(&mut self, other: Vec) { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); + /// let mut vec = vec!(1i, 2, 3, 4); /// assert!(vec.mut_slice(0, 2) == [1, 2]); /// ``` #[inline] @@ -1068,7 +1068,7 @@ pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); + /// let mut vec = vec!(1i, 2, 3, 4); /// assert!(vec.mut_slice_from(2) == [3, 4]); /// ``` #[inline] @@ -1085,7 +1085,7 @@ pub fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3, 4); + /// let mut vec = vec!(1i, 2, 3, 4); /// assert!(vec.mut_slice_to(2) == [1, 2]); /// ``` #[inline] @@ -1106,7 +1106,7 @@ pub fn mut_slice_to<'a>(&'a mut self, end: uint) -> &'a mut [T] { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 3, 4, 5, 6); + /// let mut vec = vec!(1i, 2, 3, 4, 5, 6); /// /// // scoped to restrict the lifetime of the borrows /// { @@ -1137,9 +1137,9 @@ pub fn mut_split_at<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { /// # Example /// /// ```rust - /// let mut v = vec!(1, 2, 3); + /// let mut v = vec!(1i, 2, 3); /// v.reverse(); - /// assert_eq!(v, vec!(3, 2, 1)); + /// assert_eq!(v, vec!(3i, 2, 1)); /// ``` #[inline] pub fn reverse(&mut self) { @@ -1155,7 +1155,7 @@ pub fn reverse(&mut self) { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.slice_from(1) == [2, 3]); /// ``` #[inline] @@ -1172,7 +1172,7 @@ pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.slice_to(2) == [1, 2]); /// ``` #[inline] @@ -1310,7 +1310,7 @@ impl Vec { /// # Example /// /// ```rust - /// let vec = vec!(1, 2, 3); + /// let vec = vec!(1i, 2, 3); /// assert!(vec.contains(&1)); /// ``` #[inline] @@ -1325,9 +1325,9 @@ pub fn contains(&self, x: &T) -> bool { /// # Example /// /// ```rust - /// let mut vec = vec!(1, 2, 2, 3, 2); + /// let mut vec = vec!(1i, 2, 2, 3, 2); /// vec.dedup(); - /// assert_eq!(vec, vec!(1, 2, 3, 2)); + /// assert_eq!(vec, vec!(1i, 2, 3, 2)); /// ``` pub fn dedup(&mut self) { unsafe { @@ -1422,7 +1422,7 @@ impl Vector for Vec { /// ```rust /// fn foo(slice: &[int]) {} /// - /// let vec = vec!(1, 2); + /// let vec = vec!(1i, 2); /// foo(vec.as_slice()); /// ``` #[inline] @@ -1611,7 +1611,7 @@ fn test_reserve_additional() { v.reserve_additional(2); assert!(v.capacity() >= 2); - for i in range(0, 16) { + for i in range(0i, 16) { v.push(i); } @@ -1630,13 +1630,13 @@ fn test_extend() { let mut v = Vec::new(); let mut w = Vec::new(); - v.extend(range(0, 3)); - for i in range(0, 3) { w.push(i) } + v.extend(range(0i, 3)); + for i in range(0i, 3) { w.push(i) } assert_eq!(v, w); - v.extend(range(3, 10)); - for i in range(3, 10) { w.push(i) } + v.extend(range(3i, 10)); + for i in range(3i, 10) { w.push(i) } assert_eq!(v, w); } @@ -1691,7 +1691,7 @@ fn test_mut_split_at() { #[test] fn test_clone() { let v: Vec = vec!(); - let w = vec!(1, 2, 3); + let w = vec!(1i, 2, 3); assert_eq!(v, v.clone()); @@ -1704,8 +1704,8 @@ fn test_clone() { #[test] fn test_clone_from() { let mut v = vec!(); - let three = vec!(box 1, box 2, box 3); - let two = vec!(box 4, box 5); + let three = vec!(box 1i, box 2, box 3); + let two = vec!(box 4i, box 5); // zero, long v.clone_from(&three); assert_eq!(v, three); @@ -1771,22 +1771,22 @@ fn zero_sized_values() { #[test] fn test_partition() { assert_eq!(vec![].partition(|x: &int| *x < 3), (vec![], vec![])); - assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); - assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 2), (vec![1], vec![2, 3])); - assert_eq!(vec![1, 2, 3].partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); + assert_eq!(vec![1i, 2, 3].partition(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); + assert_eq!(vec![1i, 2, 3].partition(|x: &int| *x < 2), (vec![1], vec![2, 3])); + assert_eq!(vec![1i, 2, 3].partition(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); } #[test] fn test_partitioned() { assert_eq!(vec![].partitioned(|x: &int| *x < 3), (vec![], vec![])) - assert_eq!(vec![1, 2, 3].partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); - assert_eq!(vec![1, 2, 3].partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3])); - assert_eq!(vec![1, 2, 3].partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); + assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); + assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3])); + assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); } #[test] fn test_zip_unzip() { - let z1 = vec![(1, 4), (2, 5), (3, 6)]; + let z1 = vec![(1i, 4i), (2, 5), (3, 6)]; let (left, right) = unzip(z1.iter().map(|&x| x)); @@ -1800,13 +1800,13 @@ fn test_zip_unzip() { fn test_unsafe_ptrs() { unsafe { // Test on-stack copy-from-buf. - let a = [1, 2, 3]; + let a = [1i, 2, 3]; let ptr = a.as_ptr(); let b = raw::from_buf(ptr, 3u); assert_eq!(b, vec![1, 2, 3]); // Test on-heap copy-from-buf. - let c = vec![1, 2, 3, 4, 5]; + let c = vec![1i, 2, 3, 4, 5]; let ptr = c.as_ptr(); let d = raw::from_buf(ptr, 5u); assert_eq!(d, vec![1, 2, 3, 4, 5]); @@ -1912,7 +1912,7 @@ fn bench_from_slice_0(b: &mut Bencher) { #[bench] fn bench_from_slice_5(b: &mut Bencher) { b.iter(|| { - let v: Vec = Vec::from_slice([1, 2, 3, 4, 5]); + let v: Vec = Vec::from_slice([1i, 2, 3, 4, 5]); assert!(v.as_slice() == [1, 2, 3, 4, 5]); }) } diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 2657cd53483..0b621863e2c 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -284,7 +284,8 @@ mod bench { #[bench] fn bench_as_ref(b: &mut Bencher) { b.iter(|| { - let mut x = 0; let mut y = &mut x as &mut Any; + let mut x = 0i; + let mut y = &mut x as &mut Any; test::black_box(&mut y); test::black_box(y.as_ref::() == Some(&0)); }); diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 7ab2ae307d4..fd694c04f55 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -389,14 +389,14 @@ mod test { #[test] fn smoketest_cell() { - let x = Cell::new(10); + let x = Cell::new(10i); assert!(x == Cell::new(10)); assert!(x.get() == 10); x.set(20); assert!(x == Cell::new(20)); assert!(x.get() == 20); - let y = Cell::new((30, 40)); + let y = Cell::new((30i, 40i)); assert!(y == Cell::new((30, 40))); assert!(y.get() == (30, 40)); } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 76ff56a77a4..c188ec75ddd 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -308,6 +308,7 @@ pub fn escape_unicode(c: char, f: |char|) { _ => { f('U'); 8 } }; for offset in range_step::(4 * (pad - 1), -1, -4) { + let offset = offset as uint; unsafe { match ((c as i32) >> offset) & 0xf { i @ 0 .. 9 => { f(transmute('0' as i32 + i)); } diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index e6c462c62d2..4fb887bad94 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -146,8 +146,8 @@ fn test_borrowed_clone() { #[test] fn test_clone_from() { - let a = box 5; - let mut b = box 10; + let a = box 5i; + let mut b = box 10i; realclone_from(&mut b, &a); assert_eq!(*b, 5); } diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs index 9f7592a80bd..ab151460537 100644 --- a/src/libcore/finally.rs +++ b/src/libcore/finally.rs @@ -122,7 +122,7 @@ mod test { #[test] fn test_success() { - let mut i = 0; + let mut i = 0i; try_finally( &mut i, (), |i, ()| { @@ -139,7 +139,7 @@ fn test_success() { #[test] #[should_fail] fn test_fail() { - let mut i = 0; + let mut i = 0i; try_finally( &mut i, (), |i, ()| { diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index f36acf344e4..56d0817dd00 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -140,7 +140,7 @@ fn digit(&self, x: u8) -> u8 { /// /// ~~~ /// use std::fmt::radix; -/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string()); +/// assert_eq!(format!("{}", radix(55i, 36)), "1j".to_string()); /// ~~~ pub fn radix(x: T, base: u8) -> RadixFmt { RadixFmt(x, Radix::new(base)) @@ -309,11 +309,11 @@ fn test_format_int() { assert!(format!("{:o}", 1u64).as_slice() == "1"); // Test a larger number - assert!(format!("{:t}", 55).as_slice() == "110111"); - assert!(format!("{:o}", 55).as_slice() == "67"); - assert!(format!("{:d}", 55).as_slice() == "55"); - assert!(format!("{:x}", 55).as_slice() == "37"); - assert!(format!("{:X}", 55).as_slice() == "37"); + assert!(format!("{:t}", 55i).as_slice() == "110111"); + assert!(format!("{:o}", 55i).as_slice() == "67"); + assert!(format!("{:d}", 55i).as_slice() == "55"); + assert!(format!("{:x}", 55i).as_slice() == "37"); + assert!(format!("{:X}", 55i).as_slice() == "37"); } #[test] @@ -335,21 +335,21 @@ fn test_format_int_zero() { #[test] fn test_format_int_flags() { - assert!(format!("{:3d}", 1).as_slice() == " 1"); - assert!(format!("{:>3d}", 1).as_slice() == " 1"); - assert!(format!("{:>+3d}", 1).as_slice() == " +1"); - assert!(format!("{:<3d}", 1).as_slice() == "1 "); - assert!(format!("{:#d}", 1).as_slice() == "1"); - assert!(format!("{:#x}", 10).as_slice() == "0xa"); - assert!(format!("{:#X}", 10).as_slice() == "0xA"); - assert!(format!("{:#5x}", 10).as_slice() == " 0xa"); - assert!(format!("{:#o}", 10).as_slice() == "0o12"); - assert!(format!("{:08x}", 10).as_slice() == "0000000a"); - assert!(format!("{:8x}", 10).as_slice() == " a"); - assert!(format!("{:<8x}", 10).as_slice() == "a "); - assert!(format!("{:>8x}", 10).as_slice() == " a"); - assert!(format!("{:#08x}", 10).as_slice() == "0x00000a"); - assert!(format!("{:08d}", -10).as_slice() == "-0000010"); + assert!(format!("{:3d}", 1i).as_slice() == " 1"); + assert!(format!("{:>3d}", 1i).as_slice() == " 1"); + assert!(format!("{:>+3d}", 1i).as_slice() == " +1"); + assert!(format!("{:<3d}", 1i).as_slice() == "1 "); + assert!(format!("{:#d}", 1i).as_slice() == "1"); + assert!(format!("{:#x}", 10i).as_slice() == "0xa"); + assert!(format!("{:#X}", 10i).as_slice() == "0xA"); + assert!(format!("{:#5x}", 10i).as_slice() == " 0xa"); + assert!(format!("{:#o}", 10i).as_slice() == "0o12"); + assert!(format!("{:08x}", 10i).as_slice() == "0000000a"); + assert!(format!("{:8x}", 10i).as_slice() == " a"); + assert!(format!("{:<8x}", 10i).as_slice() == "a "); + assert!(format!("{:>8x}", 10i).as_slice() == " a"); + assert!(format!("{:#08x}", 10i).as_slice() == "0x00000a"); + assert!(format!("{:08d}", -10i).as_slice() == "-0000010"); assert!(format!("{:x}", -1u8).as_slice() == "ff"); assert!(format!("{:X}", -1u8).as_slice() == "FF"); assert!(format!("{:t}", -1u8).as_slice() == "11111111"); @@ -362,12 +362,12 @@ fn test_format_int_flags() { #[test] fn test_format_int_sign_padding() { - assert!(format!("{:+5d}", 1).as_slice() == " +1"); - assert!(format!("{:+5d}", -1).as_slice() == " -1"); - assert!(format!("{:05d}", 1).as_slice() == "00001"); - assert!(format!("{:05d}", -1).as_slice() == "-0001"); - assert!(format!("{:+05d}", 1).as_slice() == "+0001"); - assert!(format!("{:+05d}", -1).as_slice() == "-0001"); + assert!(format!("{:+5d}", 1i).as_slice() == " +1"); + assert!(format!("{:+5d}", -1i).as_slice() == " -1"); + assert!(format!("{:05d}", 1i).as_slice() == "00001"); + assert!(format!("{:05d}", -1i).as_slice() == "-0001"); + assert!(format!("{:+05d}", 1i).as_slice() == "+0001"); + assert!(format!("{:+05d}", -1i).as_slice() == "-0001"); } #[test] @@ -381,8 +381,8 @@ fn test_format_int_twos_complement() { #[test] fn test_format_radix() { - assert!(format!("{:04}", radix(3, 2)).as_slice() == "0011"); - assert!(format!("{}", radix(55, 36)).as_slice() == "1j"); + assert!(format!("{:04}", radix(3i, 2)).as_slice() == "0011"); + assert!(format!("{}", radix(55i, 36)).as_slice() == "1j"); } #[test] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 32c47d36bed..3f4d3020815 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -35,7 +35,7 @@ trait defined in this module. For loops can be viewed as a syntactical expansion translated to the `loop` below. ```rust -let values = vec![1, 2, 3]; +let values = vec![1i, 2, 3]; // "Syntactical sugar" taking advantage of an iterator for &x in values.iter() { @@ -112,8 +112,8 @@ fn size_hint(&self) -> (uint, Option) { (0, None) } /// # Example /// /// ```rust - /// let a = [0]; - /// let b = [1]; + /// let a = [0i]; + /// let b = [1i]; /// let mut it = a.iter().chain(b.iter()); /// assert_eq!(it.next().unwrap(), &0); /// assert_eq!(it.next().unwrap(), &1); @@ -132,8 +132,8 @@ fn chain>(self, other: U) -> Chain { /// # Example /// /// ```rust - /// let a = [0]; - /// let b = [1]; + /// let a = [0i]; + /// let b = [1i]; /// let mut it = a.iter().zip(b.iter()); /// assert_eq!(it.next().unwrap(), (&0, &1)); /// assert!(it.next().is_none()); @@ -149,7 +149,7 @@ fn zip>(self, other: U) -> Zip { /// # Example /// /// ```rust - /// let a = [1, 2]; + /// let a = [1i, 2]; /// let mut it = a.iter().map(|&x| 2 * x); /// assert_eq!(it.next().unwrap(), 2); /// assert_eq!(it.next().unwrap(), 4); @@ -167,7 +167,7 @@ fn map<'r, B>(self, f: |A|: 'r -> B) -> Map<'r, A, B, Self> { /// # Example /// /// ```rust - /// let a = [1, 2]; + /// let a = [1i, 2]; /// let mut it = a.iter().filter(|&x| *x > 1); /// assert_eq!(it.next().unwrap(), &2); /// assert!(it.next().is_none()); @@ -184,7 +184,7 @@ fn filter<'r>(self, predicate: |&A|: 'r -> bool) -> Filter<'r, A, Self> { /// # Example /// /// ```rust - /// let a = [1, 2]; + /// let a = [1i, 2]; /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None}); /// assert_eq!(it.next().unwrap(), 4); /// assert!(it.next().is_none()); @@ -200,7 +200,7 @@ fn filter_map<'r, B>(self, f: |A|: 'r -> Option) -> FilterMap<'r, A, B, Self> /// # Example /// /// ```rust - /// let a = [100, 200]; + /// let a = [100i, 200]; /// let mut it = a.iter().enumerate(); /// assert_eq!(it.next().unwrap(), (0, &100)); /// assert_eq!(it.next().unwrap(), (1, &200)); @@ -218,7 +218,7 @@ fn enumerate(self) -> Enumerate { /// # Example /// /// ```rust - /// let xs = [100, 200, 300]; + /// let xs = [100i, 200, 300]; /// let mut it = xs.iter().map(|x| *x).peekable(); /// assert_eq!(it.peek().unwrap(), &100); /// assert_eq!(it.next().unwrap(), 100); @@ -241,7 +241,7 @@ fn peekable(self) -> Peekable { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 2, 1]; + /// let a = [1i, 2, 3, 2, 1]; /// let mut it = a.iter().skip_while(|&a| *a < 3); /// assert_eq!(it.next().unwrap(), &3); /// assert_eq!(it.next().unwrap(), &2); @@ -260,7 +260,7 @@ fn skip_while<'r>(self, predicate: |&A|: 'r -> bool) -> SkipWhile<'r, A, Self> { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 2, 1]; + /// let a = [1i, 2, 3, 2, 1]; /// let mut it = a.iter().take_while(|&a| *a < 3); /// assert_eq!(it.next().unwrap(), &1); /// assert_eq!(it.next().unwrap(), &2); @@ -277,7 +277,7 @@ fn take_while<'r>(self, predicate: |&A|: 'r -> bool) -> TakeWhile<'r, A, Self> { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter().skip(3); /// assert_eq!(it.next().unwrap(), &4); /// assert_eq!(it.next().unwrap(), &5); @@ -294,7 +294,7 @@ fn skip(self, n: uint) -> Skip { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter().take(3); /// assert_eq!(it.next().unwrap(), &1); /// assert_eq!(it.next().unwrap(), &2); @@ -314,7 +314,7 @@ fn take(self, n: uint) -> Take { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter().scan(1, |fac, &x| { /// *fac = *fac * x; /// Some(*fac) @@ -378,7 +378,7 @@ fn flat_map<'r, B, U: Iterator>(self, f: |A|: 'r -> U) /// } /// sum /// } - /// let x = vec![1,2,3,7,8,9]; + /// let x = vec![1i,2,3,7,8,9]; /// assert_eq!(process(x.move_iter()), 1006); /// ``` #[inline] @@ -417,7 +417,7 @@ fn inspect<'r>(self, f: |&A|: 'r) -> Inspect<'r, A, Self> { /// # Example /// /// ```rust - /// let mut xs = range(0, 10); + /// let mut xs = range(0u, 10); /// // sum the first five values /// let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b); /// assert!(partial_sum == 10); @@ -434,7 +434,7 @@ fn by_ref<'r>(&'r mut self) -> ByRef<'r, Self> { /// # Example /// /// ```rust - /// range(0, 5).advance(|x| {print!("{} ", x); true}); + /// range(0u, 5).advance(|x| {print!("{} ", x); true}); /// ``` #[inline] fn advance(&mut self, f: |A| -> bool) -> bool { @@ -454,7 +454,7 @@ fn advance(&mut self, f: |A| -> bool) -> bool { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let b: Vec = a.iter().map(|&x| x).collect(); /// assert!(a.as_slice() == b.as_slice()); /// ``` @@ -469,7 +469,7 @@ fn collect>(&mut self) -> B { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.nth(2).unwrap() == &3); /// assert!(it.nth(2) == None); @@ -491,7 +491,7 @@ fn nth(&mut self, mut n: uint) -> Option { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// assert!(a.iter().last().unwrap() == &5); /// ``` #[inline] @@ -507,7 +507,7 @@ fn last(&mut self) -> Option { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// assert!(a.iter().fold(0, |a, &b| a + b) == 15); /// ``` #[inline] @@ -527,7 +527,7 @@ fn fold(&mut self, init: B, f: |B, A| -> B) -> B { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.count() == 5); /// assert!(it.count() == 0); @@ -542,7 +542,7 @@ fn count(&mut self) -> uint { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// assert!(a.iter().all(|x| *x > 0)); /// assert!(!a.iter().all(|x| *x > 2)); /// ``` @@ -558,7 +558,7 @@ fn all(&mut self, f: |A| -> bool) -> bool { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.any(|x| *x == 3)); /// assert!(!it.any(|x| *x == 3)); @@ -801,7 +801,7 @@ pub trait AdditiveIterator { /// ```rust /// use std::iter::AdditiveIterator; /// - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// let mut it = a.iter().map(|&x| x); /// assert!(it.sum() == 15); /// ``` @@ -852,7 +852,7 @@ pub trait OrdIterator { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// assert!(a.iter().max().unwrap() == &5); /// ``` fn max(&mut self) -> Option; @@ -862,7 +862,7 @@ pub trait OrdIterator { /// # Example /// /// ```rust - /// let a = [1, 2, 3, 4, 5]; + /// let a = [1i, 2, 3, 4, 5]; /// assert!(a.iter().min().unwrap() == &1); /// ``` fn min(&mut self) -> Option; @@ -995,10 +995,10 @@ impl MinMaxResult { /// let r: MinMaxResult = NoElements; /// assert_eq!(r.into_option(), None) /// - /// let r = OneElement(1); + /// let r = OneElement(1i); /// assert_eq!(r.into_option(), Some((1,1))); /// - /// let r = MinMax(1,2); + /// let r = MinMax(1i,2i); /// assert_eq!(r.into_option(), Some((1,2))); /// ``` pub fn into_option(self) -> Option<(T,T)> { @@ -1019,7 +1019,7 @@ pub trait CloneableIterator { /// ```rust /// use std::iter::{CloneableIterator, count}; /// - /// let a = count(1,1).take(1); + /// let a = count(1i,1i).take(1); /// let mut cy = a.cycle(); /// assert_eq!(cy.next(), Some(1)); /// assert_eq!(cy.next(), Some(1)); @@ -2285,8 +2285,8 @@ fn test_lt() { use slice::ImmutableVector; let empty: [int, ..0] = []; - let xs = [1,2,3]; - let ys = [1,2,0]; + let xs = [1i,2,3]; + let ys = [1i,2,0]; assert!(!lt(xs.iter(), ys.iter())); assert!(!le(xs.iter(), ys.iter())); @@ -2304,17 +2304,17 @@ fn test_lt() { assert!(!ge(empty.iter(), xs.iter())); // Sequence with NaN - let u = [1.0, 2.0]; - let v = [0.0/0.0, 3.0]; + let u = [1.0f64, 2.0]; + let v = [0.0f64/0.0, 3.0]; assert!(!lt(u.iter(), v.iter())); assert!(!le(u.iter(), v.iter())); assert!(!gt(u.iter(), v.iter())); assert!(!ge(u.iter(), v.iter())); - let a = [0.0/0.0]; - let b = [1.0]; - let c = [2.0]; + let a = [0.0f64/0.0]; + let b = [1.0f64]; + let c = [2.0f64]; assert!(lt(a.iter(), b.iter()) == (a[0] < b[0])); assert!(le(a.iter(), b.iter()) == (a[0] <= b[0])); @@ -2380,7 +2380,7 @@ fn mynext>(i: &mut I) #[test] fn test_counter_from_iter() { - let it = count(0, 5).take(10); + let it = count(0i, 5).take(10); let xs: Vec = FromIterator::from_iter(it); assert!(xs == vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); } @@ -2577,7 +2577,7 @@ fn test_cycle() { #[test] fn test_iterator_nth() { - let v = &[0, 1, 2, 3, 4]; + let v = &[0i, 1, 2, 3, 4]; for i in range(0u, v.len()) { assert_eq!(v.iter().nth(i).unwrap(), &v[i]); } @@ -2585,14 +2585,14 @@ fn test_iterator_nth() { #[test] fn test_iterator_last() { - let v = &[0, 1, 2, 3, 4]; + let v = &[0i, 1, 2, 3, 4]; assert_eq!(v.iter().last().unwrap(), &4); assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0); } #[test] fn test_iterator_len() { - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; assert_eq!(v.slice(0, 4).iter().count(), 4); assert_eq!(v.slice(0, 10).iter().count(), 10); assert_eq!(v.slice(0, 0).iter().count(), 0); @@ -2600,7 +2600,7 @@ fn test_iterator_len() { #[test] fn test_iterator_sum() { - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; assert_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6); assert_eq!(v.iter().map(|&x| x).sum(), 55); assert_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0); @@ -2608,7 +2608,7 @@ fn test_iterator_sum() { #[test] fn test_iterator_product() { - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; assert_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0); assert_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24); assert_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1); @@ -2616,7 +2616,7 @@ fn test_iterator_product() { #[test] fn test_iterator_max() { - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; assert_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3)); assert_eq!(v.iter().map(|&x| x).max(), Some(10)); assert_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None); @@ -2624,7 +2624,7 @@ fn test_iterator_max() { #[test] fn test_iterator_min() { - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; assert_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0)); assert_eq!(v.iter().map(|&x| x).min(), Some(0)); assert_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None); @@ -2632,9 +2632,9 @@ fn test_iterator_min() { #[test] fn test_iterator_size_hint() { - let c = count(0, 1); - let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - let v2 = &[10, 11, 12]; + let c = count(0i, 1); + let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + let v2 = &[10i, 11, 12]; let vi = v.iter(); assert_eq!(c.size_hint(), (uint::MAX, None)); @@ -2669,14 +2669,14 @@ fn test_iterator_size_hint() { #[test] fn test_collect() { - let a = vec![1, 2, 3, 4, 5]; + let a = vec![1i, 2, 3, 4, 5]; let b: Vec = a.iter().map(|&x| x).collect(); assert!(a == b); } #[test] fn test_all() { - let v: Box<&[int]> = box &[1, 2, 3, 4, 5]; + let v: Box<&[int]> = box &[1i, 2, 3, 4, 5]; assert!(v.iter().all(|&x| x < 10)); assert!(!v.iter().all(|&x| x % 2 == 0)); assert!(!v.iter().all(|&x| x > 100)); @@ -2685,7 +2685,7 @@ fn test_all() { #[test] fn test_any() { - let v: Box<&[int]> = box &[1, 2, 3, 4, 5]; + let v: Box<&[int]> = box &[1i, 2, 3, 4, 5]; assert!(v.iter().any(|&x| x < 10)); assert!(v.iter().any(|&x| x % 2 == 0)); assert!(!v.iter().any(|&x| x > 100)); @@ -2694,7 +2694,7 @@ fn test_any() { #[test] fn test_find() { - let v: &[int] = &[1, 3, 9, 27, 103, 14, 11]; + let v: &[int] = &[1i, 3, 9, 27, 103, 14, 11]; assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14); assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3); assert!(v.iter().find(|x| *x % 12 == 0).is_none()); @@ -2702,7 +2702,7 @@ fn test_find() { #[test] fn test_position() { - let v = &[1, 3, 9, 27, 103, 14, 11]; + let v = &[1i, 3, 9, 27, 103, 14, 11]; assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5); assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1); assert!(v.iter().position(|x| *x % 12 == 0).is_none()); @@ -2710,7 +2710,7 @@ fn test_position() { #[test] fn test_count() { - let xs = &[1, 2, 2, 1, 5, 9, 0, 2]; + let xs = &[1i, 2, 2, 1, 5, 9, 0, 2]; assert_eq!(xs.iter().filter(|x| **x == 2).count(), 3); assert_eq!(xs.iter().filter(|x| **x == 5).count(), 1); assert_eq!(xs.iter().filter(|x| **x == 95).count(), 0); @@ -2718,19 +2718,19 @@ fn test_count() { #[test] fn test_max_by() { - let xs: &[int] = &[-3, 0, 1, 5, -10]; + let xs: &[int] = &[-3i, 0, 1, 5, -10]; assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); } #[test] fn test_min_by() { - let xs: &[int] = &[-3, 0, 1, 5, -10]; + let xs: &[int] = &[-3i, 0, 1, 5, -10]; assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); } #[test] fn test_by_ref() { - let mut xs = range(0, 10); + let mut xs = range(0i, 10); // sum the first five values let partial_sum = xs.by_ref().take(5).fold(0, |a, b| a + b); assert_eq!(partial_sum, 10); @@ -2739,7 +2739,7 @@ fn test_by_ref() { #[test] fn test_rev() { - let xs = [2, 4, 6, 8, 10, 12, 14, 16]; + let xs = [2i, 4, 6, 8, 10, 12, 14, 16]; let mut it = xs.iter(); it.next(); it.next(); @@ -2749,7 +2749,7 @@ fn test_rev() { #[test] fn test_double_ended_map() { - let xs = [1, 2, 3, 4, 5, 6]; + let xs = [1i, 2, 3, 4, 5, 6]; let mut it = xs.iter().map(|&x| x * -1); assert_eq!(it.next(), Some(-1)); assert_eq!(it.next(), Some(-2)); @@ -2762,7 +2762,7 @@ fn test_double_ended_map() { #[test] fn test_double_ended_enumerate() { - let xs = [1, 2, 3, 4, 5, 6]; + let xs = [1i, 2, 3, 4, 5, 6]; let mut it = xs.iter().map(|&x| x).enumerate(); assert_eq!(it.next(), Some((0, 1))); assert_eq!(it.next(), Some((1, 2))); @@ -2775,8 +2775,8 @@ fn test_double_ended_enumerate() { #[test] fn test_double_ended_zip() { - let xs = [1, 2, 3, 4, 5, 6]; - let ys = [1, 2, 3, 7]; + let xs = [1i, 2, 3, 4, 5, 6]; + let ys = [1i, 2, 3, 7]; let a = xs.iter().map(|&x| x); let b = ys.iter().map(|&x| x); let mut it = a.zip(b); @@ -2789,7 +2789,7 @@ fn test_double_ended_zip() { #[test] fn test_double_ended_filter() { - let xs = [1, 2, 3, 4, 5, 6]; + let xs = [1i, 2, 3, 4, 5, 6]; let mut it = xs.iter().filter(|&x| *x & 1 == 0); assert_eq!(it.next_back().unwrap(), &6); assert_eq!(it.next_back().unwrap(), &4); @@ -2799,7 +2799,7 @@ fn test_double_ended_filter() { #[test] fn test_double_ended_filter_map() { - let xs = [1, 2, 3, 4, 5, 6]; + let xs = [1i, 2, 3, 4, 5, 6]; let mut it = xs.iter().filter_map(|&x| if x & 1 == 0 { Some(x * 2) } else { None }); assert_eq!(it.next_back().unwrap(), 12); assert_eq!(it.next_back().unwrap(), 8); @@ -2809,8 +2809,8 @@ fn test_double_ended_filter_map() { #[test] fn test_double_ended_chain() { - let xs = [1, 2, 3, 4, 5]; - let ys = [7, 9, 11]; + let xs = [1i, 2, 3, 4, 5]; + let ys = [7i, 9, 11]; let mut it = xs.iter().chain(ys.iter()).rev(); assert_eq!(it.next().unwrap(), &11) assert_eq!(it.next().unwrap(), &9) @@ -2827,7 +2827,7 @@ fn test_double_ended_chain() { fn test_rposition() { fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } - let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; + let v = [(0i, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; assert_eq!(v.iter().rposition(f), Some(3u)); assert!(v.iter().rposition(g).is_none()); @@ -2836,9 +2836,9 @@ fn test_rposition() { #[test] #[should_fail] fn test_rposition_fail() { - let v = [(box 0, box(GC) 0), (box 0, box(GC) 0), - (box 0, box(GC) 0), (box 0, box(GC) 0)]; - let mut i = 0; + let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i), + (box 0i, box(GC) 0i), (box 0i, box(GC) 0i)]; + let mut i = 0i; v.iter().rposition(|_elt| { if i == 2 { fail!() @@ -2854,7 +2854,7 @@ fn check_randacc_iter>(a: T, le { let mut b = a.clone(); assert_eq!(len, b.indexable()); - let mut n = 0; + let mut n = 0u; for (i, elt) in a.enumerate() { assert!(Some(elt) == b.idx(i)); n += 1; @@ -2872,7 +2872,7 @@ fn check_randacc_iter>(a: T, le #[test] fn test_double_ended_flat_map() { let u = [0u,1]; - let v = [5,6,7,8]; + let v = [5u,6,7,8]; let mut it = u.iter().flat_map(|x| v.slice(*x, v.len()).iter()); assert_eq!(it.next_back().unwrap(), &8); assert_eq!(it.next().unwrap(), &5); @@ -2888,8 +2888,8 @@ fn test_double_ended_flat_map() { #[test] fn test_random_access_chain() { - let xs = [1, 2, 3, 4, 5]; - let ys = [7, 9, 11]; + let xs = [1i, 2, 3, 4, 5]; + let ys = [7i, 9, 11]; let mut it = xs.iter().chain(ys.iter()); assert_eq!(it.idx(0).unwrap(), &1); assert_eq!(it.idx(5).unwrap(), &7); @@ -2909,13 +2909,13 @@ fn test_random_access_chain() { #[test] fn test_random_access_enumerate() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; check_randacc_iter(xs.iter().enumerate(), xs.len()); } #[test] fn test_random_access_rev() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; check_randacc_iter(xs.iter().rev(), xs.len()); let mut it = xs.iter().rev(); it.next(); @@ -2926,14 +2926,14 @@ fn test_random_access_rev() { #[test] fn test_random_access_zip() { - let xs = [1, 2, 3, 4, 5]; - let ys = [7, 9, 11]; + let xs = [1i, 2, 3, 4, 5]; + let ys = [7i, 9, 11]; check_randacc_iter(xs.iter().zip(ys.iter()), cmp::min(xs.len(), ys.len())); } #[test] fn test_random_access_take() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; let empty: &[int] = []; check_randacc_iter(xs.iter().take(3), 3); check_randacc_iter(xs.iter().take(20), xs.len()); @@ -2943,7 +2943,7 @@ fn test_random_access_take() { #[test] fn test_random_access_skip() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; let empty: &[int] = []; check_randacc_iter(xs.iter().skip(2), xs.len() - 2); check_randacc_iter(empty.iter().skip(2), 0); @@ -2951,7 +2951,7 @@ fn test_random_access_skip() { #[test] fn test_random_access_inspect() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; // test .map and .inspect that don't implement Clone let mut it = xs.iter().inspect(|_| {}); @@ -2964,7 +2964,7 @@ fn test_random_access_inspect() { #[test] fn test_random_access_map() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; let mut it = xs.iter().map(|x| *x); assert_eq!(xs.len(), it.indexable()); @@ -2975,7 +2975,7 @@ fn test_random_access_map() { #[test] fn test_random_access_cycle() { - let xs = [1, 2, 3, 4, 5]; + let xs = [1i, 2, 3, 4, 5]; let empty: &[int] = []; check_randacc_iter(xs.iter().cycle().take(27), 27); check_randacc_iter(empty.iter().cycle(), 0); @@ -3044,10 +3044,10 @@ fn one() -> Foo { assert!(range(-10i, -1).collect::>() == vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]); assert!(range(0i, 5).rev().collect::>() == vec![4, 3, 2, 1, 0]); - assert_eq!(range(200, -5).count(), 0); - assert_eq!(range(200, -5).rev().count(), 0); - assert_eq!(range(200, 200).count(), 0); - assert_eq!(range(200, 200).rev().count(), 0); + assert_eq!(range(200i, -5).count(), 0); + assert_eq!(range(200i, -5).rev().count(), 0); + assert_eq!(range(200i, 200).count(), 0); + assert_eq!(range(200i, 200).rev().count(), 0); assert_eq!(range(0i, 100).size_hint(), (100, Some(100))); // this test is only meaningful when sizeof uint < sizeof u64 @@ -3062,10 +3062,10 @@ fn test_range_inclusive() { vec![0i, 1, 2, 3, 4, 5]); assert!(range_inclusive(0i, 5).rev().collect::>() == vec![5i, 4, 3, 2, 1, 0]); - assert_eq!(range_inclusive(200, -5).count(), 0); - assert_eq!(range_inclusive(200, -5).rev().count(), 0); - assert!(range_inclusive(200, 200).collect::>() == vec![200]); - assert!(range_inclusive(200, 200).rev().collect::>() == vec![200]); + assert_eq!(range_inclusive(200i, -5).count(), 0); + assert_eq!(range_inclusive(200i, -5).rev().count(), 0); + assert!(range_inclusive(200i, 200).collect::>() == vec![200]); + assert!(range_inclusive(200i, 200).rev().collect::>() == vec![200]); } #[test] @@ -3078,8 +3078,8 @@ fn test_range_step() { vec![20, 14, 8, 2]); assert!(range_step(200u8, 255, 50).collect::>() == vec![200u8, 250]); - assert!(range_step(200, -5, 1).collect::>() == vec![]); - assert!(range_step(200, 200, 1).collect::>() == vec![]); + assert!(range_step(200i, -5, 1).collect::>() == vec![]); + assert!(range_step(200i, 200, 1).collect::>() == vec![]); } #[test] @@ -3092,22 +3092,22 @@ fn test_range_step_inclusive() { vec![20, 14, 8, 2]); assert!(range_step_inclusive(200u8, 255, 50).collect::>() == vec![200u8, 250]); - assert!(range_step_inclusive(200, -5, 1).collect::>() == + assert!(range_step_inclusive(200i, -5, 1).collect::>() == vec![]); - assert!(range_step_inclusive(200, 200, 1).collect::>() == + assert!(range_step_inclusive(200i, 200, 1).collect::>() == vec![200]); } #[test] fn test_reverse() { - let mut ys = [1, 2, 3, 4, 5]; + let mut ys = [1i, 2, 3, 4, 5]; ys.mut_iter().reverse_(); assert!(ys == [5, 4, 3, 2, 1]); } #[test] fn test_peekable_is_empty() { - let a = [1]; + let a = [1i]; let mut it = a.iter().peekable(); assert!( !it.is_empty() ); it.next(); @@ -3137,10 +3137,10 @@ fn test_min_max_result() { let r: MinMaxResult = NoElements; assert_eq!(r.into_option(), None) - let r = OneElement(1); + let r = OneElement(1i); assert_eq!(r.into_option(), Some((1,1))); - let r = MinMax(1,2); + let r = MinMax(1i,2); assert_eq!(r.into_option(), Some((1,2))); } } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 6b97e6479df..a2a3e09a93c 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -324,7 +324,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// ``` /// use std::cell::RefCell; /// -/// let x = RefCell::new(1); +/// let x = RefCell::new(1i); /// /// let mut mutable_borrow = x.borrow_mut(); /// *mutable_borrow = 1; @@ -458,8 +458,8 @@ fn align_of_val_basic() { #[test] fn test_swap() { - let mut x = 31337; - let mut y = 42; + let mut x = 31337i; + let mut y = 42i; swap(&mut x, &mut y); assert_eq!(x, 42); assert_eq!(y, 31337); @@ -483,7 +483,7 @@ fn test_transmute() { trait Foo {} impl Foo for int {} - let a = box 100 as Box; + let a = box 100i as Box; unsafe { let x: raw::TraitObject = transmute(a); assert!(*(x.data as *int) == 100); diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 573470c29bc..512c107b930 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -322,7 +322,7 @@ pub trait Unsigned: Num {} /// ```rust /// use std::num; /// -/// assert_eq!(num::pow(2, 4), 16); +/// assert_eq!(num::pow(2i, 4), 16); /// ``` #[inline] pub fn pow>(mut base: T, mut exp: uint) -> T { @@ -1144,7 +1144,7 @@ impl FromPrimitive for $T { /// ``` /// use std::num; /// -/// let twenty: f32 = num::cast(0x14).unwrap(); +/// let twenty: f32 = num::cast(0x14i).unwrap(); /// assert_eq!(twenty, 20f32); /// ``` /// @@ -1378,11 +1378,11 @@ fn checked_div(&self, v: &$t) -> Option<$t> { /// Helper function for testing numeric operations #[cfg(test)] pub fn test_num(ten: T, two: T) { - assert_eq!(ten.add(&two), cast(12).unwrap()); - assert_eq!(ten.sub(&two), cast(8).unwrap()); - assert_eq!(ten.mul(&two), cast(20).unwrap()); - assert_eq!(ten.div(&two), cast(5).unwrap()); - assert_eq!(ten.rem(&two), cast(0).unwrap()); + assert_eq!(ten.add(&two), cast(12i).unwrap()); + assert_eq!(ten.sub(&two), cast(8i).unwrap()); + assert_eq!(ten.mul(&two), cast(20i).unwrap()); + assert_eq!(ten.div(&two), cast(5i).unwrap()); + assert_eq!(ten.rem(&two), cast(0i).unwrap()); assert_eq!(ten.add(&two), ten + two); assert_eq!(ten.sub(&two), ten - two); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index af1df973a3e..14edd7c70a8 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -570,11 +570,18 @@ pub trait Shl { macro_rules! shl_impl( ($($t:ty)*) => ($( - #[cfg(not(test))] + #[cfg(stage0)] impl Shl<$t, $t> for $t { #[inline] fn shl(&self, other: &$t) -> $t { (*self) << (*other) } } + #[cfg(not(stage0), not(test))] + impl Shl<$t, $t> for $t { + #[inline] + fn shl(&self, other: &$t) -> $t { + (*self) << (*other as uint) + } + } )*) ) @@ -612,11 +619,16 @@ pub trait Shr { macro_rules! shr_impl( ($($t:ty)*) => ($( - #[cfg(not(test))] + #[cfg(stage0, not(test))] impl Shr<$t, $t> for $t { #[inline] fn shr(&self, other: &$t) -> $t { (*self) >> (*other) } } + #[cfg(not(stage0), not(test))] + impl Shr<$t, $t> for $t { + #[inline] + fn shr(&self, other: &$t) -> $t { (*self) >> (*other as uint) } + } )*) ) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a4d33ae8028..e9fb7c3dae3 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -505,8 +505,8 @@ impl Option { /// let good_year = from_str(good_year_from_input).unwrap_or_default(); /// let bad_year = from_str(bad_year_from_input).unwrap_or_default(); /// - /// assert_eq!(1909, good_year); - /// assert_eq!(0, bad_year); + /// assert_eq!(1909i, good_year); + /// assert_eq!(0i, bad_year); /// ``` #[inline] pub fn unwrap_or_default(self) -> T { @@ -675,7 +675,7 @@ fn realclone(t: &T) -> T { t.clone() } - let i = Rc::new(RefCell::new(0)); + let i = Rc::new(RefCell::new(0i)); { let x = r(realclone(&i)); let opt = Some(x); @@ -687,7 +687,7 @@ fn realclone(t: &T) -> T { #[test] fn test_option_dance() { let x = Some(()); - let mut y = Some(5); + let mut y = Some(5i); let mut y2 = 0; for _x in x.iter() { y2 = y.take_unwrap(); @@ -705,12 +705,12 @@ fn test_option_too_much_dance() { #[test] fn test_and() { - let x: Option = Some(1); - assert_eq!(x.and(Some(2)), Some(2)); + let x: Option = Some(1i); + assert_eq!(x.and(Some(2i)), Some(2)); assert_eq!(x.and(None::), None); let x: Option = None; - assert_eq!(x.and(Some(2)), None); + assert_eq!(x.and(Some(2i)), None); assert_eq!(x.and(None::), None); } @@ -749,7 +749,7 @@ fn test_or_else() { #[test] fn test_option_while_some() { - let mut i = 0; + let mut i = 0i; Some(10).while_some(|j| { i += 1; if j > 0 { @@ -763,7 +763,7 @@ fn test_option_while_some() { #[test] fn test_unwrap() { - assert_eq!(Some(1).unwrap(), 1); + assert_eq!(Some(1i).unwrap(), 1); let s = Some("hello".to_string()).unwrap(); assert_eq!(s.as_slice(), "hello"); } @@ -802,7 +802,7 @@ fn test_unwrap_or_else() { #[test] fn test_filtered() { - let some_stuff = Some(42); + let some_stuff = Some(42i); let modified_stuff = some_stuff.filtered(|&x| {x < 10}); assert_eq!(some_stuff.unwrap(), 42); assert!(modified_stuff.is_none()); @@ -810,7 +810,7 @@ fn test_filtered() { #[test] fn test_iter() { - let val = 5; + let val = 5i; let x = Some(val); let mut it = x.iter(); @@ -823,8 +823,8 @@ fn test_iter() { #[test] fn test_mut_iter() { - let val = 5; - let new_val = 11; + let val = 5i; + let new_val = 11i; let mut x = Some(val); { @@ -848,9 +848,9 @@ fn test_mut_iter() { #[test] fn test_ord() { - let small = Some(1.0); - let big = Some(5.0); - let nan = Some(0.0/0.0); + let small = Some(1.0f64); + let big = Some(5.0f64); + let nan = Some(0.0f64/0.0); assert!(!(nan < big)); assert!(!(nan > big)); assert!(small < big); @@ -874,15 +874,15 @@ fn test_mutate() { #[test] fn test_collect() { - let v: Option> = collect(range(0, 0) - .map(|_| Some(0))); + let v: Option> = collect(range(0i, 0) + .map(|_| Some(0i))); assert!(v == Some(vec![])); - let v: Option> = collect(range(0, 3) + let v: Option> = collect(range(0i, 3) .map(|x| Some(x))); assert!(v == Some(vec![0, 1, 2])); - let v: Option> = collect(range(0, 3) + let v: Option> = collect(range(0i, 3) .map(|x| if x > 1 { None } else { Some(x) })); assert!(v == None); diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c37c66f9862..59d7bbfe52d 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -624,7 +624,7 @@ fn test_to_option() { #[test] fn test_ptr_addition() { unsafe { - let xs = Vec::from_elem(16, 5); + let xs = Vec::from_elem(16, 5i); let mut ptr = xs.as_ptr(); let end = ptr.offset(16); @@ -642,7 +642,7 @@ fn test_ptr_addition() { m_ptr = m_ptr.offset(1); } - assert!(xs_mut == Vec::from_elem(16, 10)); + assert!(xs_mut == Vec::from_elem(16, 10i)); } } @@ -719,8 +719,8 @@ fn test_ptr_array_each() { ]; let arr_ptr = arr.as_ptr(); - let mut ctr = 0; - let mut iteration_count = 0; + let mut ctr = 0u; + let mut iteration_count = 0u; array_each(arr_ptr, |e| { let actual = str::raw::from_c_str(e); let expected = expected_arr[ctr].with_ref(|buf| { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 3f82190e6b7..6c163b79199 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -654,11 +654,11 @@ pub fn op2() -> Result { Err("sadface") } #[test] pub fn test_and() { - assert_eq!(op1().and(Ok(667)).unwrap(), 667); + assert_eq!(op1().and(Ok(667i)).unwrap(), 667); assert_eq!(op1().and(Err::<(), &'static str>("bad")).unwrap_err(), "bad"); - assert_eq!(op2().and(Ok(667)).unwrap_err(), "sadface"); + assert_eq!(op2().and(Ok(667i)).unwrap_err(), "sadface"); assert_eq!(op2().and(Err::<(),&'static str>("bad")).unwrap_err(), "sadface"); } @@ -708,18 +708,18 @@ pub fn test_impl_map_err() { #[test] fn test_collect() { - let v: Result, ()> = collect(range(0, 0).map(|_| Ok::(0))); + let v: Result, ()> = collect(range(0i, 0).map(|_| Ok::(0))); assert!(v == Ok(vec![])); - let v: Result, ()> = collect(range(0, 3).map(|x| Ok::(x))); + let v: Result, ()> = collect(range(0i, 3).map(|x| Ok::(x))); assert!(v == Ok(vec![0, 1, 2])); - let v: Result, int> = collect(range(0, 3) + let v: Result, int> = collect(range(0i, 3) .map(|x| if x > 1 { Err(x) } else { Ok(x) })); assert!(v == Err(2)); // test that it does not take more elements than it needs - let mut functions = [|| Ok(()), || Err(1), || fail!()]; + let mut functions = [|| Ok(()), || Err(1i), || fail!()]; let v: Result, int> = collect(functions.mut_iter().map(|f| (*f)())); assert!(v == Err(1)); @@ -727,19 +727,19 @@ fn test_collect() { #[test] fn test_fold() { - assert_eq!(fold_(range(0, 0) + assert_eq!(fold_(range(0i, 0) .map(|_| Ok::<(), ()>(()))), Ok(())); - assert_eq!(fold(range(0, 3) + assert_eq!(fold(range(0i, 3) .map(|x| Ok::(x)), 0, |a, b| a + b), Ok(3)); - assert_eq!(fold_(range(0, 3) + assert_eq!(fold_(range(0i, 3) .map(|x| if x > 1 { Err(x) } else { Ok(()) })), Err(2)); // test that it does not take more elements than it needs - let mut functions = [|| Ok(()), || Err(1), || fail!()]; + let mut functions = [|| Ok(()), || Err(1i), || fail!()]; assert_eq!(fold_(functions.mut_iter() .map(|f| (*f)())), @@ -759,7 +759,7 @@ pub fn test_fmt_default() { #[test] pub fn test_unwrap_or() { - let ok: Result = Ok(100); + let ok: Result = Ok(100i); let ok_err: Result = Err("Err"); assert_eq!(ok.unwrap_or(50), 100); @@ -770,7 +770,7 @@ pub fn test_unwrap_or() { pub fn test_unwrap_or_else() { fn handler(msg: &'static str) -> int { if msg == "I got this." { - 50 + 50i } else { fail!("BadBad") } @@ -788,7 +788,7 @@ fn handler(msg: &'static str) -> int { pub fn test_unwrap_or_else_failure() { fn handler(msg: &'static str) -> int { if msg == "I got this." { - 50 + 50i } else { fail!("BadBad") } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index bb24d53458c..14b5f7a6d60 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -376,7 +376,7 @@ pub trait ImmutableVector<'a, T> { * `[3,4]`): * * ```rust - * let v = &[1,2,3,4]; + * let v = &[1i, 2, 3, 4]; * for win in v.windows(2) { * println!("{}", win); * } @@ -401,7 +401,7 @@ pub trait ImmutableVector<'a, T> { * `[3,4]`, `[5]`): * * ```rust - * let v = &[1,2,3,4,5]; + * let v = &[1i, 2, 3, 4, 5]; * for win in v.chunks(2) { * println!("{}", win); * } @@ -830,24 +830,24 @@ pub trait MutableVector<'a, T> { /// # Example /// /// ```rust - /// let mut v = [1, 2, 3, 4, 5, 6]; + /// let mut v = [1i, 2, 3, 4, 5, 6]; /// /// // scoped to restrict the lifetime of the borrows /// { /// let (left, right) = v.mut_split_at(0); /// assert!(left == &mut []); - /// assert!(right == &mut [1, 2, 3, 4, 5, 6]); + /// assert!(right == &mut [1i, 2, 3, 4, 5, 6]); /// } /// /// { /// let (left, right) = v.mut_split_at(2); - /// assert!(left == &mut [1, 2]); - /// assert!(right == &mut [3, 4, 5, 6]); + /// assert!(left == &mut [1i, 2]); + /// assert!(right == &mut [3i, 4, 5, 6]); /// } /// /// { /// let (left, right) = v.mut_split_at(6); - /// assert!(left == &mut [1, 2, 3, 4, 5, 6]); + /// assert!(left == &mut [1i, 2, 3, 4, 5, 6]); /// assert!(right == &mut []); /// } /// ``` @@ -858,9 +858,9 @@ pub trait MutableVector<'a, T> { /// # Example /// /// ```rust - /// let mut v = [1, 2, 3]; + /// let mut v = [1i, 2, 3]; /// v.reverse(); - /// assert!(v == [3, 2, 1]); + /// assert!(v == [3i, 2, 1]); /// ``` fn reverse(self); @@ -1080,15 +1080,15 @@ pub trait MutableCloneableVector { /// ```rust /// use std::slice::MutableCloneableVector; /// - /// let mut dst = [0, 0, 0]; - /// let src = [1, 2]; + /// let mut dst = [0i, 0, 0]; + /// let src = [1i, 2]; /// /// assert!(dst.copy_from(src) == 2); /// assert!(dst == [1, 2, 0]); /// - /// let src2 = [3, 4, 5, 6]; + /// let src2 = [3i, 4, 5, 6]; /// assert!(dst.copy_from(src2) == 3); - /// assert!(dst == [3, 4, 5]); + /// assert!(dst == [3i, 4, 5]); /// ``` fn copy_from(self, &[T]) -> uint; } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 84ffb7fb20e..13efeab57d4 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -364,7 +364,8 @@ fn new(needle: &[u8]) -> TwoWaySearcher { period = period2; } - let byteset = needle.iter().fold(0, |a, &b| (1 << (b & 0x3f)) | a); + let byteset = needle.iter() + .fold(0, |a, &b| (1 << ((b & 0x3f) as uint)) | a); if needle.slice_to(critPos) == needle.slice_from(needle.len() - critPos) { TwoWaySearcher { @@ -396,7 +397,9 @@ fn next(&mut self, haystack: &[u8], needle: &[u8], longPeriod: bool) -> Option<( } // Quickly skip by large portions unrelated to our substring - if (self.byteset >> (haystack[self.position + needle.len() - 1] & 0x3f)) & 1 == 0 { + if (self.byteset >> + ((haystack[self.position + needle.len() - 1] & 0x3f) + as uint)) & 1 == 0 { self.position += needle.len(); continue 'search; } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index c8cbd49aa89..18511474ecf 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -38,9 +38,9 @@ //! Using methods: //! //! ``` -//! let pair = ("pi", 3.14); +//! let pair = ("pi", 3.14f64); //! assert_eq!(pair.val0(), "pi"); -//! assert_eq!(pair.val1(), 3.14); +//! assert_eq!(pair.val1(), 3.14f64); //! ``` //! //! Using traits implemented for tuples: @@ -48,8 +48,8 @@ //! ``` //! use std::default::Default; //! -//! let a = (1, 2); -//! let b = (3, 4); +//! let a = (1i, 2i); +//! let b = (3i, 4i); //! assert!(a != b); //! //! let c = b.clone(); @@ -300,7 +300,7 @@ mod tests { #[test] fn test_clone() { - let a = (1, "2"); + let a = (1i, "2"); let b = a.clone(); assert_eq!(a, b); } @@ -335,7 +335,7 @@ macro_rules! test_getter( fn test_tuple_cmp() { let (small, big) = ((1u, 2u, 3u), (3u, 2u, 1u)); - let nan = 0.0/0.0; + let nan = 0.0f64/0.0; // PartialEq assert_eq!(small, small); @@ -357,12 +357,12 @@ fn test_tuple_cmp() { assert!(big >= small); assert!(big >= big); - assert!(!((1.0, 2.0) < (nan, 3.0))); - assert!(!((1.0, 2.0) <= (nan, 3.0))); - assert!(!((1.0, 2.0) > (nan, 3.0))); - assert!(!((1.0, 2.0) >= (nan, 3.0))); - assert!(((1.0, 2.0) < (2.0, nan))); - assert!(!((2.0, 2.0) < (2.0, nan))); + assert!(!((1.0f64, 2.0f64) < (nan, 3.0))); + assert!(!((1.0f64, 2.0f64) <= (nan, 3.0))); + assert!(!((1.0f64, 2.0f64) > (nan, 3.0))); + assert!(!((1.0f64, 2.0f64) >= (nan, 3.0))); + assert!(((1.0f64, 2.0f64) < (2.0, nan))); + assert!(!((2.0f64, 2.0f64) < (2.0, nan))); // Ord assert!(small.cmp(&small) == Equal); @@ -373,11 +373,11 @@ fn test_tuple_cmp() { #[test] fn test_show() { - let s = format!("{}", (1,)); + let s = format!("{}", (1i,)); assert_eq!(s.as_slice(), "(1,)"); - let s = format!("{}", (1, true)); + let s = format!("{}", (1i, true)); assert_eq!(s.as_slice(), "(1, true)"); - let s = format!("{}", (1, "hi", true)); + let s = format!("{}", (1i, "hi", true)); assert_eq!(s.as_slice(), "(1, hi, true)"); } } diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 188596891be..26e9b2aa372 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -116,14 +116,14 @@ mod tests { fn test_flate_round_trip() { let mut r = rand::task_rng(); let mut words = vec!(); - for _ in range(0, 20) { + for _ in range(0u, 20) { let range = r.gen_range(1u, 10); let v = r.gen_iter::().take(range).collect::>(); words.push(v); } - for _ in range(0, 20) { + for _ in range(0u, 20) { let mut input = vec![]; - for _ in range(0, 2000) { + for _ in range(0u, 2000) { input.push_all(r.choose(words.as_slice()).unwrap().as_slice()); } debug!("de/inflate of {} bytes of random word-sequences", diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 495acdbab62..f80208c4743 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -686,13 +686,13 @@ fn test_lots_of_files() { fn test_range_pattern() { let pat = Pattern::new("a[0-9]b"); - for i in range(0, 10) { + for i in range(0u, 10) { assert!(pat.matches(format!("a{}b", i).as_slice())); } assert!(!pat.matches("a_b")); let pat = Pattern::new("a[!0-9]b"); - for i in range(0, 10) { + for i in range(0u, 10) { assert!(!pat.matches(format!("a{}b", i).as_slice())); } assert!(pat.matches("a_b")); diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index 2381626b7c8..d0224749781 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -245,7 +245,7 @@ fn multi_thread() { event_loop_factory: basic::event_loop, }); - for _ in range(0, 20) { + for _ in range(0u, 20) { pool.spawn(TaskOpts::new(), proc() { let (tx, rx) = channel(); spawn(proc() { diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index 75af52ac680..0402a93e468 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1336,7 +1336,7 @@ fn no_missed_messages() { fn multithreading() { run(proc() { let mut rxs = vec![]; - for _ in range(0, 10) { + for _ in range(0u, 10) { let (tx, rx) = channel(); spawn(proc() { tx.send(()); @@ -1469,7 +1469,7 @@ fn dont_starve_2() { fn single_threaded_yield() { use std::task::deschedule; run(proc() { - for _ in range(0, 5) { deschedule(); } + for _ in range(0u, 5) { deschedule(); } }); } @@ -1480,7 +1480,7 @@ fn test_spawn_sched_blocking() { // Testing that a task in one scheduler can block in foreign code // without affecting other schedulers - for _ in range(0, 20) { + for _ in range(0u, 20) { let mut pool = pool(); let (start_tx, start_rx) = channel(); let (fin_tx, fin_rx) = channel(); diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 91ebad3b3f8..692b6e14fe7 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -536,7 +536,7 @@ fn smoke_opts_fail() { fn yield_test() { let (tx, rx) = channel(); spawn_opts(TaskOpts::new(), proc() { - for _ in range(0, 10) { task::deschedule(); } + for _ in range(0u, 10) { task::deschedule(); } tx.send(()); }); rx.recv(); diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index ddc2872b7ae..41a741eb1df 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -23,7 +23,7 @@ fn main() { error!("this is printed by default"); if log_enabled!(log::INFO) { - let x = 3 * 4; // expensive computation + let x = 3i * 4i; // expensive computation info!("the answer was: {}", x); } } diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index dba34c42a7e..fe74b7d67ff 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -27,7 +27,7 @@ /// # fn main() { /// log!(log::DEBUG, "this is a debug message"); /// log!(log::WARN, "this is a warning {}", "message"); -/// log!(6, "this is a custom logging level: {level}", level=6); +/// log!(6, "this is a custom logging level: {level}", level=6u); /// # } /// ``` #[macro_export] @@ -54,7 +54,7 @@ macro_rules! log( /// #[phase(plugin, link)] extern crate log; /// /// # fn main() { -/// # let error = 3; +/// # let error = 3u; /// error!("the build has failed with error code: {}", error); /// # } /// ``` @@ -72,7 +72,7 @@ macro_rules! error( /// #[phase(plugin, link)] extern crate log; /// /// # fn main() { -/// # let code = 3; +/// # let code = 3u; /// warn!("you may like to know that a process exited with: {}", code); /// # } /// ``` @@ -90,7 +90,7 @@ macro_rules! warn( /// #[phase(plugin, link)] extern crate log; /// /// # fn main() { -/// # let ret = 3; +/// # let ret = 3i; /// info!("this function is about to return: {}", ret); /// # } /// ``` @@ -110,7 +110,7 @@ macro_rules! info( /// #[phase(plugin, link)] extern crate log; /// /// # fn main() { -/// debug!("x = {x}, y = {y}", x=10, y=20); +/// debug!("x = {x}, y = {y}", x=10i, y=20i); /// # } /// ``` #[macro_export] diff --git a/src/libnative/io/c_unix.rs b/src/libnative/io/c_unix.rs index 7a52c048498..b1bc36e0b05 100644 --- a/src/libnative/io/c_unix.rs +++ b/src/libnative/io/c_unix.rs @@ -93,7 +93,7 @@ pub struct fd_set { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[(fd / 32) as uint] |= 1 << (fd % 32); + set.fds_bits[(fd / 32) as uint] |= 1 << ((fd % 32) as uint); } } diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 88e581a4791..8b7c8e61bc3 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -328,7 +328,7 @@ fn smoke_opts_fail() { fn yield_test() { let (tx, rx) = channel(); spawn(proc() { - for _ in range(0, 10) { task::deschedule(); } + for _ in range(0u, 10) { task::deschedule(); } tx.send(()); }); rx.recv(); diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index e9153f89e04..06e4792cdcc 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -2172,7 +2172,7 @@ fn test_rand() { fn test_rand_range() { let mut rng = task_rng(); - for _ in range(0, 10) { + for _ in range(0u, 10) { assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), &FromPrimitive::from_uint(237).unwrap()), FromPrimitive::from_uint(236).unwrap()); @@ -2180,7 +2180,7 @@ fn test_rand_range() { let l = FromPrimitive::from_uint(403469000 + 2352).unwrap(); let u = FromPrimitive::from_uint(403469000 + 3513).unwrap(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let n: BigUint = rng.gen_biguint_below(&u); assert!(n < u); @@ -2761,7 +2761,7 @@ fn test_rand() { fn test_rand_range() { let mut rng = task_rng(); - for _ in range(0, 10) { + for _ in range(0u, 10) { assert_eq!(rng.gen_bigint_range(&FromPrimitive::from_uint(236).unwrap(), &FromPrimitive::from_uint(237).unwrap()), FromPrimitive::from_uint(236).unwrap()); @@ -2769,7 +2769,7 @@ fn test_rand_range() { fn check(l: BigInt, u: BigInt) { let mut rng = task_rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let n: BigInt = rng.gen_bigint_range(&l, &u); assert!(n >= l); assert!(n < u); @@ -2858,7 +2858,7 @@ fn shr(b: &mut Bencher) { let n = { let one : BigUint = One::one(); one << 1000 }; b.iter(|| { let mut m = n.clone(); - for _ in range(0, 10) { + for _ in range(0u, 10) { m = m >> 1; } }) diff --git a/src/libnum/rational.rs b/src/libnum/rational.rs index faf05365c04..971b6b1b51b 100644 --- a/src/libnum/rational.rs +++ b/src/libnum/rational.rs @@ -353,10 +353,10 @@ fn test_test_constants() { // check our constants are what Ratio::new etc. would make. assert_eq!(_0, Zero::zero()); assert_eq!(_1, One::one()); - assert_eq!(_2, Ratio::from_integer(2)); - assert_eq!(_1_2, Ratio::new(1,2)); - assert_eq!(_3_2, Ratio::new(3,2)); - assert_eq!(_neg1_2, Ratio::new(-1,2)); + assert_eq!(_2, Ratio::from_integer(2i)); + assert_eq!(_1_2, Ratio::new(1i,2i)); + assert_eq!(_3_2, Ratio::new(3i,2i)); + assert_eq!(_neg1_2, Ratio::new(-1i,2i)); } #[test] @@ -368,7 +368,7 @@ fn test_new_reduce() { #[test] #[should_fail] fn test_new_zero() { - let _a = Ratio::new(1,0); + let _a = Ratio::new(1i,0); } @@ -466,8 +466,8 @@ fn test(a: Rational, b: Rational, c: Rational) { } test(_1, _1_2, _1_2); - test(_1_2, _3_2, Ratio::new(3,4)); - test(_1_2, _neg1_2, Ratio::new(-1, 4)); + test(_1_2, _3_2, Ratio::new(3i,4i)); + test(_1_2, _neg1_2, Ratio::new(-1i, 4i)); } #[test] @@ -606,7 +606,7 @@ fn test16(r: Rational, s: String) { test(r, s, 16) } test16(_2, "2/1".to_string()); test16(_neg1_2, "-1/2".to_string()); test16(_neg1_2 / _2, "-1/4".to_string()); - test16(Ratio::new(13,15), "d/f".to_string()); + test16(Ratio::new(13i,15i), "d/f".to_string()); test16(_1_2*_1_2*_1_2*_1_2, "1/10".to_string()); } @@ -645,7 +645,7 @@ fn test(given: T, (numer, denom): (&str, &str)) { test(2f64.powf(100.), ("1267650600228229401496703205376", "1")); test(-2f64.powf(100.), ("-1267650600228229401496703205376", "1")); test(684729.48391f64, ("367611342500051", "536870912")); - test(-8573.5918555, ("-4713381968463931", "549755813888")); + test(-8573.5918555f64, ("-4713381968463931", "549755813888")); test(1.0 / 2f64.powf(100.), ("1", "1267650600228229401496703205376")); } diff --git a/src/librand/distributions/exponential.rs b/src/librand/distributions/exponential.rs index d4e689ccb5c..7d1a4409718 100644 --- a/src/librand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -101,7 +101,7 @@ mod test { fn test_exp() { let mut exp = Exp::new(10.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { assert!(exp.sample(&mut rng) >= 0.0); assert!(exp.ind_sample(&mut rng) >= 0.0); } diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs index b1a95149830..a9f24e1a9ec 100644 --- a/src/librand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -327,7 +327,7 @@ mod test { fn test_chi_squared_one() { let mut chi = ChiSquared::new(1.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { chi.sample(&mut rng); chi.ind_sample(&mut rng); } @@ -336,7 +336,7 @@ fn test_chi_squared_one() { fn test_chi_squared_small() { let mut chi = ChiSquared::new(0.5); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { chi.sample(&mut rng); chi.ind_sample(&mut rng); } @@ -345,7 +345,7 @@ fn test_chi_squared_small() { fn test_chi_squared_large() { let mut chi = ChiSquared::new(30.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { chi.sample(&mut rng); chi.ind_sample(&mut rng); } @@ -360,7 +360,7 @@ fn test_chi_squared_invalid_dof() { fn test_f() { let mut f = FisherF::new(2.0, 32.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { f.sample(&mut rng); f.ind_sample(&mut rng); } @@ -370,7 +370,7 @@ fn test_f() { fn test_t() { let mut t = StudentT::new(11.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { t.sample(&mut rng); t.ind_sample(&mut rng); } diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 2e3c0394747..faafbc4421e 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -101,7 +101,7 @@ pub struct Weighted { /// Weighted { weight: 1, item: 'c' }); /// let wc = WeightedChoice::new(items.as_mut_slice()); /// let mut rng = rand::task_rng(); -/// for _ in range(0, 16) { +/// for _ in range(0u, 16) { /// // on average prints 'a' 4 times, 'b' 8 and 'c' twice. /// println!("{}", wc.ind_sample(&mut rng)); /// } @@ -308,36 +308,36 @@ macro_rules! t ( }} ); - t!(vec!(Weighted { weight: 1, item: 10}), [10]); + t!(vec!(Weighted { weight: 1, item: 10i}), [10]); // skip some - t!(vec!(Weighted { weight: 0, item: 20}, - Weighted { weight: 2, item: 21}, - Weighted { weight: 0, item: 22}, - Weighted { weight: 1, item: 23}), + t!(vec!(Weighted { weight: 0, item: 20i}, + Weighted { weight: 2, item: 21i}, + Weighted { weight: 0, item: 22i}, + Weighted { weight: 1, item: 23i}), [21,21, 23]); // different weights - t!(vec!(Weighted { weight: 4, item: 30}, - Weighted { weight: 3, item: 31}), + t!(vec!(Weighted { weight: 4, item: 30i}, + Weighted { weight: 3, item: 31i}), [30,30,30,30, 31,31,31]); // check that we're binary searching // correctly with some vectors of odd // length. - t!(vec!(Weighted { weight: 1, item: 40}, - Weighted { weight: 1, item: 41}, - Weighted { weight: 1, item: 42}, - Weighted { weight: 1, item: 43}, - Weighted { weight: 1, item: 44}), + t!(vec!(Weighted { weight: 1, item: 40i}, + Weighted { weight: 1, item: 41i}, + Weighted { weight: 1, item: 42i}, + Weighted { weight: 1, item: 43i}, + Weighted { weight: 1, item: 44i}), [40, 41, 42, 43, 44]); - t!(vec!(Weighted { weight: 1, item: 50}, - Weighted { weight: 1, item: 51}, - Weighted { weight: 1, item: 52}, - Weighted { weight: 1, item: 53}, - Weighted { weight: 1, item: 54}, - Weighted { weight: 1, item: 55}, - Weighted { weight: 1, item: 56}), + t!(vec!(Weighted { weight: 1, item: 50i}, + Weighted { weight: 1, item: 51i}, + Weighted { weight: 1, item: 52i}, + Weighted { weight: 1, item: 53i}, + Weighted { weight: 1, item: 54i}, + Weighted { weight: 1, item: 55i}, + Weighted { weight: 1, item: 56i}), [50, 51, 52, 53, 54, 55, 56]); } @@ -347,15 +347,15 @@ fn test_weighted_choice_no_items() { } #[test] #[should_fail] fn test_weighted_choice_zero_weight() { - WeightedChoice::new(&mut [Weighted { weight: 0, item: 0}, - Weighted { weight: 0, item: 1}]); + WeightedChoice::new(&mut [Weighted { weight: 0, item: 0i}, + Weighted { weight: 0, item: 1i}]); } #[test] #[should_fail] fn test_weighted_choice_weight_overflows() { let x = (-1) as uint / 2; // x + x + 2 is the overflow - WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, - Weighted { weight: 1, item: 1 }, - Weighted { weight: x, item: 2 }, - Weighted { weight: 1, item: 3 }]); + WeightedChoice::new(&mut [Weighted { weight: x, item: 0i }, + Weighted { weight: 1, item: 1i }, + Weighted { weight: x, item: 2i }, + Weighted { weight: 1, item: 3i }]); } } diff --git a/src/librand/distributions/normal.rs b/src/librand/distributions/normal.rs index 47ab7d32e05..507cafd2835 100644 --- a/src/librand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -158,7 +158,7 @@ mod tests { fn test_normal() { let mut norm = Normal::new(10.0, 10.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { norm.sample(&mut rng); norm.ind_sample(&mut rng); } @@ -174,7 +174,7 @@ fn test_normal_invalid_sd() { fn test_log_normal() { let mut lnorm = LogNormal::new(10.0, 10.0); let mut rng = ::test::rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { lnorm.sample(&mut rng); lnorm.ind_sample(&mut rng); } diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index 13f6d2e81c0..a6b23957fd6 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -42,7 +42,7 @@ /// let between = Range::new(10u, 10000u); /// let mut rng = rand::task_rng(); /// let mut sum = 0; -/// for _ in range(0, 1000) { +/// for _ in range(0u, 1000) { /// sum += between.ind_sample(&mut rng); /// } /// println!("{}", sum); @@ -172,12 +172,12 @@ mod tests { #[should_fail] #[test] fn test_range_bad_limits_equal() { - Range::new(10, 10); + Range::new(10i, 10i); } #[should_fail] #[test] fn test_range_bad_limits_flipped() { - Range::new(10, 5); + Range::new(10i, 5i); } #[test] @@ -191,7 +191,7 @@ macro_rules! t ( (Bounded::min_value(), Bounded::max_value())]; for &(low, high) in v.iter() { let mut sampler: Range<$ty> = Range::new(low, high); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let v = sampler.sample(&mut rng); assert!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); @@ -217,7 +217,7 @@ macro_rules! t ( (-1e35, 1e35)]; for &(low, high) in v.iter() { let mut sampler: Range<$ty> = Range::new(low, high); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let v = sampler.sample(&mut rng); assert!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 83b86e1e158..3fff27d4792 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -18,7 +18,8 @@ use {Rng, SeedableRng, Rand}; static RAND_SIZE_LEN: u32 = 8; -static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; +static RAND_SIZE: u32 = 1 << (RAND_SIZE_LEN as uint); +static RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint); /// A random number generator that uses the ISAAC algorithm[1]. /// @@ -31,16 +32,16 @@ /// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html) pub struct IsaacRng { cnt: u32, - rsl: [u32, .. RAND_SIZE], - mem: [u32, .. RAND_SIZE], + rsl: [u32, ..RAND_SIZE_UINT], + mem: [u32, ..RAND_SIZE_UINT], a: u32, b: u32, c: u32 } static EMPTY: IsaacRng = IsaacRng { cnt: 0, - rsl: [0, .. RAND_SIZE], - mem: [0, .. RAND_SIZE], + rsl: [0, ..RAND_SIZE_UINT], + mem: [0, ..RAND_SIZE_UINT], a: 0, b: 0, c: 0 }; @@ -79,7 +80,9 @@ macro_rules! mix( }} ); - for _ in range(0, 4) { mix!(); } + for _ in range(0u, 4) { + mix!(); + } if use_rsl { macro_rules! memloop ( @@ -115,32 +118,43 @@ macro_rules! memloop ( /// Refills the output buffer (`self.rsl`) #[inline] + #[allow(unsigned_negate)] fn isaac(&mut self) { self.c += 1; // abbreviations let mut a = self.a; let mut b = self.b + self.c; - static MIDPOINT: uint = RAND_SIZE as uint / 2; + static MIDPOINT: uint = (RAND_SIZE / 2) as uint; macro_rules! ind (($x:expr) => { - self.mem[(($x >> 2) & (RAND_SIZE - 1)) as uint] + self.mem[(($x >> 2) as uint & ((RAND_SIZE - 1) as uint))] }); - macro_rules! rngstep( + macro_rules! rngstepp( ($j:expr, $shift:expr) => {{ let base = $j; - let mix = if $shift < 0 { - a >> -$shift as uint - } else { - a << $shift as uint - }; + let mix = a << $shift as uint; let x = self.mem[base + mr_offset]; a = (a ^ mix) + self.mem[base + m2_offset]; let y = ind!(x) + a + b; self.mem[base + mr_offset] = y; - b = ind!(y >> RAND_SIZE_LEN) + x; + b = ind!(y >> RAND_SIZE_LEN as uint) + x; + self.rsl[base + mr_offset] = b; + }} + ); + macro_rules! rngstepn( + ($j:expr, $shift:expr) => {{ + let base = $j; + let mix = a >> $shift as uint; + + let x = self.mem[base + mr_offset]; + a = (a ^ mix) + self.mem[base + m2_offset]; + let y = ind!(x) + a + b; + self.mem[base + mr_offset] = y; + + b = ind!(y >> RAND_SIZE_LEN as uint) + x; self.rsl[base + mr_offset] = b; }} ); @@ -148,10 +162,10 @@ macro_rules! rngstep( let r = [(0, MIDPOINT), (MIDPOINT, 0)]; for &(mr_offset, m2_offset) in r.iter() { for i in range_step(0u, MIDPOINT, 4) { - rngstep!(i + 0, 13); - rngstep!(i + 1, -6); - rngstep!(i + 2, 2); - rngstep!(i + 3, -16); + rngstepp!(i + 0, 13); + rngstepn!(i + 1, 6); + rngstepp!(i + 2, 2); + rngstepn!(i + 3, 16); } } @@ -286,7 +300,10 @@ macro_rules! mix( }} ); - for _ in range(0, 4) { mix!(); } + for _ in range(0u, 4) { + mix!(); + } + if use_rsl { macro_rules! memloop ( ($arr:expr) => {{ @@ -332,14 +349,27 @@ macro_rules! ind ( *self.mem.unsafe_ref(($x as uint >> 3) & (RAND_SIZE_64 - 1)) } ); - macro_rules! rngstep( + macro_rules! rngstepp( + ($j:expr, $shift:expr) => {{ + let base = base + $j; + let mix = a ^ (a << $shift as uint); + let mix = if $j == 0 {!mix} else {mix}; + + unsafe { + let x = *self.mem.unsafe_ref(base + mr_offset); + a = mix + *self.mem.unsafe_ref(base + m2_offset); + let y = ind!(x) + a + b; + self.mem.unsafe_set(base + mr_offset, y); + + b = ind!(y >> RAND_SIZE_64_LEN) + x; + self.rsl.unsafe_set(base + mr_offset, b); + } + }} + ); + macro_rules! rngstepn( ($j:expr, $shift:expr) => {{ let base = base + $j; - let mix = a ^ (if $shift < 0 { - a >> -$shift as uint - } else { - a << $shift as uint - }); + let mix = a ^ (a >> $shift as uint); let mix = if $j == 0 {!mix} else {mix}; unsafe { @@ -356,10 +386,10 @@ macro_rules! rngstep( for &(mr_offset, m2_offset) in MP_VEC.iter() { for base in range(0, MIDPOINT / 4).map(|i| i * 4) { - rngstep!(0, 21); - rngstep!(1, -5); - rngstep!(2, 12); - rngstep!(3, -33); + rngstepp!(0, 21); + rngstepn!(1, 5); + rngstepp!(2, 12); + rngstepn!(3, 33); } } @@ -515,7 +545,7 @@ fn test_rng_32_true_values() { let seed = &[12345, 67890, 54321, 9876]; let mut rb: IsaacRng = SeedableRng::from_seed(seed); // skip forward to the 10000th number - for _ in range(0, 10000) { rb.next_u32(); } + for _ in range(0u, 10000) { rb.next_u32(); } let v = Vec::from_fn(10, |_| rb.next_u32()); assert_eq!(v, @@ -537,7 +567,7 @@ fn test_rng_64_true_values() { let seed = &[12345, 67890, 54321, 9876]; let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); // skip forward to the 10000th number - for _ in range(0, 10000) { rb.next_u64(); } + for _ in range(0u, 10000) { rb.next_u64(); } let v = Vec::from_fn(10, |_| rb.next_u64()); assert_eq!(v, diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 048e44cd55d..769b23a7e7b 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -180,7 +180,7 @@ fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> { /// let mut rng = task_rng(); /// let n: uint = rng.gen_range(0u, 10); /// println!("{}", n); - /// let m: f64 = rng.gen_range(-40.0, 1.3e5); + /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64); /// println!("{}", m); /// ``` fn gen_range(&mut self, low: T, high: T) -> T { @@ -225,7 +225,7 @@ fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> { /// ``` /// use std::rand::{task_rng, Rng}; /// - /// let choices = [1, 2, 4, 8, 16, 32]; + /// let choices = [1i, 2, 4, 8, 16, 32]; /// let mut rng = task_rng(); /// println!("{}", rng.choose(choices)); /// assert_eq!(rng.choose(choices.slice_to(0)), None); @@ -252,7 +252,7 @@ fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { /// use std::rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); - /// let mut y = [1,2,3]; + /// let mut y = [1i, 2, 3]; /// rng.shuffle(y); /// println!("{}", y.as_slice()); /// rng.shuffle(y); diff --git a/src/librand/rand_impls.rs b/src/librand/rand_impls.rs index 458a9ba378d..3dd054cee9d 100644 --- a/src/librand/rand_impls.rs +++ b/src/librand/rand_impls.rs @@ -244,7 +244,7 @@ fn rand_open() { // this is unlikely to catch an incorrect implementation that // generates exactly 0 or 1, but it keeps it sane. let mut rng = task_rng(); - for _ in range(0, 1_000) { + for _ in range(0u, 1_000) { // strict inequalities let Open01(f) = rng.gen::>(); assert!(0.0 < f && f < 1.0); @@ -257,7 +257,7 @@ fn rand_open() { #[test] fn rand_closed() { let mut rng = task_rng(); - for _ in range(0, 1_000) { + for _ in range(0u, 1_000) { // strict inequalities let Closed01(f) = rng.gen::>(); assert!(0.0 <= f && f <= 1.0); diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 09265f28c36..7a237670890 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -184,7 +184,7 @@ fn test_reseeding() { let mut rs = ReseedingRng::new(Counter {i:0}, 400, ReseedWithDefault); let mut i = 0; - for _ in range(0, 1000) { + for _ in range(0u, 1000) { assert_eq!(rs.next_u32(), i % 100); i += 1; } diff --git a/src/librustc/back/svh.rs b/src/librustc/back/svh.rs index ef3a00c26f2..c487f674c2d 100644 --- a/src/librustc/back/svh.rs +++ b/src/librustc/back/svh.rs @@ -100,7 +100,7 @@ pub fn calculate(krate: &ast::Crate) -> Svh { let hash = state.result(); return Svh { - hash: range_step(0, 64, 4).map(|i| hex(hash >> i)).collect() + hash: range_step(0u, 64u, 4u).map(|i| hex(hash >> i)).collect() }; fn hex(b: u64) -> char { diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index ed47649c6b2..eca0432229e 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -347,7 +347,7 @@ fn try_match(&self, file: &str, prefix: &str, suffix: &str) -> Option{ fn extract_one(&mut self, m: HashSet, flavor: &str, slot: &mut Option) -> Option { let mut ret = None::; - let mut error = 0; + let mut error = 0u; if slot.is_some() { // FIXME(#10786): for an optimization, we only read one of the diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 72def2c10da..4444cac0043 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -367,8 +367,8 @@ fn fromb(b: bool) -> Result { Ok(const_int(b as i64)) } BiAnd | BiBitAnd => Ok(const_int(a & b)), BiOr | BiBitOr => Ok(const_int(a | b)), BiBitXor => Ok(const_int(a ^ b)), - BiShl => Ok(const_int(a << b)), - BiShr => Ok(const_int(a >> b)), + BiShl => Ok(const_int(a << b as uint)), + BiShr => Ok(const_int(a >> b as uint)), BiEq => fromb(a == b), BiLt => fromb(a < b), BiLe => fromb(a <= b), @@ -394,8 +394,8 @@ fn fromb(b: bool) -> Result { Ok(const_int(b as i64)) } BiAnd | BiBitAnd => Ok(const_uint(a & b)), BiOr | BiBitOr => Ok(const_uint(a | b)), BiBitXor => Ok(const_uint(a ^ b)), - BiShl => Ok(const_uint(a << b)), - BiShr => Ok(const_uint(a >> b)), + BiShl => Ok(const_uint(a << b as uint)), + BiShr => Ok(const_uint(a >> b as uint)), BiEq => fromb(a == b), BiLt => fromb(a < b), BiLe => fromb(a <= b), @@ -407,15 +407,15 @@ fn fromb(b: bool) -> Result { Ok(const_int(b as i64)) } // shifts can have any integral type as their rhs (Ok(const_int(a)), Ok(const_uint(b))) => { match op { - BiShl => Ok(const_int(a << b)), - BiShr => Ok(const_int(a >> b)), + BiShl => Ok(const_int(a << b as uint)), + BiShr => Ok(const_int(a >> b as uint)), _ => Err("can't do this op on an int and uint".to_string()) } } (Ok(const_uint(a)), Ok(const_int(b))) => { match op { - BiShl => Ok(const_uint(a << b)), - BiShr => Ok(const_uint(a >> b)), + BiShl => Ok(const_uint(a << b as uint)), + BiShr => Ok(const_uint(a >> b as uint)), _ => Err("can't do this op on a uint and int".to_string()) } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 7a26d210482..5ac85833e22 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -595,7 +595,7 @@ fn set_bit(words: &mut [uint], bit: uint) -> bool { fn bit_str(bit: uint) -> String { let byte = bit >> 8; - let lobits = 1 << (bit & 0xFF); + let lobits = 1u << (bit & 0xFF); format!("[{}:{}-{:02x}]", bit, byte, lobits) } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 2329d5d685d..d862ab39ac1 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1966,7 +1966,7 @@ fn build_import_directive(&mut self, /// Resolves all imports for the crate. This method performs the fixed- /// point iteration. fn resolve_imports(&mut self) { - let mut i = 0; + let mut i = 0u; let mut prev_unresolved_imports = 0; loop { debug!("(resolving imports) iteration {}, {} imports left", diff --git a/src/librustc/middle/save/recorder.rs b/src/librustc/middle/save/recorder.rs index 428f97d0e53..fd76d6d37d1 100644 --- a/src/librustc/middle/save/recorder.rs +++ b/src/librustc/middle/save/recorder.rs @@ -256,7 +256,7 @@ pub fn variable_str(&mut self, self.check_and_record(Variable, span, sub_span, - svec!(id, name, qualname, value, typ, 0)); + svec!(id, name, qualname, value, typ, 0u)); } // formal parameters @@ -271,7 +271,7 @@ pub fn formal_str(&mut self, self.check_and_record(Variable, span, sub_span, - svec!(id, name, qualname, "", typ, 0)); + svec!(id, name, qualname, "", typ, 0u)); } // value is the initialising expression of the static if it is not mut, otherwise "". @@ -474,7 +474,10 @@ pub fn inherit_str(&mut self, self.check_and_record(Inheritance, span, sub_span, - svec!(base_id.node, base_id.krate, deriv_id, 0)); + svec!(base_id.node, + base_id.krate, + deriv_id, + 0u)); } pub fn fn_call_str(&mut self, @@ -516,7 +519,7 @@ pub fn sub_mod_ref_str(&mut self, self.record_with_span(ModRef, span, sub_span, - svec!(0, 0, qualname, parent)); + svec!(0u, 0u, qualname, parent)); } pub fn typedef_str(&mut self, @@ -557,7 +560,7 @@ pub fn sub_type_ref_str(&mut self, self.record_with_span(TypeRef, span, sub_span, - svec!(0, 0, qualname, 0)); + svec!(0u, 0u, qualname, 0u)); } // A slightly generic function for a reference to an item of any kind. diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index e68cfd7cef5..d21ee37f291 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -578,6 +578,7 @@ fn load_discr(bcx: &Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) assert_eq!(val_ty(ptr), llty.ptr_to()); let bits = machine::llbitsize_of_real(bcx.ccx(), llty); assert!(bits <= 64); + let bits = bits as uint; let mask = (-1u64 >> (64 - bits)) as Disr; if (max + 1) & mask == min & mask { // i.e., if the range is everything. The lo==hi case would be diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 783fdfa4aae..ba13ab05d7c 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -2095,7 +2095,9 @@ fn create_member_descriptions(&self, cx: &CrateContext) -> Vec { - let col = 0; // Always set the column to zero like Clang and GCC + let col = 0u; // Always set the column to zero like Clang and GCC debug!("setting debug location to {} {}", line, col); let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32), scope, ptr::null()]; unsafe { diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 10d44ecede6..2359f9d72d2 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -65,7 +65,9 @@ pub fn coerce(fcx: &FnCtxt, sp: Span, expected: ty::t, expr: &ast::Expr) { expected.repr(fcx.ccx.tcx), expr_ty.repr(fcx.ccx.tcx)); let expected = if ty::type_needs_infer(expected) { - resolve_type(fcx.infcx(), expected, + resolve_type(fcx.infcx(), + None, + expected, try_resolve_tvar_shallow).unwrap_or(expected) } else { expected }; match fcx.mk_assignty(expr, expr_ty, expected) { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 9d155ef31f9..647b099a10a 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -169,6 +169,19 @@ pub struct Inherited<'a> { upvar_borrow_map: RefCell, } +/// When type-checking an expression, we propagate downward +/// whatever type hint we are able in the form of an `Expectation`. +enum Expectation { + /// We know nothing about what type this expression should have. + NoExpectation, + + /// This expression should have the type given (or some subtype) + ExpectHasType(ty::t), + + /// This expression will be cast to the `ty::t` + ExpectCastableToType(ty::t), +} + #[deriving(Clone)] pub struct FnStyleState { pub def: ast::NodeId, @@ -492,7 +505,7 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>, visit.visit_block(body, ()); } - check_block_with_expected(&fcx, body, Some(ret_ty)); + check_block_with_expected(&fcx, body, ExpectHasType(ret_ty)); // We unify the tail expr's type with the // function result type, if there is a tail expr. @@ -1708,7 +1721,11 @@ fn write_call(fcx: &FnCtxt, call_expr: &ast::Expr, output: ty::t) { } // AST fragment checking -pub fn check_lit(fcx: &FnCtxt, lit: &ast::Lit) -> ty::t { +fn check_lit(fcx: &FnCtxt, + lit: &ast::Lit, + expected: Expectation) + -> ty::t +{ let tcx = fcx.ccx.tcx; match lit.node { @@ -1721,15 +1738,29 @@ pub fn check_lit(fcx: &FnCtxt, lit: &ast::Lit) -> ty::t { ast::LitInt(_, t) => ty::mk_mach_int(t), ast::LitUint(_, t) => ty::mk_mach_uint(t), ast::LitIntUnsuffixed(_) => { - // An unsuffixed integer literal could have any integral type, - // so we create an integral type variable for it. - ty::mk_int_var(tcx, fcx.infcx().next_int_var_id()) + let opt_ty = expected.map_to_option(fcx, |sty| { + match *sty { + ty::ty_int(i) => Some(ty::mk_mach_int(i)), + ty::ty_uint(i) => Some(ty::mk_mach_uint(i)), + ty::ty_char => Some(ty::mk_mach_uint(ast::TyU8)), + ty::ty_ptr(..) => Some(ty::mk_mach_uint(ast::TyU)), + ty::ty_bare_fn(..) => Some(ty::mk_mach_uint(ast::TyU)), + _ => None + } + }); + opt_ty.unwrap_or_else( + || ty::mk_int_var(tcx, fcx.infcx().next_int_var_id())) } ast::LitFloat(_, t) => ty::mk_mach_float(t), ast::LitFloatUnsuffixed(_) => { - // An unsuffixed floating point literal could have any floating point - // type, so we create a floating point type variable for it. - ty::mk_float_var(tcx, fcx.infcx().next_float_var_id()) + let opt_ty = expected.map_to_option(fcx, |sty| { + match *sty { + ty::ty_float(i) => Some(ty::mk_mach_float(i)), + _ => None + } + }); + opt_ty.unwrap_or_else( + || ty::mk_float_var(tcx, fcx.infcx().next_float_var_id())) } ast::LitNil => ty::mk_nil(), ast::LitBool(_) => ty::mk_bool() @@ -1746,43 +1777,51 @@ pub fn valid_range_bounds(ccx: &CrateCtxt, } } -pub fn check_expr_has_type( - fcx: &FnCtxt, expr: &ast::Expr, - expected: ty::t) { - check_expr_with_unifier(fcx, expr, Some(expected), NoPreference, || { - demand::suptype(fcx, expr.span, expected, fcx.expr_ty(expr)); - }); +pub fn check_expr_has_type(fcx: &FnCtxt, + expr: &ast::Expr, + expected: ty::t) { + check_expr_with_unifier( + fcx, expr, ExpectHasType(expected), NoPreference, + || demand::suptype(fcx, expr.span, expected, fcx.expr_ty(expr))); } -fn check_expr_coercable_to_type(fcx: &FnCtxt, expr: &ast::Expr, expected: ty::t) { - check_expr_with_unifier(fcx, expr, Some(expected), NoPreference, || { - demand::coerce(fcx, expr.span, expected, expr) - }); +fn check_expr_coercable_to_type(fcx: &FnCtxt, + expr: &ast::Expr, + expected: ty::t) { + check_expr_with_unifier( + fcx, expr, ExpectHasType(expected), NoPreference, + || demand::coerce(fcx, expr.span, expected, expr)); } fn check_expr_with_hint(fcx: &FnCtxt, expr: &ast::Expr, expected: ty::t) { - check_expr_with_unifier(fcx, expr, Some(expected), NoPreference, || ()) + check_expr_with_unifier( + fcx, expr, ExpectHasType(expected), NoPreference, + || ()) } -fn check_expr_with_opt_hint(fcx: &FnCtxt, expr: &ast::Expr, - expected: Option) { - check_expr_with_unifier(fcx, expr, expected, NoPreference, || ()) +fn check_expr_with_expectation(fcx: &FnCtxt, + expr: &ast::Expr, + expected: Expectation) { + check_expr_with_unifier( + fcx, expr, expected, NoPreference, + || ()) } -fn check_expr_with_opt_hint_and_lvalue_pref(fcx: &FnCtxt, +fn check_expr_with_expectation_and_lvalue_pref(fcx: &FnCtxt, expr: &ast::Expr, - expected: Option, - lvalue_pref: LvaluePreference) { + expected: Expectation, + lvalue_pref: LvaluePreference) +{ check_expr_with_unifier(fcx, expr, expected, lvalue_pref, || ()) } fn check_expr(fcx: &FnCtxt, expr: &ast::Expr) { - check_expr_with_unifier(fcx, expr, None, NoPreference, || ()) + check_expr_with_unifier(fcx, expr, NoExpectation, NoPreference, || ()) } fn check_expr_with_lvalue_pref(fcx: &FnCtxt, expr: &ast::Expr, lvalue_pref: LvaluePreference) { - check_expr_with_unifier(fcx, expr, None, lvalue_pref, || ()) + check_expr_with_unifier(fcx, expr, NoExpectation, lvalue_pref, || ()) } @@ -1863,9 +1902,10 @@ enum TupleArgumentsFlag { /// `ty_bot`, so avoid that when err and bot need to be handled differently. fn check_expr_with_unifier(fcx: &FnCtxt, expr: &ast::Expr, - expected: Option, + expected: Expectation, lvalue_pref: LvaluePreference, - unifier: ||) { + unifier: ||) +{ debug!(">> typechecking"); // A generic function for doing all of the checking for call expressions @@ -2001,14 +2041,27 @@ fn check_then_else(fcx: &FnCtxt, opt_else_expr: Option>, id: ast::NodeId, sp: Span, - expected: Option) { + expected: Expectation) { check_expr_has_type(fcx, cond_expr, ty::mk_bool()); let branches_ty = match opt_else_expr { Some(ref else_expr) => { + // Disregard "castable to" expectations because they + // can lead us astray. Consider for example `if cond + // {22} else {c} as u8` -- if we propagate the + // "castable to u8" constraint to 22, it will pick the + // type 22u8, which is overly constrained (c might not + // be a u8). In effect, the problem is that the + // "castable to" expectation is not the tightest thing + // we can say, so we want to drop it in this case. + // The tightest thing we can say is "must unify with + // else branch". Note that in the case of a "has type" + // constraint, this limitation does not hold. + let expected = expected.only_has_type(); + check_block_with_expected(fcx, then_blk, expected); let then_ty = fcx.node_ty(then_blk.id); - check_expr_with_opt_hint(fcx, &**else_expr, expected); + check_expr_with_expectation(fcx, &**else_expr, expected); let else_ty = fcx.expr_ty(&**else_expr); infer::common_supertype(fcx.infcx(), infer::IfExpression(sp), @@ -2101,10 +2154,8 @@ fn check_binop(fcx: &FnCtxt, fcx.expr_ty(&*lhs)); if ty::type_is_integral(lhs_t) && ast_util::is_shift_binop(op) { - // Shift is a special case: rhs can be any integral type - check_expr(fcx, &*rhs); - let rhs_t = fcx.expr_ty(&*rhs); - require_integral(fcx, rhs.span, rhs_t); + // Shift is a special case: rhs must be uint, no matter what lhs is + check_expr_has_type(fcx, rhs, ty::mk_uint()); fcx.write_ty(expr.id, lhs_t); return; } @@ -2243,40 +2294,18 @@ fn check_user_unop(fcx: &FnCtxt, }) } - // Resolves `expected` by a single level if it is a variable and passes it - // through the `unpack` function. It there is no expected type or - // resolution is not possible (e.g., no constraints yet present), just - // returns `none`. - fn unpack_expected( - fcx: &FnCtxt, - expected: Option, - unpack: |&ty::sty| -> Option) - -> Option { - match expected { - Some(t) => { - match resolve_type(fcx.infcx(), t, force_tvar) { - Ok(t) => unpack(&ty::get(t).sty), - _ => None - } - } - _ => None - } - } - fn check_expr_fn(fcx: &FnCtxt, expr: &ast::Expr, store: ty::TraitStore, decl: &ast::FnDecl, body: ast::P, - expected: Option) { + expected: Expectation) { let tcx = fcx.ccx.tcx; // Find the expected input/output types (if any). Substitute // fresh bound regions for any bound regions we find in the // expected types so as to avoid capture. - let expected_sty = unpack_expected(fcx, - expected, - |x| Some((*x).clone())); + let expected_sty = expected.map_to_option(fcx, |x| Some((*x).clone())); let (expected_sig, expected_onceness, expected_bounds) = { @@ -2696,8 +2725,8 @@ fn check_struct_enum_variant(fcx: &FnCtxt, } } - ast::ExprLit(ref lit) => { - let typ = check_lit(fcx, &**lit); + ast::ExprLit(lit) => { + let typ = check_lit(fcx, lit, expected); fcx.write_ty(id, typ); } ast::ExprBinary(op, ref lhs, ref rhs) => { @@ -2735,21 +2764,31 @@ fn check_struct_enum_variant(fcx: &FnCtxt, } } ast::ExprUnary(unop, ref oprnd) => { - let exp_inner = unpack_expected(fcx, expected, |sty| { + let expected = expected.only_has_type(); + let expected_inner = expected.map(fcx, |sty| { match unop { ast::UnBox | ast::UnUniq => match *sty { - ty::ty_box(ty) | ty::ty_uniq(ty) => Some(ty), - _ => None + ty::ty_box(ty) | ty::ty_uniq(ty) => { + ExpectHasType(ty) + } + _ => { + NoExpectation + } }, - ast::UnNot | ast::UnNeg => expected, - ast::UnDeref => None + ast::UnNot | ast::UnNeg => { + expected + } + ast::UnDeref => { + NoExpectation + } } }); let lvalue_pref = match unop { ast::UnDeref => lvalue_pref, _ => NoPreference }; - check_expr_with_opt_hint_and_lvalue_pref(fcx, &**oprnd, exp_inner, lvalue_pref); + check_expr_with_expectation_and_lvalue_pref( + fcx, &**oprnd, expected_inner, lvalue_pref); let mut oprnd_t = fcx.expr_ty(&**oprnd); if !ty::type_is_error(oprnd_t) && !ty::type_is_bot(oprnd_t) { match unop { @@ -2818,15 +2857,19 @@ fn check_struct_enum_variant(fcx: &FnCtxt, fcx.write_ty(id, oprnd_t); } ast::ExprAddrOf(mutbl, ref oprnd) => { - let hint = unpack_expected( - fcx, expected, - |sty| match *sty { ty::ty_rptr(_, ref mt) => Some(mt.ty), - _ => None }); + let expected = expected.only_has_type(); + let hint = expected.map(fcx, |sty| { + match *sty { ty::ty_rptr(_, ref mt) => ExpectHasType(mt.ty), + _ => NoExpectation } + }); let lvalue_pref = match mutbl { ast::MutMutable => PreferMutLvalue, ast::MutImmutable => NoPreference }; - check_expr_with_opt_hint_and_lvalue_pref(fcx, &**oprnd, hint, lvalue_pref); + check_expr_with_expectation_and_lvalue_pref(fcx, + &**oprnd, + hint, + lvalue_pref); // Note: at this point, we cannot say what the best lifetime // is to use for resulting pointer. We want to use the @@ -2890,9 +2933,9 @@ fn check_struct_enum_variant(fcx: &FnCtxt, } fcx.write_bot(id); } - ast::ExprParen(ref a) => { - check_expr_with_opt_hint_and_lvalue_pref(fcx, &**a, expected, lvalue_pref); - fcx.write_ty(id, fcx.expr_ty(&**a)); + ast::ExprParen(a) => { + check_expr_with_expectation_and_lvalue_pref(fcx, a, expected, lvalue_pref); + fcx.write_ty(id, fcx.expr_ty(a)); } ast::ExprAssign(ref lhs, ref rhs) => { check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue); @@ -3006,133 +3049,11 @@ fn check_struct_enum_variant(fcx: &FnCtxt, fcx.write_bot(id); } } - ast::ExprCast(ref e, ref t) => { - check_expr(fcx, &**e); - let t_1 = fcx.to_ty(&**t); - let t_e = fcx.expr_ty(&**e); - - debug!("t_1={}", fcx.infcx().ty_to_str(t_1)); - debug!("t_e={}", fcx.infcx().ty_to_str(t_e)); - - if ty::type_is_error(t_e) { - fcx.write_error(id); - } - else if ty::type_is_bot(t_e) { - fcx.write_bot(id); - } - else { - match ty::get(t_1).sty { - // This will be looked up later on - _ if ty::type_is_trait(t_1) => {}, - - _ => { - let t_1 = structurally_resolved_type(fcx, e.span, t_1); - let t_e = structurally_resolved_type(fcx, e.span, t_e); - - if ty::type_is_nil(t_e) { - fcx.type_error_message(expr.span, |actual| { - format!("cast from nil: `{}` as `{}`", - actual, - fcx.infcx().ty_to_str(t_1)) - }, t_e, None); - } else if ty::type_is_nil(t_1) { - fcx.type_error_message(expr.span, |actual| { - format!("cast to nil: `{}` as `{}`", - actual, - fcx.infcx().ty_to_str(t_1)) - }, t_e, None); - } - - let t_1_is_scalar = ty::type_is_scalar(t_1); - let t_1_is_char = ty::type_is_char(t_1); - let t_1_is_bare_fn = ty::type_is_bare_fn(t_1); - let t_1_is_float = ty::type_is_floating_point(t_1); - - // casts to scalars other than `char` and `bare fn` are trivial - let t_1_is_trivial = t_1_is_scalar && !t_1_is_char && !t_1_is_bare_fn; - if ty::type_is_c_like_enum(fcx.tcx(), t_e) && t_1_is_trivial { - if t_1_is_float { - fcx.type_error_message(expr.span, |actual| { - format!("illegal cast; cast through an \ - integer first: `{}` as `{}`", - actual, - fcx.infcx().ty_to_str(t_1)) - }, t_e, None); - } - // casts from C-like enums are allowed - } else if t_1_is_char { - let t_e = fcx.infcx().resolve_type_vars_if_possible(t_e); - if ty::get(t_e).sty != ty::ty_uint(ast::TyU8) { - fcx.type_error_message(expr.span, |actual| { - format!("only `u8` can be cast as \ - `char`, not `{}`", actual) - }, t_e, None); - } - } else if ty::get(t_1).sty == ty::ty_bool { - fcx.tcx() - .sess - .span_err(expr.span, - "cannot cast as `bool`, compare with \ - zero instead"); - } else if ty::type_is_region_ptr(t_e) && ty::type_is_unsafe_ptr(t_1) { - fn is_vec(t: ty::t) -> bool { - match ty::get(t).sty { - ty::ty_vec(..) => true, - ty::ty_ptr(ty::mt{ty: t, ..}) | ty::ty_rptr(_, ty::mt{ty: t, ..}) | - ty::ty_box(t) | ty::ty_uniq(t) => match ty::get(t).sty { - ty::ty_vec(_, None) => true, - _ => false, - }, - _ => false - } - } - fn types_compatible(fcx: &FnCtxt, sp: Span, - t1: ty::t, t2: ty::t) -> bool { - if !is_vec(t1) { - false - } else { - let el = ty::sequence_element_type(fcx.tcx(), - t1); - infer::mk_eqty(fcx.infcx(), false, - infer::Misc(sp), el, t2).is_ok() - } - } - - // Due to the limitations of LLVM global constants, - // region pointers end up pointing at copies of - // vector elements instead of the original values. - // To allow unsafe pointers to work correctly, we - // need to special-case obtaining an unsafe pointer - // from a region pointer to a vector. - - /* this cast is only allowed from &[T] to *T or - &T to *T. */ - match (&ty::get(t_e).sty, &ty::get(t_1).sty) { - (&ty::ty_rptr(_, ty::mt { ty: mt1, mutbl: ast::MutImmutable }), - &ty::ty_ptr(ty::mt { ty: mt2, mutbl: ast::MutImmutable })) - if types_compatible(fcx, e.span, mt1, mt2) => { - /* this case is allowed */ - } - _ => { - demand::coerce(fcx, e.span, t_1, &**e); - } - } - } else if !(ty::type_is_scalar(t_e) && t_1_is_trivial) { - /* - If more type combinations should be supported than are - supported here, then file an enhancement issue and - record the issue number in this comment. - */ - fcx.type_error_message(expr.span, |actual| { - format!("non-scalar cast: `{}` as `{}`", - actual, - fcx.infcx().ty_to_str(t_1)) - }, t_e, None); - } - } - } - fcx.write_ty(id, t_1); - } + ast::ExprCast(expr_from, t) => { + let ty_to = fcx.to_ty(t); + debug!("ExprCast ty_to={}", fcx.infcx().ty_to_str(ty_to)); + check_cast(fcx, expr_from, ty_to); + fcx.write_ty(id, ty_to); } ast::ExprVec(ref args) => { let t: ty::t = fcx.infcx().next_ty_var(); @@ -3144,7 +3065,7 @@ fn types_compatible(fcx: &FnCtxt, sp: Span, fcx.write_ty(id, typ); } ast::ExprRepeat(ref element, ref count_expr) => { - check_expr_with_hint(fcx, &**count_expr, ty::mk_uint()); + check_expr_has_type(fcx, &**count_expr, ty::mk_uint()); let count = ty::eval_repeat_count(fcx, &**count_expr); let t: ty::t = fcx.infcx().next_ty_var(); check_expr_has_type(fcx, &**element, t); @@ -3162,7 +3083,8 @@ fn types_compatible(fcx: &FnCtxt, sp: Span, } } ast::ExprTup(ref elts) => { - let flds = unpack_expected(fcx, expected, |sty| { + let expected = expected.only_has_type(); + let flds = expected.map_to_option(fcx, |sty| { match *sty { ty::ty_tup(ref flds) => Some((*flds).clone()), _ => None @@ -3173,11 +3095,11 @@ fn types_compatible(fcx: &FnCtxt, sp: Span, let elt_ts = elts.iter().enumerate().map(|(i, e)| { let opt_hint = match flds { - Some(ref fs) if i < fs.len() => Some(*fs.get(i)), - _ => None + Some(ref fs) if i < fs.len() => ExpectHasType(*fs.get(i)), + _ => NoExpectation }; - check_expr_with_opt_hint(fcx, &**e, opt_hint); - let t = fcx.expr_ty(&**e); + check_expr_with_expectation(fcx, *e, opt_hint); + let t = fcx.expr_ty(*e); err_field = err_field || ty::type_is_error(t); bot_field = bot_field || ty::type_is_bot(t); t @@ -3263,14 +3185,193 @@ fn types_compatible(fcx: &FnCtxt, sp: Span, syntax::print::pprust::expr_to_str(expr)); debug!("... {}, expected is {}", ppaux::ty_to_str(tcx, fcx.expr_ty(expr)), - match expected { - Some(t) => ppaux::ty_to_str(tcx, t), - _ => "empty".to_string() - }); + expected.repr(tcx)) unifier(); } +impl Expectation { + fn only_has_type(self) -> Expectation { + match self { + NoExpectation | ExpectCastableToType(..) => NoExpectation, + ExpectHasType(t) => ExpectHasType(t) + } + } + + // Resolves `expected` by a single level if it is a variable. If + // there is no expected type or resolution is not possible (e.g., + // no constraints yet present), just returns `None`. + fn resolve(self, fcx: &FnCtxt) -> Expectation { + match self { + NoExpectation => { + NoExpectation + } + ExpectCastableToType(t) => { + ExpectCastableToType( + fcx.infcx().resolve_type_vars_if_possible(t)) + } + ExpectHasType(t) => { + ExpectHasType( + fcx.infcx().resolve_type_vars_if_possible(t)) + } + } + } + + fn map(self, fcx: &FnCtxt, unpack: |&ty::sty| -> Expectation) -> Expectation { + match self.resolve(fcx) { + NoExpectation => NoExpectation, + ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty), + } + } + + fn map_to_option(self, + fcx: &FnCtxt, + unpack: |&ty::sty| -> Option) + -> Option + { + match self.resolve(fcx) { + NoExpectation => None, + ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty), + } + } +} + +impl Repr for Expectation { + fn repr(&self, tcx: &ty::ctxt) -> String { + match *self { + NoExpectation => format!("NoExpectation"), + ExpectHasType(t) => format!("ExpectHasType({})", + t.repr(tcx)), + ExpectCastableToType(t) => format!("ExpectCastableToType({})", + t.repr(tcx)), + } + } +} + +fn check_cast(fcx: &FnCtxt, expr_from: Gc, ty_to: ty::t) { + // Find the type of `expr_from`. Supply hints based on the type + // we are casting to, if appropriate. + let ty_to = structurally_resolved_type(fcx, expr_from.span, ty_to); + if ty::type_is_scalar(ty_to) { + // Supply the type as a hint so as to influence integer + // literals and other things that might care. + check_expr_with_hint(fcx, expr_from, ty_to) + } else { + check_expr(fcx, expr_from) + } + let ty_from = fcx.expr_ty(expr_from); + + // Object creation is checked during the vtable phase. + if ty::type_is_trait(ty_to) { + check_expr(fcx, expr_from); + return; + } + + let ty_from = fcx.infcx().resolve_type_vars_if_possible(ty_from); + + if ty::type_is_nil(ty_from) { + fcx.type_error_message(expr_from.span, |actual| { + format!("cast from nil: `{}` as `{}`", actual, + fcx.infcx().ty_to_str(ty_to)) + }, ty_from, None); + return; + } + + if ty::type_is_nil(ty_to) { + fcx.type_error_message(expr_from.span, |actual| { + format!("cast to nil: `{}` as `{}`", actual, + fcx.infcx().ty_to_str(ty_to)) + }, ty_from, None); + return; + } + + let t_e = structurally_resolved_type(fcx, expr_from.span, ty_from); + let t_1 = structurally_resolved_type(fcx, expr_from.span, ty_to); + + let to_is_scalar = ty::type_is_scalar(t_1); + let to_is_float = ty::type_is_floating_point(t_1); + let to_is_char = ty::type_is_char(t_1); + let to_is_bare_fn = ty::type_is_bare_fn(t_1); + + // casts to scalars other than `char` and `bare fn` are trivial + let to_is_trivial = to_is_scalar && + !to_is_char && !to_is_bare_fn; + + if ty::type_is_c_like_enum(fcx.tcx(), t_e) && to_is_trivial { + if to_is_float { + fcx.type_error_message(expr_from.span, |actual| { + format!("illegal cast; cast through an integer first: `{}` \ + as `{}`", + actual, + fcx.infcx().ty_to_str(t_1)) + }, ty_from, None); + } + // casts from C-like enums are allowed + } else if to_is_char { + if ty::get(ty_from).sty != ty::ty_uint(ast::TyU8) { + fcx.type_error_message(expr_from.span, |actual| { + format!("only `u8` can be cast as `char`, not `{}`", actual) + }, ty_from, None); + } + } else if ty::type_is_bool(t_1) { + fcx.tcx().sess.span_err(expr_from.span, + "cannot cast as `bool`, compare with zero instead"); + } else if ty::type_is_region_ptr(t_e) && ty::type_is_unsafe_ptr(t_1) { + fn is_vec(t: ty::t) -> bool { + match ty::get(t).sty { + ty::ty_vec(..) => true, + ty::ty_ptr(ty::mt{ty: t, ..}) | + ty::ty_rptr(_, ty::mt{ty: t, ..}) | + ty::ty_box(t) | + ty::ty_uniq(t) => match ty::get(t).sty { + ty::ty_vec(_, None) => true, + _ => false, + }, + _ => false + } + } + fn types_compatible(fcx: &FnCtxt, sp: Span, + t1: ty::t, t2: ty::t) -> bool { + if !is_vec(t1) { + false + } else { + let el = ty::sequence_element_type(fcx.tcx(), + t1); + infer::mk_eqty(fcx.infcx(), false, + infer::Misc(sp), el, t2).is_ok() + } + } + + // Due to the limitations of LLVM global constants, + // region pointers end up pointing at copies of + // vector elements instead of the original values. + // To allow unsafe pointers to work correctly, we + // need to special-case obtaining an unsafe pointer + // from a region pointer to a vector. + + /* this cast is only allowed from &[T] to *T or + &T to *T. */ + match (&ty::get(t_e).sty, &ty::get(t_1).sty) { + (&ty::ty_rptr(_, ty::mt { ty: mt1, mutbl: ast::MutImmutable }), + &ty::ty_ptr(ty::mt { ty: mt2, mutbl: ast::MutImmutable })) + if types_compatible(fcx, expr_from.span, mt1, mt2) => { + /* this case is allowed */ + } + _ => { + demand::coerce(fcx, expr_from.span, ty_to, expr_from); + } + } + } else if !(ty::type_is_scalar(t_e) && to_is_trivial) { + // If more type combinations should be supported than are + // supported here, then file an enhancement issue and + // record the issue number in this comment. + fcx.type_error_message(expr_from.span, |actual| { + format!("non-scalar cast: `{}` as `{}`", actual, + fcx.infcx().ty_to_str(ty_to)) + }, ty_from, None); + } +} + pub fn require_uint(fcx: &FnCtxt, sp: Span, t: ty::t) { if !type_is_uint(fcx, sp, t) { fcx.type_error_message(sp, |actual| { @@ -3371,7 +3472,7 @@ pub fn check_stmt(fcx: &FnCtxt, stmt: &ast::Stmt) { } pub fn check_block_no_value(fcx: &FnCtxt, blk: &ast::Block) { - check_block_with_expected(fcx, blk, Some(ty::mk_nil())); + check_block_with_expected(fcx, blk, ExpectHasType(ty::mk_nil())); let blkty = fcx.node_ty(blk.id); if ty::type_is_error(blkty) { fcx.write_error(blk.id); @@ -3385,9 +3486,9 @@ pub fn check_block_no_value(fcx: &FnCtxt, blk: &ast::Block) { } } -pub fn check_block_with_expected(fcx: &FnCtxt, - blk: &ast::Block, - expected: Option) { +fn check_block_with_expected(fcx: &FnCtxt, + blk: &ast::Block, + expected: Expectation) { let prev = { let mut fcx_ps = fcx.ps.borrow_mut(); let fn_style_state = fcx_ps.recurse(blk); @@ -3448,8 +3549,8 @@ pub fn check_block_with_expected(fcx: &FnCtxt, e.span, "unreachable expression".to_string()); } - check_expr_with_opt_hint(fcx, &*e, expected); - let ety = fcx.expr_ty(&*e); + check_expr_with_expectation(fcx, e, expected); + let ety = fcx.expr_ty(e); fcx.write_ty(blk.id, ety); if any_err { fcx.write_error(blk.id); @@ -4170,7 +4271,7 @@ fn adjust_region_parameters( // Resolves `typ` by a single level if `typ` is a type variable. If no // resolution is possible, then an error is reported. pub fn structurally_resolved_type(fcx: &FnCtxt, sp: Span, tp: ty::t) -> ty::t { - match infer::resolve_type(fcx.infcx(), tp, force_tvar) { + match infer::resolve_type(fcx.infcx(), Some(sp), tp, force_tvar) { Ok(t_s) if !ty::type_is_ty_var(t_s) => t_s, _ => { fcx.type_error_message(sp, |_actual| { diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 4cd319af0d9..07fb43d0d34 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -228,7 +228,7 @@ pub fn resolve_type(&self, unresolved_ty: ty::t) -> ty::t { * bigger than the let and the `*b` expression, so we will * effectively resolve `` to be the block B. */ - match resolve_type(self.fcx.infcx(), unresolved_ty, + match resolve_type(self.fcx.infcx(), None, unresolved_ty, resolve_and_force_all_but_regions) { Ok(t) => t, Err(_) => ty::mk_err() diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 7e118291f34..7612add9b05 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -481,7 +481,7 @@ fn fixup_ty(vcx: &VtableContext, is_early: bool) -> Option { let tcx = vcx.tcx(); - match resolve_type(vcx.infcx, ty, resolve_and_force_all_but_regions) { + match resolve_type(vcx.infcx, Some(span), ty, resolve_and_force_all_but_regions) { Ok(new_type) => Some(new_type), Err(e) if !is_early => { tcx.sess.span_fatal(span, diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 8e3e8e6091b..eb43144571e 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -456,7 +456,7 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t { return t; } - match resolve_type(self.infcx, t, resolve_all | force_all) { + match resolve_type(self.infcx, None, t, resolve_all | force_all) { Ok(t) => t, Err(e) => { self.report_error(e); diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index e6f79362cf2..32e34d1320e 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -61,6 +61,7 @@ fn get_base_type(inference_context: &InferCtxt, -> Option { let resolved_type; match resolve_type(inference_context, + Some(span), original_type, resolve_ivar) { Ok(resulting_type) if !type_is_ty_var(resulting_type) => { diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 9317563da93..2b330544239 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -213,7 +213,8 @@ pub fn subtype(&self, a: ty::t, b: ty::t) -> CoerceResult { pub fn unpack_actual_value(&self, a: ty::t, f: |&ty::sty| -> CoerceResult) -> CoerceResult { - match resolve_type(self.get_ref().infcx, a, try_resolve_tvar_shallow) { + match resolve_type(self.get_ref().infcx, None, + a, try_resolve_tvar_shallow) { Ok(t) => { f(&ty::get(t).sty) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index bb458d27d17..197a2370eff 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -238,6 +238,7 @@ pub enum RegionVariableOrigin { pub enum fixup_err { unresolved_int_ty(IntVid), + unresolved_float_ty(FloatVid), unresolved_ty(TyVid), cyclic_ty(TyVid), unresolved_region(RegionVid), @@ -247,6 +248,9 @@ pub enum fixup_err { pub fn fixup_err_to_str(f: fixup_err) -> String { match f { unresolved_int_ty(_) => "unconstrained integral type".to_string(), + unresolved_float_ty(_) => { + "unconstrained floating point type".to_string() + } unresolved_ty(_) => "unconstrained type".to_string(), cyclic_ty(_) => "cyclic type of infinite size".to_string(), unresolved_region(_) => "unconstrained region".to_string(), @@ -407,18 +411,17 @@ pub fn mk_coercety(cx: &InferCtxt, // See comment on the type `resolve_state` below pub fn resolve_type(cx: &InferCtxt, + span: Option, a: ty::t, modes: uint) - -> fres -{ - let mut resolver = resolver(cx, modes); + -> fres { + let mut resolver = resolver(cx, modes, span); cx.commit_unconditionally(|| resolver.resolve_type_chk(a)) } pub fn resolve_region(cx: &InferCtxt, r: ty::Region, modes: uint) - -> fres -{ - let mut resolver = resolver(cx, modes); + -> fres { + let mut resolver = resolver(cx, modes, None); resolver.resolve_region_chk(r) } @@ -671,9 +674,11 @@ pub fn trait_ref_to_str(&self, t: &ty::TraitRef) -> String { } pub fn resolve_type_vars_if_possible(&self, typ: ty::t) -> ty::t { - match resolve_type(self, typ, resolve_nested_tvar | resolve_ivar) { - Ok(new_type) => new_type, - Err(_) => typ + match resolve_type(self, + None, + typ, resolve_nested_tvar | resolve_ivar) { + Ok(new_type) => new_type, + Err(_) => typ } } diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index c81d4b17d9b..757b715ec93 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -1348,7 +1348,7 @@ fn process_edges(this: &RegionVarBindings, fn iterate_until_fixed_point(&self, tag: &str, body: |constraint: &Constraint| -> bool) { - let mut iteration = 0; + let mut iteration = 0u; let mut changed = true; while changed { changed = false; diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index ae7578957f8..ed6ea6c9677 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -54,8 +54,9 @@ use middle::typeck::infer::{Bounds, cyclic_ty, fixup_err, fres, InferCtxt}; use middle::typeck::infer::unresolved_ty; use middle::typeck::infer::unify::Root; -use util::common::{indent}; -use util::ppaux::{ty_to_str, Repr}; +use syntax::codemap::Span; +use util::common::indent; +use util::ppaux::{Repr, ty_to_str}; use syntax::ast; @@ -81,16 +82,22 @@ pub struct ResolveState<'a> { modes: uint, err: Option, v_seen: Vec , - type_depth: uint + type_depth: uint, + span: Option, } -pub fn resolver<'a>(infcx: &'a InferCtxt, modes: uint) -> ResolveState<'a> { +pub fn resolver<'a>(infcx: &'a InferCtxt, + modes: uint, + span: Option) + -> ResolveState<'a> +{ ResolveState { infcx: infcx, modes: modes, err: None, v_seen: Vec::new(), - type_depth: 0 + type_depth: 0, + span: span } } @@ -113,7 +120,9 @@ pub fn should(&mut self, mode: uint) -> bool { (self.modes & mode) == mode } - pub fn resolve_type_chk(&mut self, typ: ty::t) -> fres { + pub fn resolve_type_chk(&mut self, + typ: ty::t) + -> fres { self.err = None; debug!("Resolving {} (modes={:x})", @@ -138,7 +147,8 @@ pub fn resolve_type_chk(&mut self, typ: ty::t) -> fres { } } - pub fn resolve_region_chk(&mut self, orig: ty::Region) + pub fn resolve_region_chk(&mut self, + orig: ty::Region) -> fres { self.err = None; let resolved = indent(|| self.resolve_region(orig) ); @@ -248,10 +258,20 @@ pub fn resolve_int_var(&mut self, vid: IntVid) -> ty::t { Some(UintType(t)) => ty::mk_mach_uint(t), None => { if self.should(force_ivar) { - // As a last resort, default to int. + // As a last resort, default to int and emit an error. let ty = ty::mk_int(); table.borrow_mut().set( tcx, node.key, Root(Some(IntType(ast::TyI)), node.rank)); + + match self.span { + Some(sp) => { + self.infcx.tcx.sess.span_err( + sp, + "cannot determine the type of this integer; add \ + a suffix to specify the type explicitly"); + } + None => { } + } ty } else { ty::mk_int_var(self.infcx.tcx, vid) @@ -272,10 +292,20 @@ pub fn resolve_float_var(&mut self, vid: FloatVid) -> ty::t { Some(t) => ty::mk_mach_float(t), None => { if self.should(force_fvar) { - // As a last resort, default to f64. + // As a last resort, default to f64 and emit an error. let ty = ty::mk_f64(); table.borrow_mut().set( tcx, node.key, Root(Some(ast::TyF64), node.rank)); + + match self.span { + Some(sp) => { + self.infcx.tcx.sess.span_err( + sp, + "cannot determine the type of this number; add \ + a suffix to specify the type explicitly"); + } + None => { } + } ty } else { ty::mk_float_var(self.infcx.tcx, vid) diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 1c91b41b270..0c0bba992a0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -350,10 +350,8 @@ fn push_sig_to_str(cx: &ctxt, ty_bot => "!".to_string(), ty_bool => "bool".to_string(), ty_char => "char".to_string(), - ty_int(t) => ast_util::int_ty_to_str(t, None, - ast_util::AutoSuffix).to_string(), - ty_uint(t) => ast_util::uint_ty_to_str(t, None, - ast_util::AutoSuffix).to_string(), + ty_int(t) => ast_util::int_ty_to_str(t, None).to_string(), + ty_uint(t) => ast_util::uint_ty_to_str(t, None).to_string(), ty_float(t) => ast_util::float_ty_to_str(t).to_string(), ty_box(typ) => format!("Gc<{}>", ty_to_str(cx, typ)), ty_uniq(typ) => format!("Box<{}>", ty_to_str(cx, typ)), diff --git a/src/librustrt/libunwind.rs b/src/librustrt/libunwind.rs index fe9b2b569c0..faddadb832d 100644 --- a/src/librustrt/libunwind.rs +++ b/src/librustrt/libunwind.rs @@ -57,20 +57,20 @@ pub enum _Unwind_Reason_Code { pub type _Unwind_Word = libc::uintptr_t; #[cfg(target_arch = "x86")] -pub static unwinder_private_data_size: int = 5; +pub static unwinder_private_data_size: uint = 5; #[cfg(target_arch = "x86_64")] -pub static unwinder_private_data_size: int = 2; +pub static unwinder_private_data_size: uint = 2; #[cfg(target_arch = "arm", not(target_os = "ios"))] -pub static unwinder_private_data_size: int = 20; +pub static unwinder_private_data_size: uint = 20; #[cfg(target_arch = "arm", target_os = "ios")] -pub static unwinder_private_data_size: int = 5; +pub static unwinder_private_data_size: uint = 5; #[cfg(target_arch = "mips")] #[cfg(target_arch = "mipsel")] -pub static unwinder_private_data_size: int = 2; +pub static unwinder_private_data_size: uint = 2; pub struct _Unwind_Exception { pub exception_class: _Unwind_Exception_Class, diff --git a/src/librustrt/thread.rs b/src/librustrt/thread.rs index 3dcd1c4a6f0..b385f48f33a 100644 --- a/src/librustrt/thread.rs +++ b/src/librustrt/thread.rs @@ -333,14 +333,14 @@ mod tests { fn smoke() { Thread::start(proc (){}).join(); } #[test] - fn data() { assert_eq!(Thread::start(proc () { 1 }).join(), 1); } + fn data() { assert_eq!(Thread::start(proc () { 1i }).join(), 1); } #[test] fn detached() { Thread::spawn(proc () {}) } #[test] fn small_stacks() { - assert_eq!(42, Thread::start_stack(0, proc () 42).join()); - assert_eq!(42, Thread::start_stack(1, proc () 42).join()); + assert_eq!(42i, Thread::start_stack(0, proc () 42i).join()); + assert_eq!(42i, Thread::start_stack(1, proc () 42i).join()); } } diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 5c4da38989f..ee1e836112e 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -336,7 +336,7 @@ fn test_from_base64_invalid_padding() { fn test_base64_random() { use std::rand::{task_rng, random, Rng}; - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let times = task_rng().gen_range(1u, 100); let v = Vec::from_fn(times, |_| random::()); assert_eq!(v.as_slice() diff --git a/src/libserialize/ebml.rs b/src/libserialize/ebml.rs index 12c5a3493c1..efee29212e9 100644 --- a/src/libserialize/ebml.rs +++ b/src/libserialize/ebml.rs @@ -173,7 +173,7 @@ pub fn vuint_at(data: &[u8], start: uint) -> DecodeResult { // the most significant bit is set, the second most significant bit is set etc. we can // replace up to three "and+branch" with a single table lookup which gives us a measured // speedup of around 2x on x86_64. - static SHIFT_MASK_TABLE: [(u32, u32), ..16] = [ + static SHIFT_MASK_TABLE: [(uint, u32), ..16] = [ (0, 0x0), (0, 0x0fffffff), (8, 0x1fffff), (8, 0x1fffff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff), diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 44d06061853..2fccbc2fcaf 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -173,14 +173,14 @@ pub fn test_from_hex_ignores_whitespace() { #[test] pub fn test_to_hex_all_bytes() { - for i in range(0, 256) { + for i in range(0u, 256) { assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint)); } } #[test] pub fn test_from_hex_all_bytes() { - for i in range(0, 256) { + for i in range(0u, 256) { assert_eq!(format!("{:02x}", i as uint).as_slice() .from_hex() .unwrap() diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 0439306ffde..1721bd7ae15 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -3365,21 +3365,21 @@ fn test_to_json() { assert_eq!(true.to_json(), Boolean(true)); assert_eq!(false.to_json(), Boolean(false)); assert_eq!("abc".to_string().to_json(), String("abc".to_string())); - assert_eq!((1, 2).to_json(), list2); - assert_eq!((1, 2, 3).to_json(), list3); - assert_eq!([1, 2].to_json(), list2); - assert_eq!((&[1, 2, 3]).to_json(), list3); - assert_eq!((vec![1, 2]).to_json(), list2); - assert_eq!(vec!(1, 2, 3).to_json(), list3); + assert_eq!((1i, 2i).to_json(), list2); + assert_eq!((1i, 2i, 3i).to_json(), list3); + assert_eq!([1i, 2].to_json(), list2); + assert_eq!((&[1i, 2, 3]).to_json(), list3); + assert_eq!((vec![1i, 2]).to_json(), list2); + assert_eq!(vec!(1i, 2i, 3i).to_json(), list3); let mut tree_map = TreeMap::new(); - tree_map.insert("a".to_string(), 1); + tree_map.insert("a".to_string(), 1i); 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(), 1); + hash_map.insert("a".to_string(), 1i); hash_map.insert("b".to_string(), 2); assert_eq!(hash_map.to_json(), object); - assert_eq!(Some(15).to_json(), Number(15 as f64)); + assert_eq!(Some(15i).to_json(), Number(15 as f64)); assert_eq!(None::.to_json(), Null); } @@ -3420,7 +3420,7 @@ fn bench_small(b: &mut Bencher) { fn big_json() -> String { let mut src = "[\n".to_string(); - for _ in range(0, 500) { + for _ in range(0i, 500) { src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \ [1,2,3]},"#); } diff --git a/src/libstd/collections/hashmap.rs b/src/libstd/collections/hashmap.rs index 8feb0e0b7ee..d06d4ea7177 100644 --- a/src/libstd/collections/hashmap.rs +++ b/src/libstd/collections/hashmap.rs @@ -1688,7 +1688,7 @@ fn hash(&self, state: &mut S) { fn test_create_capacity_zero() { let mut m = HashMap::with_capacity(0); - assert!(m.insert(1, 1)); + assert!(m.insert(1i, 1i)); assert!(m.contains_key(&1)); assert!(!m.contains_key(&0)); @@ -1698,9 +1698,9 @@ fn test_create_capacity_zero() { fn test_insert() { let mut m = HashMap::new(); assert_eq!(m.len(), 0); - assert!(m.insert(1, 2)); + assert!(m.insert(1i, 2i)); assert_eq!(m.len(), 1); - assert!(m.insert(2, 4)); + assert!(m.insert(2i, 4i)); assert_eq!(m.len(), 2); assert_eq!(*m.find(&1).unwrap(), 2); assert_eq!(*m.find(&2).unwrap(), 4); @@ -1732,7 +1732,7 @@ fn drop(&mut self) { #[test] fn test_drops() { - drop_vector.replace(Some(RefCell::new(Vec::from_elem(200, 0)))); + drop_vector.replace(Some(RefCell::new(Vec::from_elem(200, 0i)))); { let mut m = HashMap::new(); @@ -1796,10 +1796,10 @@ fn test_lots_of_insertions() { // Try this a few times to make sure we never screw up the hashmap's // internal state. - for _ in range(0, 10) { + for _ in range(0i, 10) { assert!(m.is_empty()); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { assert!(m.insert(i, i)); for j in range_inclusive(1, i) { @@ -1813,12 +1813,12 @@ fn test_lots_of_insertions() { } } - for i in range_inclusive(1001, 2000) { + for i in range_inclusive(1001i, 2000) { assert!(!m.contains_key(&i)); } // remove forwards - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { assert!(m.remove(&i)); for j in range_inclusive(1, i) { @@ -1830,16 +1830,16 @@ fn test_lots_of_insertions() { } } - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { assert!(!m.contains_key(&i)); } - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { assert!(m.insert(i, i)); } // remove backwards - for i in range_step_inclusive(1000, 1, -1) { + for i in range_step_inclusive(1000i, 1, -1) { assert!(m.remove(&i)); for j in range_inclusive(i, 1000) { @@ -1856,9 +1856,9 @@ fn test_lots_of_insertions() { #[test] fn test_find_mut() { let mut m = HashMap::new(); - assert!(m.insert(1, 12)); - assert!(m.insert(2, 8)); - assert!(m.insert(5, 14)); + assert!(m.insert(1i, 12i)); + assert!(m.insert(2i, 8i)); + assert!(m.insert(5i, 14i)); let new = 100; match m.find_mut(&5) { None => fail!(), Some(x) => *x = new @@ -1869,18 +1869,18 @@ fn test_find_mut() { #[test] fn test_insert_overwrite() { let mut m = HashMap::new(); - assert!(m.insert(1, 2)); + assert!(m.insert(1i, 2i)); assert_eq!(*m.find(&1).unwrap(), 2); - assert!(!m.insert(1, 3)); + assert!(!m.insert(1i, 3i)); assert_eq!(*m.find(&1).unwrap(), 3); } #[test] fn test_insert_conflicts() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); - assert!(m.insert(5, 3)); - assert!(m.insert(9, 4)); + assert!(m.insert(1i, 2i)); + assert!(m.insert(5i, 3i)); + assert!(m.insert(9i, 4i)); assert_eq!(*m.find(&9).unwrap(), 4); assert_eq!(*m.find(&5).unwrap(), 3); assert_eq!(*m.find(&1).unwrap(), 2); @@ -1889,7 +1889,7 @@ fn test_insert_conflicts() { #[test] fn test_conflict_remove() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); + assert!(m.insert(1i, 2i)); assert_eq!(*m.find(&1).unwrap(), 2); assert!(m.insert(5, 3)); assert_eq!(*m.find(&1).unwrap(), 2); @@ -1906,7 +1906,7 @@ fn test_conflict_remove() { #[test] fn test_is_empty() { let mut m = HashMap::with_capacity(4); - assert!(m.insert(1, 2)); + assert!(m.insert(1i, 2i)); assert!(!m.is_empty()); assert!(m.remove(&1)); assert!(m.is_empty()); @@ -1915,7 +1915,7 @@ fn test_is_empty() { #[test] fn test_pop() { let mut m = HashMap::new(); - m.insert(1, 2); + m.insert(1i, 2i); assert_eq!(m.pop(&1), Some(2)); assert_eq!(m.pop(&1), None); } @@ -1924,7 +1924,7 @@ fn test_pop() { #[allow(experimental)] fn test_pop_equiv() { let mut m = HashMap::new(); - m.insert(1, 2); + m.insert(1i, 2i); assert_eq!(m.pop_equiv(&KindaIntLike(1)), Some(2)); assert_eq!(m.pop_equiv(&KindaIntLike(1)), None); } @@ -1932,9 +1932,9 @@ fn test_pop_equiv() { #[test] fn test_swap() { let mut m = HashMap::new(); - assert_eq!(m.swap(1, 2), None); - assert_eq!(m.swap(1, 3), Some(2)); - assert_eq!(m.swap(1, 4), Some(3)); + assert_eq!(m.swap(1i, 2i), None); + assert_eq!(m.swap(1i, 3i), Some(2)); + assert_eq!(m.swap(1i, 4i), Some(3)); } #[test] @@ -1942,8 +1942,8 @@ fn test_move_iter() { let hm = { let mut hm = HashMap::new(); - hm.insert('a', 1); - hm.insert('b', 2); + hm.insert('a', 1i); + hm.insert('b', 2i); hm }; @@ -1971,7 +1971,7 @@ fn test_iterate() { #[test] fn test_keys() { - let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; let map = vec.move_iter().collect::>(); let keys = map.keys().map(|&k| k).collect::>(); assert_eq!(keys.len(), 3); @@ -1982,7 +1982,7 @@ fn test_keys() { #[test] fn test_values() { - let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let vec = vec![(1i, 'a'), (2i, 'b'), (3i, 'c')]; let map = vec.move_iter().collect::>(); let values = map.values().map(|&v| v).collect::>(); assert_eq!(values.len(), 3); @@ -1994,8 +1994,8 @@ fn test_values() { #[test] fn test_find() { let mut m = HashMap::new(); - assert!(m.find(&1).is_none()); - m.insert(1, 2); + assert!(m.find(&1i).is_none()); + m.insert(1i, 2i); match m.find(&1) { None => fail!(), Some(v) => assert_eq!(*v, 2) @@ -2005,17 +2005,17 @@ fn test_find() { #[test] fn test_eq() { let mut m1 = HashMap::new(); - m1.insert(1, 2); - m1.insert(2, 3); - m1.insert(3, 4); + m1.insert(1i, 2i); + m1.insert(2i, 3i); + m1.insert(3i, 4i); let mut m2 = HashMap::new(); - m2.insert(1, 2); - m2.insert(2, 3); + m2.insert(1i, 2i); + m2.insert(2i, 3i); assert!(m1 != m2); - m2.insert(3, 4); + m2.insert(3i, 4i); assert_eq!(m1, m2); } @@ -2025,8 +2025,8 @@ fn test_show() { let mut map: HashMap = HashMap::new(); let empty: HashMap = HashMap::new(); - map.insert(1, 2); - map.insert(3, 4); + map.insert(1i, 2i); + map.insert(3i, 4i); let map_str = format!("{}", map); @@ -2102,7 +2102,7 @@ fn test_resize_policy() { fn test_find_equiv() { let mut m = HashMap::new(); - let (foo, bar, baz) = (1,2,3); + let (foo, bar, baz) = (1i,2i,3i); m.insert("foo".to_string(), foo); m.insert("bar".to_string(), bar); m.insert("baz".to_string(), baz); @@ -2117,7 +2117,7 @@ fn test_find_equiv() { #[test] fn test_from_iter() { - let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; let map: HashMap = xs.iter().map(|&x| x).collect(); @@ -2128,7 +2128,7 @@ fn test_from_iter() { #[test] fn test_size_hint() { - let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; let map: HashMap = xs.iter().map(|&x| x).collect(); @@ -2141,7 +2141,7 @@ fn test_size_hint() { #[test] fn test_mut_size_hint() { - let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; let mut map: HashMap = xs.iter().map(|&x| x).collect(); @@ -2167,8 +2167,8 @@ fn test_disjoint() { let mut ys = HashSet::new(); assert!(xs.is_disjoint(&ys)); assert!(ys.is_disjoint(&xs)); - assert!(xs.insert(5)); - assert!(ys.insert(11)); + assert!(xs.insert(5i)); + assert!(ys.insert(11i)); assert!(xs.is_disjoint(&ys)); assert!(ys.is_disjoint(&xs)); assert!(xs.insert(7)); @@ -2186,13 +2186,13 @@ fn test_disjoint() { #[test] fn test_subset_and_superset() { let mut a = HashSet::new(); - assert!(a.insert(0)); + assert!(a.insert(0i)); assert!(a.insert(5)); assert!(a.insert(11)); assert!(a.insert(7)); let mut b = HashSet::new(); - assert!(b.insert(0)); + assert!(b.insert(0i)); assert!(b.insert(7)); assert!(b.insert(19)); assert!(b.insert(250)); @@ -2230,7 +2230,7 @@ fn test_intersection() { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(11)); + assert!(a.insert(11i)); assert!(a.insert(1)); assert!(a.insert(3)); assert!(a.insert(77)); @@ -2238,7 +2238,7 @@ fn test_intersection() { assert!(a.insert(5)); assert!(a.insert(-5)); - assert!(b.insert(2)); + assert!(b.insert(2i)); assert!(b.insert(11)); assert!(b.insert(77)); assert!(b.insert(-9)); @@ -2260,13 +2260,13 @@ fn test_difference() { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); + assert!(a.insert(1i)); assert!(a.insert(3)); assert!(a.insert(5)); assert!(a.insert(9)); assert!(a.insert(11)); - assert!(b.insert(3)); + assert!(b.insert(3i)); assert!(b.insert(9)); let mut i = 0; @@ -2283,13 +2283,13 @@ fn test_symmetric_difference() { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); + assert!(a.insert(1i)); assert!(a.insert(3)); assert!(a.insert(5)); assert!(a.insert(9)); assert!(a.insert(11)); - assert!(b.insert(-2)); + assert!(b.insert(-2i)); assert!(b.insert(3)); assert!(b.insert(9)); assert!(b.insert(14)); @@ -2309,7 +2309,7 @@ fn test_union() { let mut a = HashSet::new(); let mut b = HashSet::new(); - assert!(a.insert(1)); + assert!(a.insert(1i)); assert!(a.insert(3)); assert!(a.insert(5)); assert!(a.insert(9)); @@ -2318,7 +2318,7 @@ fn test_union() { assert!(a.insert(19)); assert!(a.insert(24)); - assert!(b.insert(-2)); + assert!(b.insert(-2i)); assert!(b.insert(1)); assert!(b.insert(5)); assert!(b.insert(9)); @@ -2336,7 +2336,7 @@ fn test_union() { #[test] fn test_from_iter() { - let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + let xs = [1i, 2, 3, 4, 5, 6, 7, 8, 9]; let set: HashSet = xs.iter().map(|&x| x).collect(); @@ -2366,13 +2366,13 @@ fn test_eq() { // I'm keeping them around to prevent a regression. let mut s1 = HashSet::new(); - s1.insert(1); + s1.insert(1i); s1.insert(2); s1.insert(3); let mut s2 = HashSet::new(); - s2.insert(1); + s2.insert(1i); s2.insert(2); assert!(s1 != s2); @@ -2387,7 +2387,7 @@ fn test_show() { let mut set: HashSet = HashSet::new(); let empty: HashSet = HashSet::new(); - set.insert(1); + set.insert(1i); set.insert(2); let set_str = format!("{}", set); @@ -2421,7 +2421,7 @@ fn new_insert_drop(b : &mut Bencher) { b.iter(|| { let mut m = HashMap::new(); - m.insert(0, 0); + m.insert(0i, 0i); assert_eq!(m.len(), 1); }) } @@ -2432,7 +2432,7 @@ fn insert(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.insert(i, i); } @@ -2450,12 +2450,12 @@ fn find_existing(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.insert(i, i); } b.iter(|| { - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.contains_key(&i); } }); @@ -2467,12 +2467,12 @@ fn find_nonexisting(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.insert(i, i); } b.iter(|| { - for i in range_inclusive(1001, 2000) { + for i in range_inclusive(1001i, 2000) { m.contains_key(&i); } }); @@ -2484,11 +2484,11 @@ fn hashmap_as_queue(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.insert(i, i); } - let mut k = 1; + let mut k = 1i; b.iter(|| { m.pop(&k); @@ -2503,11 +2503,11 @@ fn find_pop_insert(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in range_inclusive(1i, 1000) { m.insert(i, i); } - let mut k = 1; + let mut k = 1i; b.iter(|| { m.find(&(k + 400)); diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index 7236b527831..b1164981c0b 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -36,12 +36,12 @@ ```rust # extern crate debug; # fn main() { -format!("Hello"); // => "Hello" -format!("Hello, {:s}!", "world"); // => "Hello, world!" -format!("The number is {:d}", 1); // => "The number is 1" -format!("{:?}", (3, 4)); // => "(3, 4)" -format!("{value}", value=4); // => "4" -format!("{} {}", 1, 2); // => "1 2" +format!("Hello"); // => "Hello" +format!("Hello, {:s}!", "world"); // => "Hello, world!" +format!("The number is {:d}", 1i); // => "The number is 1" +format!("{:?}", (3i, 4i)); // => "(3, 4)" +format!("{value}", value=4i); // => "4" +format!("{} {}", 1i, 2i); // => "1 2" # } ``` @@ -65,7 +65,7 @@ iterator advances. This leads to behavior like this: ```rust -format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2" +format!("{1} {} {0} {}", 1i, 2i); // => "2 1 1 2" ``` The internal iterator over the argument has not been advanced by the time the @@ -94,9 +94,9 @@ ```rust # extern crate debug; # fn main() { -format!("{argument}", argument = "test"); // => "test" -format!("{name} {}", 1, name = 2); // => "2 1" -format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3); // => "a 3 ()" +format!("{argument}", argument = "test"); // => "test" +format!("{name} {}", 1i, name = 2i); // => "2 1" +format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3i); // => "a 3 ()" # } ``` diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 84a1253e5b4..5d9865fded3 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -93,7 +93,7 @@ pub fn u64_to_le_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { let mut n = n; while i > 0u { bytes.push((n & 255_u64) as u8); - n >>= 8_u64; + n >>= 8; i -= 1u; } f(bytes.as_slice()) @@ -130,7 +130,7 @@ pub fn u64_to_be_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { let mut bytes = vec!(); let mut i = size; while i > 0u { - let shift = ((i - 1u) * 8u) as u64; + let shift = (i - 1u) * 8u; bytes.push((n >> shift) as u8); i -= 1u; } diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index a801dd0e7cb..d8e04f18239 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -1164,7 +1164,7 @@ pub fn tmpdir() -> TempDir { let dir = &tmpdir.join("di_readdir"); check!(mkdir(dir, io::UserRWX)); let prefix = "foo"; - for n in range(0,3) { + for n in range(0i,3) { let f = dir.join(format!("{}.txt", n)); let mut w = check!(File::create(&f)); let msg_str = format!("{}{}", prefix, n.to_str()); diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index ec3d9370833..3443a85b468 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -611,7 +611,7 @@ fn io_read_at_least() { fn bench_mem_writer(b: &mut Bencher) { b.iter(|| { let mut wr = MemWriter::new(); - for _i in range(0, 10) { + for _i in range(0u, 10) { wr.write([5, .. 10]).unwrap(); } assert_eq!(wr.unwrap().as_slice(), [5, .. 100].as_slice()); @@ -624,7 +624,7 @@ fn bench_mem_reader(b: &mut Bencher) { let buf = Vec::from_slice([5 as u8, ..100]); { let mut rdr = MemReader::new(buf); - for _i in range(0, 10) { + for _i in range(0u, 10) { let mut buf = [0 as u8, .. 10]; rdr.read(buf).unwrap(); assert_eq!(buf.as_slice(), [5, .. 10].as_slice()); @@ -639,7 +639,7 @@ fn bench_buf_writer(b: &mut Bencher) { let mut buf = [0 as u8, ..100]; { let mut wr = BufWriter::new(buf); - for _i in range(0, 10) { + for _i in range(0u, 10) { wr.write([5, .. 10]).unwrap(); } } @@ -653,7 +653,7 @@ fn bench_buf_reader(b: &mut Bencher) { let buf = [5 as u8, ..100]; { let mut rdr = BufReader::new(buf); - for _i in range(0, 10) { + for _i in range(0u, 10) { let mut buf = [0 as u8, .. 10]; rdr.read(buf).unwrap(); assert_eq!(buf.as_slice(), [5, .. 10].as_slice()); diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 8ffb057c934..7d6ab9d7419 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -1154,7 +1154,7 @@ pub fn peer_name(addr: SocketAddr) { port).unwrap()); }); let _l = rx.recv(); - for i in range(0, 1001) { + for i in range(0i, 1001) { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} @@ -1258,7 +1258,7 @@ pub fn peer_name(addr: SocketAddr) { assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); s.set_timeout(Some(20)); - for i in range(0, 1001) { + for i in range(0i, 1001) { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, @@ -1298,7 +1298,7 @@ pub fn peer_name(addr: SocketAddr) { assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); tx.send(()); - for _ in range(0, 100) { + for _ in range(0i, 100) { assert!(s.write([0, ..128 * 1024]).is_ok()); } }) @@ -1318,7 +1318,7 @@ pub fn peer_name(addr: SocketAddr) { let mut s = a.accept().unwrap(); s.set_write_timeout(Some(20)); - for i in range(0, 1001) { + for i in range(0i, 1001) { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index e1f9cb3889f..5f6de52f866 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -569,7 +569,7 @@ pub fn socket_name(addr: SocketAddr) { let _b = UdpSocket::bind(addr2).unwrap(); a.set_write_timeout(Some(1000)); - for _ in range(0, 100) { + for _ in range(0u, 100) { match a.sendto([0, ..4*1024], addr2) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index 8f4f66836ad..c5ddda9945d 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -321,7 +321,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) { }; spawn(proc() { - for _ in range(0, times) { + for _ in range(0u, times) { let mut stream = UnixStream::connect(&path2); match stream.write([100]) { Ok(..) => {} @@ -477,7 +477,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) { tx.send(UnixStream::connect(&addr2).unwrap()); }); let l = rx.recv(); - for i in range(0, 1001) { + for i in range(0u, 1001) { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} @@ -586,7 +586,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) { assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); s.set_timeout(Some(20)); - for i in range(0, 1001) { + for i in range(0u, 1001) { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, @@ -629,7 +629,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) { assert_eq!(s.read([0]).err().unwrap().kind, TimedOut); tx.send(()); - for _ in range(0, 100) { + for _ in range(0u, 100) { assert!(s.write([0, ..128 * 1024]).is_ok()); } }) @@ -647,7 +647,7 @@ pub fn smalltest(server: proc(UnixStream):Send, client: proc(UnixStream):Send) { let mut s = a.accept().unwrap(); s.set_write_timeout(Some(20)); - for i in range(0, 1001) { + for i in range(0u, 1001) { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 1dcf08b2322..ecd6693990c 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -908,7 +908,7 @@ pub fn sleeper() -> Process { iotest!(fn test_zero() { let mut p = sleeper(); p.signal_kill().unwrap(); - for _ in range(0, 20) { + for _ in range(0i, 20) { if p.signal(0).is_err() { assert!(!p.wait().unwrap().success()); return diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index da099953a49..9ae855536ac 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -115,7 +115,7 @@ pub fn sleep(&mut self, msecs: u64) { /// let mut timer = Timer::new().unwrap(); /// let ten_milliseconds = timer.oneshot(10); /// - /// for _ in range(0, 100) { /* do work */ } + /// for _ in range(0u, 100) { /* do work */ } /// /// // blocks until 10 ms after the `oneshot` call /// ten_milliseconds.recv(); @@ -157,12 +157,12 @@ pub fn oneshot(&mut self, msecs: u64) -> Receiver<()> { /// let mut timer = Timer::new().unwrap(); /// let ten_milliseconds = timer.periodic(10); /// - /// for _ in range(0, 100) { /* do work */ } + /// for _ in range(0u, 100) { /* do work */ } /// /// // blocks until 10 ms after the `periodic` call /// ten_milliseconds.recv(); /// - /// for _ in range(0, 100) { /* do work */ } + /// for _ in range(0u, 100) { /* do work */ } /// /// // blocks until 20 ms after the `periodic` call (*not* 10ms after the /// // previous `recv`) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 58f65c90b3b..4db15d2cbbe 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -32,7 +32,7 @@ /// # #![allow(unreachable_code)] /// fail!(); /// fail!("this is a terrible mistake!"); -/// fail!(4); // fail with the value of 4 to be collected elsewhere +/// fail!(4i); // fail with the value of 4 to be collected elsewhere /// fail!("this is a {} {message}", "fancy", message = "message"); /// ``` #[macro_export] @@ -80,7 +80,7 @@ fn run_fmt(fmt: &::std::fmt::Arguments) -> ! { /// // assert with a custom message /// # let x = true; /// assert!(x, "x wasn't true!"); -/// # let a = 3; let b = 27; +/// # let a = 3i; let b = 27i; /// assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] @@ -105,8 +105,8 @@ macro_rules! assert( /// # Example /// /// ``` -/// let a = 3; -/// let b = 1 + 2; +/// let a = 3i; +/// let b = 1i + 2i; /// assert_eq!(a, b); /// ``` #[macro_export] @@ -147,7 +147,7 @@ macro_rules! assert_eq( /// // assert with a custom message /// # let x = true; /// debug_assert!(x, "x wasn't true!"); -/// # let a = 3; let b = 27; +/// # let a = 3i; let b = 27i; /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] @@ -168,8 +168,8 @@ macro_rules! debug_assert( /// # Example /// /// ``` -/// let a = 3; -/// let b = 1 + 2; +/// let a = 3i; +/// let b = 1i + 2i; /// debug_assert_eq!(a, b); /// ``` #[macro_export] @@ -220,7 +220,7 @@ macro_rules! unimplemented( /// ``` /// format!("test"); /// format!("hello {}", "world!"); -/// format!("x = {}, y = {y}", 10, y = 30); +/// format!("x = {}, y = {y}", 10i, y = 30i); /// ``` #[macro_export] macro_rules! format( @@ -335,7 +335,7 @@ macro_rules! vec( /// let (tx1, rx1) = channel(); /// let (tx2, rx2) = channel(); /// # fn long_running_task() {} -/// # fn calculate_the_answer() -> int { 42 } +/// # fn calculate_the_answer() -> int { 42i } /// /// spawn(proc() { long_running_task(); tx1.send(()) }); /// spawn(proc() { tx2.send(calculate_the_answer()) }); @@ -506,7 +506,7 @@ macro_rules! concat_idents( ($($e:ident),*) => ({ /* compiler built-in */ }) ) /// # Example /// /// ``` - /// let s = concat!("test", 10, 'b', true); + /// let s = concat!("test", 10i, 'b', true); /// assert_eq!(s, "test10btrue"); /// ``` #[macro_export] diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 7301f9b08e9..50b2e0ff343 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -128,11 +128,11 @@ pub fn from_str_radix(str: &str, radix: uint) -> Option { /// Helper function for testing numeric operations #[cfg(test)] pub fn test_num(ten: T, two: T) { - assert_eq!(ten.add(&two), cast(12).unwrap()); - assert_eq!(ten.sub(&two), cast(8).unwrap()); - assert_eq!(ten.mul(&two), cast(20).unwrap()); - assert_eq!(ten.div(&two), cast(5).unwrap()); - assert_eq!(ten.rem(&two), cast(0).unwrap()); + assert_eq!(ten.add(&two), cast(12i).unwrap()); + assert_eq!(ten.sub(&two), cast(8i).unwrap()); + assert_eq!(ten.mul(&two), cast(20i).unwrap()); + assert_eq!(ten.div(&two), cast(5i).unwrap()); + assert_eq!(ten.rem(&two), cast(0i).unwrap()); assert_eq!(ten.add(&two), ten + two); assert_eq!(ten.sub(&two), ten - two); @@ -760,14 +760,14 @@ macro_rules! assert_pow( assert_eq!(result, naive_pow($num, $exp)); }} ) - assert_pow!((3, 0 ) => 1); - assert_pow!((5, 1 ) => 5); - assert_pow!((-4, 2 ) => 16); - assert_pow!((0.5, 5 ) => 0.03125); - assert_pow!((8, 3 ) => 512); - assert_pow!((8.0, 5 ) => 32768.0); - assert_pow!((8.5, 5 ) => 44370.53125); - assert_pow!((2u64, 50) => 1125899906842624); + assert_pow!((3i, 0 ) => 1); + assert_pow!((5i, 1 ) => 5); + assert_pow!((-4i, 2 ) => 16); + assert_pow!((0.5f64, 5 ) => 0.03125); + assert_pow!((8i, 3 ) => 512); + assert_pow!((8.0f64, 5 ) => 32768.0); + assert_pow!((8.5f64, 5 ) => 44370.53125); + assert_pow!((2u64, 50) => 1125899906842624); } } @@ -781,7 +781,7 @@ mod bench { #[bench] fn bench_pow_function(b: &mut Bencher) { - let v = Vec::from_fn(1024, |n| n); - b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));}); + let v = Vec::from_fn(1024u, |n| n); + b.iter(|| {v.iter().fold(0u, |old, new| num::pow(old, *new));}); } } diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index adc532879e2..ffe4a94d2a2 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -252,7 +252,7 @@ pub fn random() -> T { /// use std::rand::{task_rng, sample}; /// /// let mut rng = task_rng(); -/// let sample = sample(&mut rng, range(1, 100), 5); +/// let sample = sample(&mut rng, range(1i, 100), 5); /// println!("{}", sample); /// ``` pub fn sample, R: Rng>(rng: &mut R, @@ -305,17 +305,17 @@ fn test_fill_bytes_default() { #[test] fn test_gen_range() { let mut r = task_rng(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let a = r.gen_range(-3i, 42); assert!(a >= -3 && a < 42); - assert_eq!(r.gen_range(0, 1), 0); - assert_eq!(r.gen_range(-12, -11), -12); + assert_eq!(r.gen_range(0i, 1), 0); + assert_eq!(r.gen_range(-12i, -11), -12); } - for _ in range(0, 1000) { - let a = r.gen_range(10, 42); + for _ in range(0u, 1000) { + let a = r.gen_range(10i, 42); assert!(a >= 10 && a < 42); - assert_eq!(r.gen_range(0, 1), 0); + assert_eq!(r.gen_range(0i, 1), 0); assert_eq!(r.gen_range(3_000_000u, 3_000_001), 3_000_000); } @@ -369,7 +369,7 @@ fn test_gen_vec() { #[test] fn test_choose() { let mut r = task_rng(); - assert_eq!(r.choose([1, 1, 1]).map(|&x|x), Some(1)); + assert_eq!(r.choose([1i, 1, 1]).map(|&x|x), Some(1)); let v: &[int] = &[]; assert_eq!(r.choose(v), None); @@ -380,15 +380,15 @@ fn test_shuffle() { let mut r = task_rng(); let empty: &mut [int] = &mut []; r.shuffle(empty); - let mut one = [1]; + let mut one = [1i]; r.shuffle(one); assert_eq!(one.as_slice(), &[1]); - let mut two = [1, 2]; + let mut two = [1i, 2]; r.shuffle(two); assert!(two == [1, 2] || two == [2, 1]); - let mut x = [1, 1, 1]; + let mut x = [1i, 1, 1]; r.shuffle(x); assert_eq!(x.as_slice(), &[1, 1, 1]); } @@ -397,7 +397,7 @@ fn test_shuffle() { fn test_task_rng() { let mut r = task_rng(); r.gen::(); - let mut v = [1, 1, 1]; + let mut v = [1i, 1, 1]; r.shuffle(v); assert_eq!(v.as_slice(), &[1, 1, 1]); assert_eq!(r.gen_range(0u, 1u), 0u); @@ -419,8 +419,8 @@ fn test_random() { #[test] fn test_sample() { - let min_val = 1; - let max_val = 100; + let min_val = 1i; + let max_val = 100i; let mut r = task_rng(); let vals = range(min_val, max_val).collect::>(); diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index f507011c2b9..1c1aab15361 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -282,7 +282,7 @@ fn test_os_rng() { fn test_os_rng_tasks() { let mut txs = vec!(); - for _ in range(0, 20) { + for _ in range(0u, 20) { let (tx, rx) = channel(); txs.push(tx); task::spawn(proc() { @@ -295,7 +295,7 @@ fn test_os_rng_tasks() { task::deschedule(); let mut v = [0u8, .. 1000]; - for _ in range(0, 100) { + for _ in range(0u, 100) { r.next_u32(); task::deschedule(); r.next_u64(); diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index b98fe8f0aae..e3652ffac6e 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -949,7 +949,7 @@ macro_rules! sym( ($e:expr, $t:ident) => (unsafe { let _c = Cleanup { handle: process, SymCleanup: SymCleanup }; // And now that we're done with all the setup, do the stack walking! - let mut i = 0; + let mut i = 0i; try!(write!(w, "stack backtrace:\n")); while StackWalk64(image, process, thread, &mut frame, &mut context, 0 as *libc::c_void, 0 as *libc::c_void, diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index ccc67e3f8b0..78da605143d 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -181,7 +181,7 @@ fn test_interface_unwrap() { #[test] fn test_get_ref_method() { - let mut f = Future::from_value(22); + let mut f = Future::from_value(22i); assert_eq!(*f.get_ref(), 22); } diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index cf95f5b088f..da0c3daefe7 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -89,7 +89,7 @@ pub fn execute(&mut self, f: proc(&T):Send) { fn test_task_pool() { let f: || -> proc(uint):Send -> uint = || { proc(i) i }; let mut pool = TaskPool::new(4, f); - for _ in range(0, 8) { + for _ in range(0u, 8) { pool.execute(proc(i) println!("Hello from thread {}!", *i)); } } diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 9a1c0151e54..5deb7f151bb 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -56,9 +56,9 @@ fn test_simple_types() { fn test_vectors() { let x: Vec = vec![]; assert_eq!(x.to_str(), "[]".to_string()); - assert_eq!((vec![1]).to_str(), "[1]".to_string()); - assert_eq!((vec![1, 2, 3]).to_str(), "[1, 2, 3]".to_string()); - assert!((vec![vec![], vec![1], vec![1, 1]]).to_str() == + assert_eq!((vec![1i]).to_str(), "[1]".to_string()); + assert_eq!((vec![1i, 2, 3]).to_str(), "[1, 2, 3]".to_string()); + assert!((vec![vec![], vec![1i], vec![1i, 1]]).to_str() == "[[], [1], [1, 1]]".to_string()); } } diff --git a/src/libsync/atomics.rs b/src/libsync/atomics.rs index 7d9a18cfbda..8ce17b9bf3b 100644 --- a/src/libsync/atomics.rs +++ b/src/libsync/atomics.rs @@ -195,8 +195,8 @@ fn option_empty() { #[test] fn option_swap() { - let p = AtomicOption::new(box 1); - let a = box 2; + let p = AtomicOption::new(box 1i); + let a = box 2i; let b = p.swap(a, SeqCst); @@ -206,12 +206,12 @@ fn option_swap() { #[test] fn option_take() { - let p = AtomicOption::new(box 1); + let p = AtomicOption::new(box 1i); assert!(p.take(SeqCst) == Some(box 1)); assert!(p.take(SeqCst) == None); - let p2 = box 2; + let p2 = box 2i; p.swap(p2, SeqCst); assert!(p.take(SeqCst) == Some(box 2)); @@ -219,11 +219,11 @@ fn option_take() { #[test] fn option_fill() { - let p = AtomicOption::new(box 1); - assert!(p.fill(box 2, SeqCst).is_some()); // should fail; shouldn't leak! + let p = AtomicOption::new(box 1i); + assert!(p.fill(box 2i, SeqCst).is_some()); // should fail; shouldn't leak! assert!(p.take(SeqCst) == Some(box 1)); - assert!(p.fill(box 2, SeqCst).is_none()); // shouldn't fail + assert!(p.fill(box 2i, SeqCst).is_none()); // shouldn't fail assert!(p.take(SeqCst) == Some(box 2)); } } diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 842743657a6..3e8f4eef370 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -77,9 +77,9 @@ //! // Create a simple streaming channel //! let (tx, rx) = channel(); //! spawn(proc() { -//! tx.send(10); +//! tx.send(10i); //! }); -//! assert_eq!(rx.recv(), 10); +//! assert_eq!(rx.recv(), 10i); //! ``` //! //! Shared usage: @@ -87,14 +87,14 @@ //! ``` //! // Create a shared channel which can be sent along from many tasks //! let (tx, rx) = channel(); -//! for i in range(0, 10) { +//! for i in range(0i, 10i) { //! let tx = tx.clone(); //! spawn(proc() { //! tx.send(i); //! }) //! } //! -//! for _ in range(0, 10) { +//! for _ in range(0i, 10i) { //! let j = rx.recv(); //! assert!(0 <= j && j < 10); //! } @@ -113,7 +113,7 @@ //! Synchronous channels: //! //! ``` -//! let (tx, rx) = sync_channel(0); +//! let (tx, rx) = sync_channel::(0); //! spawn(proc() { //! // This will wait for the parent task to start receiving //! tx.send(53); @@ -504,15 +504,15 @@ pub fn channel() -> (Sender, Receiver) { /// let (tx, rx) = sync_channel(1); /// /// // this returns immediately -/// tx.send(1); +/// tx.send(1i); /// /// spawn(proc() { /// // this will block until the previous message has been received -/// tx.send(2); +/// tx.send(2i); /// }); /// -/// assert_eq!(rx.recv(), 1); -/// assert_eq!(rx.recv(), 2); +/// assert_eq!(rx.recv(), 1i); +/// assert_eq!(rx.recv(), 2i); /// ``` pub fn sync_channel(bound: uint) -> (SyncSender, Receiver) { let a = Arc::new(Unsafe::new(sync::Packet::new(bound))); @@ -577,11 +577,11 @@ pub fn send(&self, t: T) { /// let (tx, rx) = channel(); /// /// // This send is always successful - /// assert_eq!(tx.send_opt(1), Ok(())); + /// assert_eq!(tx.send_opt(1i), Ok(())); /// /// // This send will fail because the receiver is gone /// drop(rx); - /// assert_eq!(tx.send_opt(1), Err(1)); + /// assert_eq!(tx.send_opt(1i), Err(1)); /// ``` pub fn send_opt(&self, t: T) -> Result<(), T> { // In order to prevent starvation of other tasks in situations where @@ -1041,25 +1041,25 @@ pub fn stress_factor() -> uint { } test!(fn smoke() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); tx.send(1); assert_eq!(rx.recv(), 1); }) test!(fn drop_full() { let (tx, _rx) = channel(); - tx.send(box 1); + tx.send(box 1i); }) test!(fn drop_full_shared() { let (tx, _rx) = channel(); drop(tx.clone()); drop(tx.clone()); - tx.send(box 1); + tx.send(box 1i); }) test!(fn smoke_shared() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); @@ -1068,7 +1068,7 @@ pub fn stress_factor() -> uint { }) test!(fn smoke_threads() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); spawn(proc() { tx.send(1); }); @@ -1076,19 +1076,19 @@ pub fn stress_factor() -> uint { }) test!(fn smoke_port_gone() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); drop(rx); tx.send(1); } #[should_fail]) test!(fn smoke_shared_port_gone() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); drop(rx); tx.send(1); } #[should_fail]) test!(fn smoke_shared_port_gone2() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); drop(rx); let tx2 = tx.clone(); drop(tx); @@ -1096,7 +1096,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn port_gone_concurrent() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); spawn(proc() { rx.recv(); }); @@ -1104,7 +1104,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn port_gone_concurrent_shared() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); let tx2 = tx.clone(); spawn(proc() { rx.recv(); @@ -1130,7 +1130,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn chan_gone_concurrent() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); spawn(proc() { tx.send(1); tx.send(1); @@ -1139,11 +1139,11 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn stress() { - let (tx, rx) = channel(); + let (tx, rx) = channel::(); spawn(proc() { - for _ in range(0, 10000) { tx.send(1); } + for _ in range(0u, 10000) { tx.send(1i); } }); - for _ in range(0, 10000) { + for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } }) @@ -1183,14 +1183,14 @@ fn send_from_outside_runtime() { let tx4 = tx3.clone(); spawn(proc() { tx1.send(()); - for _ in range(0, 40) { + for _ in range(0i, 40) { assert_eq!(rx2.recv(), 1); } tx3.send(()); }); rx1.recv(); native::task::spawn(proc() { - for _ in range(0, 40) { + for _ in range(0i, 40) { tx2.send(1); } tx4.send(()); @@ -1204,12 +1204,12 @@ fn recv_from_outside_runtime() { let (tx, rx) = channel::(); let (dtx, drx) = channel(); native::task::spawn(proc() { - for _ in range(0, 40) { + for _ in range(0i, 40) { assert_eq!(rx.recv(), 1); } dtx.send(()); }); - for _ in range(0, 40) { + for _ in range(0u, 40) { tx.send(1); } drx.recv(); @@ -1377,10 +1377,10 @@ fn no_runtime() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); spawn(proc() { - tx.send(box 10); + tx.send(box 10i); }); spawn(proc() { - assert!(rx.recv() == box 10); + assert!(rx.recv() == box 10i); }); } }) @@ -1415,8 +1415,8 @@ fn recv(rx: Receiver>, i: int) { test!(fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = channel(); - for _ in range(0, 10000) { tx.send(()); } - for _ in range(0, 10000) { rx.recv(); } + for _ in range(0i, 10000) { tx.send(()); } + for _ in range(0i, 10000) { rx.recv(); } }) test!(fn shared_chan_stress() { @@ -1511,7 +1511,7 @@ fn recv(rx: Receiver>, i: int) { tx2.send(()); }); // make sure the other task has gone to sleep - for _ in range(0, 5000) { task::deschedule(); } + for _ in range(0u, 5000) { task::deschedule(); } // upgrade to a shared chan and send a message let t = tx.clone(); @@ -1527,11 +1527,11 @@ fn recv(rx: Receiver>, i: int) { let (tx, rx) = channel(); let t = Thread::start(proc() { - for _ in range(0, 1000) { + for _ in range(0u, 1000) { tx.send(()); } }); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { rx.recv(); } t.join(); @@ -1553,7 +1553,7 @@ fn recv(rx: Receiver>, i: int) { } cdone.send(()); }); - for _ in range(0, 10) { + for _ in range(0u, 10) { tx.send(()); } t.join(); @@ -1574,18 +1574,18 @@ pub fn stress_factor() -> uint { } test!(fn smoke() { - let (tx, rx) = sync_channel(1); + let (tx, rx) = sync_channel::(1); tx.send(1); assert_eq!(rx.recv(), 1); }) test!(fn drop_full() { let (tx, _rx) = sync_channel(1); - tx.send(box 1); + tx.send(box 1i); }) test!(fn smoke_shared() { - let (tx, rx) = sync_channel(1); + let (tx, rx) = sync_channel::(1); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); @@ -1594,7 +1594,7 @@ pub fn stress_factor() -> uint { }) test!(fn smoke_threads() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { tx.send(1); }); @@ -1602,13 +1602,13 @@ pub fn stress_factor() -> uint { }) test!(fn smoke_port_gone() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); drop(rx); tx.send(1); } #[should_fail]) test!(fn smoke_shared_port_gone2() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); drop(rx); let tx2 = tx.clone(); drop(tx); @@ -1616,7 +1616,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn port_gone_concurrent() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { rx.recv(); }); @@ -1624,7 +1624,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn port_gone_concurrent_shared() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); spawn(proc() { rx.recv(); @@ -1650,7 +1650,7 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn chan_gone_concurrent() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { tx.send(1); tx.send(1); @@ -1659,11 +1659,11 @@ pub fn stress_factor() -> uint { } #[should_fail]) test!(fn stress() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { - for _ in range(0, 10000) { tx.send(1); } + for _ in range(0u, 10000) { tx.send(1); } }); - for _ in range(0, 10000) { + for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } }) @@ -1840,19 +1840,19 @@ pub fn stress_factor() -> uint { test!(fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::>(0); spawn(proc() { - tx.send(box 10); + tx.send(box 10i); }); spawn(proc() { - assert!(rx.recv() == box 10); + assert!(rx.recv() == box 10i); }); } }) test!(fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::>(0); send(tx, 0); recv(rx, 0); @@ -1880,8 +1880,8 @@ fn recv(rx: Receiver>, i: int) { test!(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 range(0, 10000) { tx.send(()); } - for _ in range(0, 10000) { rx.recv(); } + for _ in range(0u, 10000) { tx.send(()); } + for _ in range(0u, 10000) { rx.recv(); } }) test!(fn shared_chan_stress() { @@ -1968,15 +1968,15 @@ fn recv(rx: Receiver>, i: int) { // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted test!(fn destroy_upgraded_shared_port_when_sender_still_active() { - let (tx, rx) = sync_channel(0); - let (tx2, rx2) = sync_channel(0); + let (tx, rx) = sync_channel::<()>(0); + let (tx2, rx2) = sync_channel::<()>(0); spawn(proc() { rx.recv(); // wait on a oneshot drop(rx); // destroy a shared tx2.send(()); }); // make sure the other task has gone to sleep - for _ in range(0, 5000) { task::deschedule(); } + for _ in range(0u, 5000) { task::deschedule(); } // upgrade to a shared chan and send a message let t = tx.clone(); @@ -1990,7 +1990,7 @@ fn recv(rx: Receiver>, i: int) { test!(fn try_recvs_off_the_runtime() { use std::rt::thread::Thread; - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::<()>(0); let (cdone, pdone) = channel(); let t = Thread::start(proc() { let mut hits = 0; @@ -2003,7 +2003,7 @@ fn recv(rx: Receiver>, i: int) { } cdone.send(()); }); - for _ in range(0, 10) { + for _ in range(0u, 10) { tx.send(()); } t.join(); @@ -2011,26 +2011,26 @@ fn recv(rx: Receiver>, i: int) { }) test!(fn send_opt1() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { rx.recv(); }); assert_eq!(tx.send_opt(1), Ok(())); }) test!(fn send_opt2() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); }) test!(fn send_opt3() { - let (tx, rx) = sync_channel(1); + let (tx, rx) = sync_channel::(1); assert_eq!(tx.send_opt(1), Ok(())); spawn(proc() { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); }) test!(fn send_opt4() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); let (done, donerx) = channel(); let done2 = done.clone(); @@ -2048,27 +2048,27 @@ fn recv(rx: Receiver>, i: int) { }) test!(fn try_send1() { - let (tx, _rx) = sync_channel(0); + let (tx, _rx) = sync_channel::(0); assert_eq!(tx.try_send(1), Err(Full(1))); }) test!(fn try_send2() { - let (tx, _rx) = sync_channel(1); + let (tx, _rx) = sync_channel::(1); assert_eq!(tx.try_send(1), Ok(())); assert_eq!(tx.try_send(1), Err(Full(1))); }) test!(fn try_send3() { - let (tx, rx) = sync_channel(1); + let (tx, rx) = sync_channel::(1); assert_eq!(tx.try_send(1), Ok(())); drop(rx); assert_eq!(tx.try_send(1), Err(RecvDisconnected(1))); }) test!(fn try_send4() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { - for _ in range(0, 1000) { task::deschedule(); } + for _ in range(0u, 1000) { task::deschedule(); } assert_eq!(tx.try_send(1), Ok(())); }); assert_eq!(rx.recv(), 1); diff --git a/src/libsync/comm/select.rs b/src/libsync/comm/select.rs index de89e33ffda..8d56f9a003b 100644 --- a/src/libsync/comm/select.rs +++ b/src/libsync/comm/select.rs @@ -30,15 +30,15 @@ //! let (tx1, rx1) = channel(); //! let (tx2, rx2) = channel(); //! -//! tx1.send(1); -//! tx2.send(2); +//! tx1.send(1i); +//! tx2.send(2i); //! //! select! { //! val = rx1.recv() => { -//! assert_eq!(val, 1); +//! assert_eq!(val, 1i); //! }, //! val = rx2.recv() => { -//! assert_eq!(val, 2); +//! assert_eq!(val, 2i); //! } //! } //! ``` @@ -397,10 +397,10 @@ macro_rules! select { let (tx3, rx3) = channel::(); spawn(proc() { - for _ in range(0, 20) { task::deschedule(); } + for _ in range(0u, 20) { task::deschedule(); } tx1.send(1); rx3.recv(); - for _ in range(0, 20) { task::deschedule(); } + for _ in range(0u, 20) { task::deschedule(); } }); select! ( @@ -420,7 +420,7 @@ macro_rules! select { let (tx3, rx3) = channel::<()>(); spawn(proc() { - for _ in range(0, 20) { task::deschedule(); } + for _ in range(0u, 20) { task::deschedule(); } tx1.send(1); tx2.send(2); rx3.recv(); @@ -521,7 +521,7 @@ macro_rules! select { tx3.send(()); }); - for _ in range(0, 1000) { task::deschedule(); } + for _ in range(0u, 1000) { task::deschedule(); } drop(tx1.clone()); tx2.send(()); rx3.recv(); @@ -624,7 +624,7 @@ macro_rules! select { tx2.send(()); }); - for _ in range(0, 100) { task::deschedule() } + for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); }) @@ -643,7 +643,7 @@ macro_rules! select { tx2.send(()); }); - for _ in range(0, 100) { task::deschedule() } + for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); }) @@ -661,13 +661,13 @@ macro_rules! select { tx2.send(()); }); - for _ in range(0, 100) { task::deschedule() } + for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); }) test!(fn sync1() { - let (tx, rx) = sync_channel(1); + let (tx, rx) = sync_channel::(1); tx.send(1); select! { n = rx.recv() => { assert_eq!(n, 1); } @@ -675,9 +675,9 @@ macro_rules! select { }) test!(fn sync2() { - let (tx, rx) = sync_channel(0); + let (tx, rx) = sync_channel::(0); spawn(proc() { - for _ in range(0, 100) { task::deschedule() } + for _ in range(0u, 100) { task::deschedule() } tx.send(1); }); select! { @@ -686,8 +686,8 @@ macro_rules! select { }) test!(fn sync3() { - let (tx1, rx1) = sync_channel(0); - let (tx2, rx2) = channel(); + let (tx1, rx1) = sync_channel::(0); + let (tx2, rx2): (Sender, Receiver) = channel(); spawn(proc() { tx1.send(1); }); spawn(proc() { tx2.send(2); }); select! { diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs index f0184dc8164..18608a0a370 100644 --- a/src/libsync/deque.rs +++ b/src/libsync/deque.rs @@ -72,7 +72,7 @@ // size. // // The size in question is 1 << MIN_BITS -static MIN_BITS: int = 7; +static MIN_BITS: uint = 7; struct Deque { bottom: AtomicInt, @@ -138,7 +138,7 @@ pub struct BufferPool { /// LLVM is probably pretty good at doing this already. struct Buffer { storage: *T, - log_size: int, + log_size: uint, } impl BufferPool { @@ -157,7 +157,7 @@ pub fn deque(&self) -> (Worker, Stealer) { Stealer { deque: b, noshare: marker::NoShare }) } - fn alloc(&self, bits: int) -> Box> { + fn alloc(&mut self, bits: uint) -> Box> { unsafe { let mut pool = self.pool.lock(); match pool.iter().position(|x| x.size() >= (1 << bits)) { @@ -225,7 +225,7 @@ fn clone(&self) -> Stealer { // personally going to heavily comment what's going on here. impl Deque { - fn new(pool: BufferPool) -> Deque { + fn new(mut pool: BufferPool) -> Deque { let buf = pool.alloc(MIN_BITS); Deque { bottom: AtomicInt::new(0), @@ -345,12 +345,12 @@ fn drop(&mut self) { } #[inline] -fn buffer_alloc_size(log_size: int) -> uint { +fn buffer_alloc_size(log_size: uint) -> uint { (1 << log_size) * size_of::() } impl Buffer { - unsafe fn new(log_size: int) -> Buffer { + unsafe fn new(log_size: uint) -> Buffer { let size = buffer_alloc_size::(log_size); let buffer = allocate(size, min_align_of::()); Buffer { @@ -383,7 +383,10 @@ unsafe fn put(&self, i: int, t: T) { // Again, unsafe because this has incredibly dubious ownership violations. // It is assumed that this buffer is immediately dropped. unsafe fn resize(&self, b: int, t: int, delta: int) -> Buffer { - let buf = Buffer::new(self.log_size + delta); + // NB: not entirely obvious, but thanks to 2's complement, + // casting delta to uint and then adding gives the desired + // effect. + let buf = Buffer::new(self.log_size + delta as uint); for i in range(t, b) { buf.put(i, self.get(i)); } @@ -419,7 +422,7 @@ fn smoke() { let (w, s) = pool.deque(); assert_eq!(w.pop(), None); assert_eq!(s.steal(), Empty); - w.push(1); + w.push(1i); assert_eq!(w.pop(), Some(1)); w.push(1); assert_eq!(s.steal(), Data(1)); @@ -564,7 +567,7 @@ fn stress() { let mut rng = rand::task_rng(); let mut expected = 0; while expected < AMT { - if rng.gen_range(0, 3) == 2 { + if rng.gen_range(0i, 3) == 2 { match w.pop() { None => {} Some(2) => unsafe { HITS.fetch_add(1, SeqCst); }, @@ -629,7 +632,7 @@ fn no_starvation() { let mut myhit = false; 'outer: loop { for _ in range(0, rng.gen_range(0, AMT)) { - if !myhit && rng.gen_range(0, 3) == 2 { + if !myhit && rng.gen_range(0i, 3) == 2 { match w.pop() { None => {} Some((1, 2)) => myhit = true, diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index 1fe8e8fc0db..dff9fee2b77 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -259,7 +259,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } /// ``` /// use sync::{RWLock, Arc}; /// -/// let lock1 = Arc::new(RWLock::new(1)); +/// let lock1 = Arc::new(RWLock::new(1i)); /// let lock2 = lock1.clone(); /// /// spawn(proc() { @@ -396,7 +396,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } /// use sync::{Arc, Barrier}; /// /// let barrier = Arc::new(Barrier::new(10)); -/// for _ in range(0, 10) { +/// for _ in range(0u, 10) { /// let c = barrier.clone(); /// // The same messages will be printed together. /// // You will NOT see any interleaving. @@ -508,7 +508,7 @@ fn test_arc_condvar_poison() { #[test] #[should_fail] fn test_mutex_arc_poison() { - let arc = Arc::new(Mutex::new(1)); + let arc = Arc::new(Mutex::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.lock(); @@ -522,7 +522,7 @@ fn test_mutex_arc_poison() { fn test_mutex_arc_nested() { // Tests nested mutexes and access // to underlying data. - let arc = Arc::new(Mutex::new(1)); + let arc = Arc::new(Mutex::new(1i)); let arc2 = Arc::new(Mutex::new(arc)); task::spawn(proc() { let lock = arc2.lock(); @@ -554,7 +554,7 @@ fn drop(&mut self) { #[test] #[should_fail] fn test_rw_arc_poison_wr() { - let arc = Arc::new(RWLock::new(1)); + let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.write(); @@ -565,7 +565,7 @@ fn test_rw_arc_poison_wr() { } #[test] #[should_fail] fn test_rw_arc_poison_ww() { - let arc = Arc::new(RWLock::new(1)); + let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.write(); @@ -576,7 +576,7 @@ fn test_rw_arc_poison_ww() { } #[test] fn test_rw_arc_no_poison_rr() { - let arc = Arc::new(RWLock::new(1)); + let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.read(); @@ -587,7 +587,7 @@ fn test_rw_arc_no_poison_rr() { } #[test] fn test_rw_arc_no_poison_rw() { - let arc = Arc::new(RWLock::new(1)); + let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.read(); @@ -598,7 +598,7 @@ fn test_rw_arc_no_poison_rw() { } #[test] fn test_rw_arc_no_poison_dr() { - let arc = Arc::new(RWLock::new(1)); + let arc = Arc::new(RWLock::new(1i)); let arc2 = arc.clone(); let _ = task::try(proc() { let lock = arc2.write().downgrade(); @@ -610,13 +610,13 @@ fn test_rw_arc_no_poison_dr() { #[test] fn test_rw_arc() { - let arc = Arc::new(RWLock::new(0)); + let arc = Arc::new(RWLock::new(0i)); let arc2 = arc.clone(); let (tx, rx) = channel(); task::spawn(proc() { let mut lock = arc2.write(); - for _ in range(0, 10) { + for _ in range(0u, 10) { let tmp = *lock; *lock = -1; task::deschedule(); @@ -627,7 +627,7 @@ fn test_rw_arc() { // Readers try to catch the writer in the act let mut children = Vec::new(); - for _ in range(0, 5) { + for _ in range(0u, 5) { let arc3 = arc.clone(); children.push(try_future(proc() { let lock = arc3.read(); @@ -675,11 +675,11 @@ fn test_rw_downgrade() { // (4) tells writer and all other readers to contend as it downgrades. // (5) Writer attempts to set state back to 42, while downgraded task // and all reader tasks assert that it's 31337. - let arc = Arc::new(RWLock::new(0)); + let arc = Arc::new(RWLock::new(0i)); // Reader tasks let mut reader_convos = Vec::new(); - for _ in range(0, 10) { + for _ in range(0u, 10) { let ((tx1, rx1), (tx2, rx2)) = (channel(), channel()); reader_convos.push((tx1, rx2)); let arcn = arc.clone(); @@ -777,7 +777,7 @@ fn test_rw_write_cond_downgrade_read_race_helper() { let lock = lock.downgrade(); // if writer mistakenly got in, make sure it mutates state // before we assert on it - for _ in range(0, 5) { task::deschedule(); } + for _ in range(0u, 5) { task::deschedule(); } // make sure writer didn't get in. assert!(*lock); } @@ -788,7 +788,7 @@ fn test_rw_write_cond_downgrade_read_race() { // deschedules in the intuitively-right locations made it even less // likely, and I wasn't sure why :( . This is a mediocre "next best" // option. - for _ in range(0, 8) { + for _ in range(0u, 8) { test_rw_write_cond_downgrade_read_race_helper(); } } @@ -801,7 +801,7 @@ fn test_barrier() { let barrier = Arc::new(Barrier::new(10)); let (tx, rx) = channel(); - for _ in range(0, 9) { + for _ in range(0u, 9) { let c = barrier.clone(); let tx = tx.clone(); spawn(proc() { @@ -819,7 +819,7 @@ fn test_barrier() { barrier.wait(); // Now, the barrier is cleared and we should get data. - for _ in range(0, 9) { + for _ in range(0u, 9) { rx.recv(); } } diff --git a/src/libsync/one.rs b/src/libsync/one.rs index 5240d303ca4..6fad2c8aa40 100644 --- a/src/libsync/one.rs +++ b/src/libsync/one.rs @@ -129,7 +129,7 @@ mod test { #[test] fn smoke_once() { static mut o: Once = ONCE_INIT; - let mut a = 0; + let mut a = 0i; unsafe { o.doit(|| a += 1); } assert_eq!(a, 1); unsafe { o.doit(|| a += 1); } @@ -142,10 +142,10 @@ fn stampede_once() { static mut run: bool = false; let (tx, rx) = channel(); - for _ in range(0, 10) { + for _ in range(0u, 10) { let tx = tx.clone(); spawn(proc() { - for _ in range(0, 4) { task::deschedule() } + for _ in range(0u, 4) { task::deschedule() } unsafe { o.doit(|| { assert!(!run); @@ -165,7 +165,7 @@ fn stampede_once() { assert!(run); } - for _ in range(0, 10) { + for _ in range(0u, 10) { rx.recv(); } } diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index c5f452d3e58..28a08a7fef2 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -138,7 +138,7 @@ pub fn acquire(&self) { }); // Uncomment if you wish to test for sem races. Not // valgrind-friendly. - /* for _ in range(0, 1000) { task::deschedule(); } */ + /* for _ in range(0u, 1000) { task::deschedule(); } */ // Need to wait outside the exclusive. if waiter_nobe.is_some() { let _ = waiter_nobe.unwrap().recv(); @@ -642,10 +642,10 @@ fn test_sem_as_mutex() { let s2 = s.clone(); task::spawn(proc() { let _g = s2.access(); - for _ in range(0, 5) { task::deschedule(); } + for _ in range(0u, 5) { task::deschedule(); } }); let _g = s.access(); - for _ in range(0, 5) { task::deschedule(); } + for _ in range(0u, 5) { task::deschedule(); } } #[test] fn test_sem_as_cvar() { @@ -657,7 +657,7 @@ fn test_sem_as_cvar() { s2.acquire(); tx.send(()); }); - for _ in range(0, 5) { task::deschedule(); } + for _ in range(0u, 5) { task::deschedule(); } s.release(); let _ = rx.recv(); @@ -666,7 +666,7 @@ fn test_sem_as_cvar() { let s = Arc::new(Semaphore::new(0)); let s2 = s.clone(); task::spawn(proc() { - for _ in range(0, 5) { task::deschedule(); } + for _ in range(0u, 5) { task::deschedule(); } s2.release(); let _ = rx.recv(); }); @@ -705,7 +705,7 @@ fn test_sem_runtime_friendly_blocking() { tx.send(()); }); rx.recv(); // wait for child to come alive - for _ in range(0, 5) { task::deschedule(); } // let the child contend + for _ in range(0u, 5) { task::deschedule(); } // let the child contend } rx.recv(); // wait for child to be done } @@ -735,7 +735,7 @@ fn test_mutex_lock() { } fn access_shared(sharedstate: *mut int, m: &Arc, n: uint) { - for _ in range(0, n) { + for _ in range(0u, n) { let _g = m.lock(); let oldval = unsafe { *sharedstate }; task::deschedule(); @@ -780,7 +780,7 @@ fn test_mutex_cond_broadcast_helper(num_waiters: uint) { let m = Arc::new(Mutex::new()); let mut rxs = Vec::new(); - for _ in range(0, num_waiters) { + for _ in range(0u, num_waiters) { let mi = m.clone(); let (tx, rx) = channel(); rxs.push(rx); @@ -907,7 +907,7 @@ fn test_rwlock_exclusion(x: Arc, fn access_shared(sharedstate: &mut int, x: &Arc, mode: RWLockMode, n: uint) { - for _ in range(0, n) { + for _ in range(0u, n) { lock_rwlock_in_mode(x, mode, || { let oldval = *sharedstate; task::deschedule(); @@ -1033,7 +1033,7 @@ fn lock_cond(x: &Arc, blk: |c: &Condvar|) { let x = Arc::new(RWLock::new()); let mut rxs = Vec::new(); - for _ in range(0, num_waiters) { + for _ in range(0u, num_waiters) { let xi = x.clone(); let (tx, rx) = channel(); rxs.push(rx); diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs index 55d2f3062ba..a4da1fd2335 100644 --- a/src/libsync/spsc_queue.rs +++ b/src/libsync/spsc_queue.rs @@ -237,7 +237,7 @@ mod test { #[test] fn smoke() { let q = Queue::new(0); - q.push(1); + q.push(1i); q.push(2); assert_eq!(q.pop(), Some(1)); assert_eq!(q.pop(), Some(2)); @@ -259,7 +259,7 @@ fn drop_full() { #[test] fn smoke_bound() { let q = Queue::new(1); - q.push(1); + q.push(1i); q.push(2); assert_eq!(q.pop(), Some(1)); assert_eq!(q.pop(), Some(2)); @@ -281,7 +281,7 @@ fn stress_bound(bound: uint) { let b = a.clone(); let (tx, rx) = channel(); native::task::spawn(proc() { - for _ in range(0, 100000) { + for _ in range(0u, 100000) { loop { match b.pop() { Some(1) => break, @@ -292,7 +292,7 @@ fn stress_bound(bound: uint) { } tx.send(()); }); - for _ in range(0, 100000) { + for _ in range(0i, 100000) { a.push(1); } rx.recv(); diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 3d6266fd4c0..9771bc9386b 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -150,7 +150,7 @@ pub fn for_target(&self, os: Os, arch: Architecture) -> Option { impl Architecture { fn bit(&self) -> u32 { - 1 << (*self as u32) + 1 << (*self as uint) } } @@ -198,11 +198,11 @@ fn indices_are_correct() { assert_eq!(i, abi_data.abi.index()); } - let bits = 1 << (X86 as u32); - let bits = bits | 1 << (X86_64 as u32); + let bits = 1 << (X86 as uint); + let bits = bits | 1 << (X86_64 as uint); assert_eq!(IntelBits, bits); - let bits = 1 << (Arm as u32); + let bits = 1 << (Arm as uint); assert_eq!(ArmBits, bits); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index aeafc0e306c..64d381d2b12 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -675,8 +675,7 @@ pub enum IntTy { impl fmt::Show for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", - ast_util::int_ty_to_str(*self, None, ast_util::AutoSuffix)) + write!(f, "{}", ast_util::int_ty_to_str(*self, None)) } } @@ -691,8 +690,7 @@ pub enum UintTy { impl fmt::Show for UintTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", - ast_util::uint_ty_to_str(*self, None, ast_util::AutoSuffix)) + write!(f, "{}", ast_util::uint_ty_to_str(*self, None)) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d28553da691..95bd35764e7 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -107,19 +107,11 @@ pub fn is_path(e: Gc) -> bool { return match e.node { ExprPath(_) => true, _ => false }; } -pub enum SuffixMode { - ForceSuffix, - AutoSuffix, -} - // Get a string representation of a signed int type, with its value. // We want to avoid "45int" and "-3int" in favor of "45" and "-3" -pub fn int_ty_to_str(t: IntTy, val: Option, mode: SuffixMode) -> String { +pub fn int_ty_to_str(t: IntTy, val: Option) -> String { let s = match t { - TyI if val.is_some() => match mode { - AutoSuffix => "", - ForceSuffix => "i", - }, + TyI if val.is_some() => "i", TyI => "int", TyI8 => "i8", TyI16 => "i16", @@ -147,12 +139,9 @@ pub fn int_ty_max(t: IntTy) -> u64 { // Get a string representation of an unsigned int type, with its value. // We want to avoid "42uint" in favor of "42u" -pub fn uint_ty_to_str(t: UintTy, val: Option, mode: SuffixMode) -> String { +pub fn uint_ty_to_str(t: UintTy, val: Option) -> String { let s = match t { - TyU if val.is_some() => match mode { - AutoSuffix => "", - ForceSuffix => "u", - }, + TyU if val.is_some() => "u", TyU => "uint", TyU8 => "u8", TyU16 => "u16", diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 8e36339b0e5..9549d5b8389 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -212,10 +212,8 @@ pub fn to_str(t: &Token) -> String { res.push_char('\''); res } - LIT_INT(i, t) => ast_util::int_ty_to_str(t, Some(i), - ast_util::ForceSuffix), - LIT_UINT(u, t) => ast_util::uint_ty_to_str(t, Some(u), - ast_util::ForceSuffix), + LIT_INT(i, t) => ast_util::int_ty_to_str(t, Some(i)), + LIT_UINT(u, t) => ast_util::uint_ty_to_str(t, Some(u)), LIT_INT_UNSUFFIXED(i) => { (i as u64).to_str() } LIT_FLOAT(s, t) => { let mut body = String::from_str(get_ident(s).get()); diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 672e08af2d8..854aa80ca34 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -163,7 +163,7 @@ pub fn mk_printer(out: Box, linewidth: uint) -> Printer { let n: uint = 3 * linewidth; debug!("mk_printer {}", linewidth); let token: Vec = Vec::from_elem(n, Eof); - let size: Vec = Vec::from_elem(n, 0); + let size: Vec = Vec::from_elem(n, 0i); let scan_stack: Vec = Vec::from_elem(n, 0u); Printer { out: out, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index fafebd3c5dc..97e99ca692d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2319,13 +2319,11 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> { } ast::LitInt(i, t) => { word(&mut self.s, - ast_util::int_ty_to_str(t, Some(i), - ast_util::AutoSuffix).as_slice()) + ast_util::int_ty_to_str(t, Some(i)).as_slice()) } ast::LitUint(u, t) => { word(&mut self.s, - ast_util::uint_ty_to_str(t, Some(u), - ast_util::ForceSuffix).as_slice()) + ast_util::uint_ty_to_str(t, Some(u)).as_slice()) } ast::LitIntUnsuffixed(i) => { word(&mut self.s, format!("{}", i).as_slice()) diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index a3b2c23dfdf..d5cc2c7f304 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -173,7 +173,7 @@ fn test_len() { #[test] fn test_push_get() { let mut v = SmallVector::zero(); - v.push(1); + v.push(1i); assert_eq!(1, v.len()); assert_eq!(&1, v.get(0)); v.push(2); @@ -186,7 +186,7 @@ fn test_push_get() { #[test] fn test_from_iter() { - let v: SmallVector = (vec!(1, 2, 3)).move_iter().collect(); + let v: SmallVector = (vec!(1i, 2, 3)).move_iter().collect(); assert_eq!(3, v.len()); assert_eq!(&1, v.get(0)); assert_eq!(&2, v.get(1)); @@ -199,11 +199,11 @@ fn test_move_iter() { let v: Vec = v.move_iter().collect(); assert_eq!(Vec::new(), v); - let v = SmallVector::one(1); - assert_eq!(vec!(1), v.move_iter().collect()); + let v = SmallVector::one(1i); + assert_eq!(vec!(1i), v.move_iter().collect()); - let v = SmallVector::many(vec!(1, 2, 3)); - assert_eq!(vec!(1, 2, 3), v.move_iter().collect()); + let v = SmallVector::many(vec!(1i, 2i, 3i)); + assert_eq!(vec!(1i, 2i, 3i), v.move_iter().collect()); } #[test] @@ -220,7 +220,7 @@ fn test_expect_one_many() { #[test] fn test_expect_one_one() { - assert_eq!(1, SmallVector::one(1).expect_one("")); - assert_eq!(1, SmallVector::many(vec!(1)).expect_one("")); + assert_eq!(1i, SmallVector::one(1i).expect_one("")); + assert_eq!(1i, SmallVector::many(vec!(1i)).expect_one("")); } } diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index 1a7063c4951..139f1113aaf 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -123,7 +123,13 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) 'c' => if stack.len() > 0 { match stack.pop().unwrap() { // if c is 0, use 0200 (128) for ncurses compatibility - Number(c) => output.push(if c == 0 { 128 } else { c } as u8), + Number(c) => { + output.push(if c == 0 { + 128u8 + } else { + c as u8 + }) + } _ => return Err("a non-char was used with %c".to_string()) } } else { return Err("stack is empty".to_string()) }, diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index 916342b6743..71fdea9b9ec 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -186,7 +186,7 @@ macro_rules! try( ($e:expr) => ( let magic = try!(file.read_le_u16()); if magic != 0x011A { return Err(format!("invalid magic number: expected {:x} but found {:x}", - 0x011A, magic as uint)); + 0x011Au, magic as uint)); } let names_bytes = try!(file.read_le_i16()) as int; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 4df8cfdd490..34e9dce3960 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -658,11 +658,11 @@ pub fn write_failures(&mut self) -> io::IoResult<()> { } pub fn write_metric_diff(&mut self, diff: &MetricDiff) -> io::IoResult<()> { - let mut noise = 0; - let mut improved = 0; - let mut regressed = 0; - let mut added = 0; - let mut removed = 0; + let mut noise = 0u; + let mut improved = 0u; + let mut regressed = 0u; + let mut added = 0u; + let mut removed = 0u; for (k, v) in diff.iter() { match *v { diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index b0562c39dc2..8db9a4f53aa 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -1034,21 +1034,21 @@ fn t(s: &Summary, expected: String) { assert_eq!(out, expected); } - t(&Summary::new([-2.0, -1.0]), + t(&Summary::new([-2.0f64, -1.0f64]), "-2 |[------******#*****---]| -1".to_string()); - t(&Summary::new([0.0, 2.0]), + t(&Summary::new([0.0f64, 2.0f64]), "0 |[-------*****#*******---]| 2".to_string()); - t(&Summary::new([-2.0, 0.0]), + t(&Summary::new([-2.0f64, 0.0f64]), "-2 |[------******#******---]| 0".to_string()); } #[test] fn test_sum_f64s() { - assert_eq!([0.5, 3.2321, 1.5678].sum(), 5.2999); + assert_eq!([0.5f64, 3.2321f64, 1.5678f64].sum(), 5.2999); } #[test] fn test_sum_f64_between_ints_that_sum_to_0() { - assert_eq!([1e30, 1.2, -1e30].sum(), 1.2); + assert_eq!([1e30f64, 1.2f64, -1e30f64].sum(), 1.2); } } @@ -1060,12 +1060,12 @@ mod bench { #[bench] pub fn sum_three_items(b: &mut Bencher) { b.iter(|| { - [1e20, 1.5, -1e20].sum(); + [1e20f64, 1.5f64, -1e20f64].sum(); }) } #[bench] pub fn sum_many_f64(b: &mut Bencher) { - let nums = [-1e30, 1e60, 1e30, 1.0, -1e60]; + let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60]; let v = Vec::from_fn(500, |i| nums[i%5]); b.iter(|| { diff --git a/src/test/auxiliary/issue-11224.rs b/src/test/auxiliary/issue-11224.rs index 560844332a1..d66cfe9bf63 100644 --- a/src/test/auxiliary/issue-11224.rs +++ b/src/test/auxiliary/issue-11224.rs @@ -21,6 +21,6 @@ fn f() {} } pub fn foo() { - let a = &1 as &inner::Trait; + let a = &1i as &inner::Trait; a.f(); } diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index e17e21ae7f4..bc310e31711 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -24,9 +24,9 @@ use std::gc::{Gc, GC}; #[macro_export] -macro_rules! exported_macro (() => (2)) +macro_rules! exported_macro (() => (2i)) -macro_rules! unexported_macro (() => (3)) +macro_rules! unexported_macro (() => (3i)) #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index bf50736b7e6..0d1911af9e0 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -63,7 +63,7 @@ fn maybe_run_test(argv: &[String], name: String, test: ||) { } fn shift_push() { - let mut v1 = Vec::from_elem(30000, 1); + let mut v1 = Vec::from_elem(30000, 1i); let mut v2 = Vec::new(); while v1.len() > 0 { @@ -77,7 +77,7 @@ fn read_line() { let mut path = Path::new(env!("CFG_SRC_DIR")); path.push("src/test/bench/shootout-k-nucleotide.data"); - for _ in range(0, 3) { + for _ in range(0u, 3) { let mut reader = BufferedReader::new(File::open(&path).unwrap()); for _line in reader.lines() { } diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 816a7529212..6ec1d5395cf 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -101,7 +101,7 @@ fn main() { let mut pixels = [0f32, ..256*256]; let n2d = Noise2DContext::new(); - for _ in range(0, 100) { + for _ in range(0u, 100) { for y in range(0u, 256) { for x in range(0u, 256) { let v = n2d.get(x as f32 * 0.1, y as f32 * 0.1); diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 74b06b93076..822565ec127 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -94,7 +94,7 @@ fn main() { let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| { use std::num::pow; - let iterations = pow(2, (max_depth - depth + min_depth) as uint); + let iterations = pow(2i, (max_depth - depth + min_depth) as uint); Future::spawn(proc() { let mut chk = 0; for i in range(1, iterations + 1) { diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 28786f1e163..8095037662b 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -111,7 +111,7 @@ fn creature( to_rendezvous: Sender, to_rendezvous_log: Sender ) { - let mut creatures_met = 0; + let mut creatures_met = 0i32; let mut evil_clones_met = 0; let mut rendezvous = from_rendezvous.iter(); diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 99eb2e5484d..91686d00fc3 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -48,7 +48,7 @@ fn fannkuch(n: uint, i: uint) -> (int, int) { let mut perm = Vec::from_fn(n, |e| ((n + e - i) % n + 1) as i32); let mut tperm = perm.clone(); let mut count = Vec::from_elem(n, 0u); - let mut perm_count = 0; + let mut perm_count = 0i; let mut checksum = 0; for countdown in range(1, fact(n - 1) + 1).rev() { diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 87805c4d4bc..f32a46cd52a 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -136,7 +136,7 @@ fn mask(dy: int, dx: int, id: uint, p: &Vec<(int, int)>) -> Option { if x < 0 || x > 4 {return None;} let y = y + dy; if y < 0 || y > 9 {return None;} - m |= 1 << (y * 5 + x); + m |= 1 << (y * 5 + x) as uint; } Some(m) } @@ -146,16 +146,16 @@ fn mask(dy: int, dx: int, id: uint, p: &Vec<(int, int)>) -> Option { // (i/5, i%5). fn make_masks() -> Vec > > { let pieces = vec!( - vec!((0,0),(0,1),(0,2),(0,3),(1,3)), - vec!((0,0),(0,2),(0,3),(1,0),(1,1)), - vec!((0,0),(0,1),(0,2),(1,2),(2,1)), - vec!((0,0),(0,1),(0,2),(1,1),(2,1)), - vec!((0,0),(0,2),(1,0),(1,1),(2,1)), - vec!((0,0),(0,1),(0,2),(1,1),(1,2)), - vec!((0,0),(0,1),(1,1),(1,2),(2,1)), - vec!((0,0),(0,1),(0,2),(1,0),(1,2)), - vec!((0,0),(0,1),(0,2),(1,2),(1,3)), - vec!((0,0),(0,1),(0,2),(0,3),(1,2))); + vec!((0i,0i),(0,1),(0,2),(0,3),(1,3)), + vec!((0i,0i),(0,2),(0,3),(1,0),(1,1)), + vec!((0i,0i),(0,1),(0,2),(1,2),(2,1)), + vec!((0i,0i),(0,1),(0,2),(1,1),(2,1)), + vec!((0i,0i),(0,2),(1,0),(1,1),(2,1)), + vec!((0i,0i),(0,1),(0,2),(1,1),(1,2)), + vec!((0i,0i),(0,1),(1,1),(1,2),(2,1)), + vec!((0i,0i),(0,1),(0,2),(1,0),(1,2)), + vec!((0i,0i),(0,1),(0,2),(1,2),(1,3)), + vec!((0i,0i),(0,1),(0,2),(0,3),(1,2))); // To break the central symetry of the problem, every // transformation must be taken except for one piece (piece 3 @@ -165,7 +165,7 @@ fn make_masks() -> Vec > > { .map(|(id, p)| transform(p, id != 3)) .collect(); - range(0, 50).map(|yx| { + range(0i, 50).map(|yx| { transforms.iter().enumerate().map(|(id, t)| { t.iter().filter_map(|p| mask(yx / 5, yx % 5, id, p)).collect() }).collect() @@ -208,7 +208,7 @@ fn filter_masks(masks: &mut Vec>>) { // Gets the identifier of a mask. fn get_id(m: u64) -> u8 { for id in range(0u8, 10) { - if m & (1 << (id + 50)) != 0 {return id;} + if m & (1 << (id + 50) as uint) != 0 {return id;} } fail!("{:016x} does not have a valid identifier", m); } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 57a6d0e7c52..85f035b60cb 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -66,9 +66,9 @@ fn parse_opts(argv: Vec ) -> Config { } fn stress_task(id: int) { - let mut i = 0; + let mut i = 0i; loop { - let n = 15; + let n = 15i; assert_eq!(fib(n), fib(n)); i += 1; println!("{}: Completed {} iterations", id, i); @@ -108,7 +108,7 @@ fn main() { let num_trials = 10; for n in range(1, max + 1) { - for _ in range(0, num_trials) { + for _ in range(0u, num_trials) { let start = time::precise_time_ns(); let fibn = fib(n); let stop = time::precise_time_ns(); diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index d5f55458ec4..912c635bd44 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -102,10 +102,10 @@ fn main() { } else { FromStr::from_str(args[1].as_slice()).unwrap() }; - let u = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); - let v = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); - let tmp = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); - for _ in range(0, 10) { + let u = Arc::new(RWLock::new(Vec::from_elem(n, 1f64))); + let v = Arc::new(RWLock::new(Vec::from_elem(n, 1f64))); + let tmp = Arc::new(RWLock::new(Vec::from_elem(n, 1f64))); + for _ in range(0u8, 10) { mult_AtAv(u.clone(), v.clone(), tmp.clone()); mult_AtAv(v.clone(), u.clone(), tmp.clone()); } diff --git a/src/test/bench/silly-test-spawn.rs b/src/test/bench/silly-test-spawn.rs index a68b36964c1..fbd35c57adc 100644 --- a/src/test/bench/silly-test-spawn.rs +++ b/src/test/bench/silly-test-spawn.rs @@ -22,7 +22,7 @@ fn start(argc: int, argv: **u8) -> int { } fn main() { - for _ in range(1, 100_000) { + for _ in range(1u32, 100_000) { spawn(proc() {}) } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index af51157bba5..4a81deaf529 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -181,7 +181,7 @@ fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) { impl Colors { fn new(start_color: u8) -> Colors { // Sets bits 9..start_color - let tails = !0u16 << start_color; + let tails = !0u16 << start_color as uint; return Colors(HEADS & tails); } @@ -198,7 +198,7 @@ fn next(&self) -> u8 { fn remove(&mut self, color: u8) { if color != 0u8 { let Colors(val) = *self; - let mask = !(1u16 << color); + let mask = !(1u16 << color as uint); *self = Colors(val & mask); } } diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 19d3e84520d..5d58774f1d7 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -22,7 +22,7 @@ fn fn_id(f: extern fn()) -> extern fn() { return f } } fn main() { - let i = 8; + let i = 8i; let f = coerce(|| println!("{:?}", i) ); f(); } diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 831c4d3e824..616320c168b 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -40,7 +40,7 @@ fn block_overarching_alias_mut() { let mut v = box 3; let mut x = &mut v; - for _ in range(0, 3) { + for _ in range(0i, 3) { borrow(v); //~ ERROR cannot borrow } *x = box 5; diff --git a/src/test/compile-fail/borrowck-lend-flow-match.rs b/src/test/compile-fail/borrowck-lend-flow-match.rs index 6b875ff268d..7a494b5959a 100644 --- a/src/test/compile-fail/borrowck-lend-flow-match.rs +++ b/src/test/compile-fail/borrowck-lend-flow-match.rs @@ -22,10 +22,10 @@ fn separate_arms() { None => { // It is ok to reassign x here, because there is in // fact no outstanding loan of x! - x = Some(0); + x = Some(0i); } Some(ref _i) => { - x = Some(1); //~ ERROR cannot assign + x = Some(1i); //~ ERROR cannot assign } } x.clone(); // just to prevent liveness warnings diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index d262bcee983..b6ecb50fac8 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -15,7 +15,7 @@ fn borrow(v: &int, f: |x: &int|) { } fn box_imm() { - let v = box 3; + let v = box 3i; let _w = &v; task::spawn(proc() { println!("v={}", *v); @@ -24,7 +24,7 @@ fn box_imm() { } fn box_imm_explicit() { - let v = box 3; + let v = box 3i; let _w = &v; task::spawn(proc() { println!("v={}", *v); diff --git a/src/test/compile-fail/borrowck-preserve-cond-box.rs b/src/test/compile-fail/borrowck-preserve-cond-box.rs index e1641f54a6c..e8ff69ed641 100644 --- a/src/test/compile-fail/borrowck-preserve-cond-box.rs +++ b/src/test/compile-fail/borrowck-preserve-cond-box.rs @@ -15,8 +15,8 @@ use std::gc::GC; fn testfn(cond: bool) { - let mut x = box(GC) 3; - let mut y = box(GC) 4; + let mut x = box(GC) 3i; + let mut y = box(GC) 4i; // borrow x and y let r_x = &*x; @@ -32,13 +32,13 @@ fn testfn(cond: bool) { println!("*r = {}, exp = {}", *r, exp); assert_eq!(*r, exp); - x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed + x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed + y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed println!("*r = {}, exp = {}", *r, exp); assert_eq!(*r, exp); - assert_eq!(x, box(GC) 5); - assert_eq!(y, box(GC) 6); + assert_eq!(x, box(GC) 5i); + assert_eq!(y, box(GC) 6i); } pub fn main() { diff --git a/src/test/compile-fail/borrowck-while-break.rs b/src/test/compile-fail/borrowck-while-break.rs index 8cdf1da5c93..15a70b2444d 100644 --- a/src/test/compile-fail/borrowck-while-break.rs +++ b/src/test/compile-fail/borrowck-while-break.rs @@ -11,7 +11,7 @@ fn test(cond: bool) { let v; while cond { - v = 3; + v = 3i; break; } println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` diff --git a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs b/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs deleted file mode 100644 index ce58b260f61..00000000000 --- a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let foo = ['h' as u8, 'i' as u8, 0 as u8]; - let bar = &foo as *u8; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index 671bf45c933..27aa43638f4 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -25,17 +25,17 @@ fn main() { // if n > m, it's a type mismatch error. // n < m - let &x = &(&1 as &T); - let &x = &&(&1 as &T); - let &&x = &&(&1 as &T); + let &x = &(&1i as &T); + let &x = &&(&1i as &T); + let &&x = &&(&1i as &T); // n == m - let &x = &1 as &T; //~ ERROR cannot be dereferenced - let &&x = &(&1 as &T); //~ ERROR cannot be dereferenced - let box x = box 1 as Box; //~ ERROR cannot be dereferenced + let &x = &1i as &T; //~ ERROR cannot be dereferenced + let &&x = &(&1i as &T); //~ ERROR cannot be dereferenced + let box x = box 1i as Box; //~ ERROR cannot be dereferenced // n > m - let &&x = &1 as &T; //~ ERROR found an `&`-pointer pattern - let &&&x = &(&1 as &T); //~ ERROR found an `&`-pointer pattern - let box box x = box 1 as Box; //~ ERROR found a box pattern + let &&x = &1i as &T; //~ ERROR found an `&`-pointer pattern + let &&&x = &(&1i as &T); //~ ERROR found an `&`-pointer pattern + let box box x = box 1i as Box; //~ ERROR found a box pattern } diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 08ff575f63b..eadd16348b2 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -15,6 +15,6 @@ fn f<'r, T>(v: &'r T) -> ||: 'r -> T { } fn main() { - let v = &5; + let v = &5i; println!("{}", f(v)()); } diff --git a/src/test/compile-fail/issue-4517.rs b/src/test/compile-fail/issue-4517.rs index b280365a7ba..b90a7f233b6 100644 --- a/src/test/compile-fail/issue-4517.rs +++ b/src/test/compile-fail/issue-4517.rs @@ -11,7 +11,7 @@ fn bar(int_param: int) {} fn main() { - let foo: [u8, ..4] = [1u8, ..4u8]; + let foo: [u8, ..4] = [1u8, ..4u]; bar(foo); //~^ ERROR mismatched types: expected `int` but found `[u8, .. 4]` // (expected int but found vector) diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 6921acde45e..50704a1afbf 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -24,7 +24,7 @@ fn main() { // ~Repeat<&'blk int> where blk is the lifetime of the block below. let y = { - let tmp0 = 3; + let tmp0 = 3i; let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough repeater(tmp1) }; diff --git a/src/test/compile-fail/lint-dead-code-3.rs b/src/test/compile-fail/lint-dead-code-3.rs index 95c1d131b7b..b0d517d18f7 100644 --- a/src/test/compile-fail/lint-dead-code-3.rs +++ b/src/test/compile-fail/lint-dead-code-3.rs @@ -80,6 +80,6 @@ fn f() {} } pub fn foo() { - let a = &1 as &inner::Trait; + let a = &1i as &inner::Trait; a.f(); } diff --git a/src/test/compile-fail/liveness-bad-bang-2.rs b/src/test/compile-fail/liveness-bad-bang-2.rs index 24a02821ee2..f5ad5e6af0c 100644 --- a/src/test/compile-fail/liveness-bad-bang-2.rs +++ b/src/test/compile-fail/liveness-bad-bang-2.rs @@ -11,6 +11,6 @@ // Tests that a function with a ! annotation always actually fails // error-pattern: some control paths may return -fn bad_bang(i: uint) -> ! { println!("{}", 3); } +fn bad_bang(i: uint) -> ! { println!("{}", 3i); } fn main() { bad_bang(5u); } diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index 4b578765f32..0b8e65fee08 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -11,7 +11,7 @@ extern crate debug; fn main() { - let x = box 5; + let x = box 5i; let y = x; println!("{:?}", *x); //~ ERROR use of partially moved value: `*x` y.clone(); diff --git a/src/test/compile-fail/method-missing-call.rs b/src/test/compile-fail/method-missing-call.rs index 3cde24892af..1c8b7fbf85c 100644 --- a/src/test/compile-fail/method-missing-call.rs +++ b/src/test/compile-fail/method-missing-call.rs @@ -33,7 +33,7 @@ fn main() { //~^ NOTE maybe a missing `()` to call it? If not, try an anonymous // Ensure the span is useful - let ys = &[1,2,3,4,5,6,7]; + let ys = &[1i,2,3,4,5,6,7]; let a = ys.iter() .map(|x| x) .filter(|&&x| x == 1) diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index 80aa0392918..ec218768a98 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -14,7 +14,7 @@ use std::task; fn main() { - let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + let v = vec!(1i, 2, 3, 4, 5, 6, 7, 8, 9, 10); let arc_v = Arc::new(v); task::spawn(proc() { diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 8f488747bb9..b8009031883 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -12,7 +12,7 @@ use std::task; fn main() { - let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + let v = vec!(1i, 2, 3, 4, 5, 6, 7, 8, 9, 10); let arc_v = Arc::new(v); task::spawn(proc() { diff --git a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs index 2727db9d042..41ea0c88e07 100644 --- a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs @@ -11,7 +11,7 @@ // Check that non constant exprs fail for vector repeat syntax fn main() { - fn bar(n: int) { + fn bar(n: uint) { let _x = [0, ..n]; //~ ERROR expected constant integer for repeat count but found variable } } diff --git a/src/test/compile-fail/regions-appearance-constraint.rs b/src/test/compile-fail/regions-appearance-constraint.rs index be4bdeedff4..842fe3fde41 100644 --- a/src/test/compile-fail/regions-appearance-constraint.rs +++ b/src/test/compile-fail/regions-appearance-constraint.rs @@ -15,23 +15,23 @@ use std::gc::GC; fn testfn(cond: bool) { - let mut x = box(GC) 3; - let mut y = box(GC) 4; + let mut x = box(GC) 3i; + let mut y = box(GC) 4i; let mut a = &*x; - let mut exp = 3; + let mut exp = 3i; if cond { a = &*y; exp = 4; } - x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed + x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed + y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed assert_eq!(*a, exp); - assert_eq!(x, box(GC) 5); - assert_eq!(y, box(GC) 6); + assert_eq!(x, box(GC) 5i); + assert_eq!(y, box(GC) 6i); } pub fn main() {} diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 285e11fa9a2..cef3b525997 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -11,7 +11,7 @@ fn wants_static_fn(_x: ||: 'static) {} fn main() { - let i = 3; + let i = 3i; wants_static_fn(|| { //~ ERROR cannot infer println!("i={}", i); }) diff --git a/src/test/compile-fail/regions-var-type-out-of-scope.rs b/src/test/compile-fail/regions-var-type-out-of-scope.rs index 8955a26de0b..a954b16699f 100644 --- a/src/test/compile-fail/regions-var-type-out-of-scope.rs +++ b/src/test/compile-fail/regions-var-type-out-of-scope.rs @@ -14,8 +14,8 @@ fn foo(cond: bool) { let mut x; if cond { - x = &3; //~ ERROR borrowed value does not live long enough - assert_eq!(*x, 3); + x = &3i; //~ ERROR borrowed value does not live long enough + assert_eq!(*x, 3i); } } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index 5e0340ce4f5..3dce0178597 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -16,5 +16,5 @@ impl bar for uint { fn dup(&self) -> uint { *self } fn blah(&self) {} } fn main() { 10i.dup::(); //~ ERROR does not take type parameters 10i.blah::(); //~ ERROR incorrect number of type parameters - (box 10 as Box).dup(); //~ ERROR contains a self-type + (box 10i as Box).dup(); //~ ERROR contains a self-type } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index f90937c34a6..94383d9724c 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -19,6 +19,6 @@ fn foo(x: Box) -> Box { x } fn main() { let x: Box; - box() 1 as Box; + box() 1i as Box; } diff --git a/src/test/run-fail/assert-eq-macro-fail.rs b/src/test/run-fail/assert-eq-macro-fail.rs index fd6d69efb4f..69ed025070b 100644 --- a/src/test/run-fail/assert-eq-macro-fail.rs +++ b/src/test/run-fail/assert-eq-macro-fail.rs @@ -11,5 +11,5 @@ // error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14`, right: `15`) fn main() { - assert_eq!(14,15); + assert_eq!(14i,15i); } diff --git a/src/test/run-fail/assert-macro-fmt.rs b/src/test/run-fail/assert-macro-fmt.rs index 53a37c5d684..72222ce4362 100644 --- a/src/test/run-fail/assert-macro-fmt.rs +++ b/src/test/run-fail/assert-macro-fmt.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-assert-fmt 42 rust' fn main() { - assert!(false, "test-assert-fmt {} {}", 42, "rust"); + assert!(false, "test-assert-fmt {} {}", 42i, "rust"); } diff --git a/src/test/run-fail/fail-macro-any.rs b/src/test/run-fail/fail-macro-any.rs index c56eabbb3b4..528f18dde0d 100644 --- a/src/test/run-fail/fail-macro-any.rs +++ b/src/test/run-fail/fail-macro-any.rs @@ -12,5 +12,5 @@ fn main() { - fail!(box 413 as Box<::std::any::Any+Send>); + fail!(box 413i as Box<::std::any::Any+Send>); } diff --git a/src/test/run-fail/fail-macro-fmt.rs b/src/test/run-fail/fail-macro-fmt.rs index e97d2dbe985..b3984c210b5 100644 --- a/src/test/run-fail/fail-macro-fmt.rs +++ b/src/test/run-fail/fail-macro-fmt.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-fail-fmt 42 rust' fn main() { - fail!("test-fail-fmt {} {}", 42, "rust"); + fail!("test-fail-fmt {} {}", 42i, "rust"); } diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index b513757a4c8..22ab9d0bbae 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -21,7 +21,7 @@ fn failfn() { } fn main() { - let y = box 0; + let y = box 0i; let x: Gc = box(GC) (proc() { println!("{:?}", y.clone()); }); diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs index 086c4012087..1eae3f49f27 100644 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ b/src/test/run-fail/unwind-box-unique-unique.rs @@ -21,7 +21,7 @@ fn failfn() { } fn main() { - let x = box(GC) box box 0; + let x = box(GC) box box 0i; failfn(); println!("{:?}", x); } diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs index 4add29bc873..be4c929a2f2 100644 --- a/src/test/run-fail/unwind-box-unique.rs +++ b/src/test/run-fail/unwind-box-unique.rs @@ -21,7 +21,7 @@ fn failfn() { } fn main() { - let x = box(GC) box 0; + let x = box(GC) box 0i; failfn(); println!("{:?}", x); } diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs index f18e55b305e..acf87b19c76 100644 --- a/src/test/run-fail/unwind-box-vec.rs +++ b/src/test/run-fail/unwind-box-vec.rs @@ -21,7 +21,7 @@ fn failfn() { } fn main() { - let x = box(GC) vec!(0, 1, 2, 3, 4, 5); + let x = box(GC) vec!(0i, 1, 2, 3, 4, 5); failfn(); println!("{:?}", x); } diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index 3711503ee2b..314949cc593 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -22,7 +22,7 @@ fn random_char() -> char { let mut rng = task_rng(); // a subset of the XID_start unicode table (ensuring that the // compiler doesn't fail with an "unrecognised token" error) - let (lo, hi): (u32, u32) = match rng.gen_range(1, 4 + 1) { + let (lo, hi): (u32, u32) = match rng.gen_range(1u32, 4u32 + 1) { 1 => (0x41, 0x5a), 2 => (0xf8, 0x1ba), 3 => (0x1401, 0x166c), @@ -43,11 +43,11 @@ fn main() { .write_str("mod unicode_input_multiple_files_chars;"); } - for _ in range(0, 100) { + for _ in range(0u, 100) { { let randoms = tmpdir.join("unicode_input_multiple_files_chars.rs"); let mut w = File::create(&randoms).unwrap(); - for _ in range(0, 30) { + for _ in range(0u, 30) { let _ = w.write_char(random_char()); } } diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index f957fbae65c..903ca69f247 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -21,7 +21,7 @@ fn random_char() -> char { let mut rng = task_rng(); // a subset of the XID_start unicode table (ensuring that the // compiler doesn't fail with an "unrecognised token" error) - let (lo, hi): (u32, u32) = match rng.gen_range(1, 4 + 1) { + let (lo, hi): (u32, u32) = match rng.gen_range(1u32, 4u32 + 1) { 1 => (0x41, 0x5a), 2 => (0xf8, 0x1ba), 3 => (0x1401, 0x166c), @@ -37,7 +37,7 @@ fn main() { let tmpdir = Path::new(args.get(2).as_slice()); let main_file = tmpdir.join("span_main.rs"); - for _ in range(0, 100) { + for _ in range(0u, 100) { let n = task_rng().gen_range(3u, 20); { diff --git a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs b/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs index 496b0111363..820606179bc 100644 --- a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs +++ b/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs @@ -17,7 +17,7 @@ pub fn main() { let a = hexfloat!("0x1.999999999999ap-4"); - assert_eq!(a, 0.1); + assert_eq!(a, 0.1f64); let b = hexfloat!("-0x1.fffp-4", f32); assert_eq!(b, -0.12498474_f32); let c = hexfloat!("0x.12345p5", f64); diff --git a/src/test/run-pass/arith-1.rs b/src/test/run-pass/arith-1.rs index e834aa5aa09..1e043d77fa8 100644 --- a/src/test/run-pass/arith-1.rs +++ b/src/test/run-pass/arith-1.rs @@ -22,7 +22,7 @@ pub fn main() { assert_eq!(i32_a * i32_a * i32_a, 1000); assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000); assert_eq!(i32_a * i32_a / i32_a * i32_a, 100); - assert_eq!(i32_a * (i32_a - 1) << 2 + i32_a, 368640); + assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as uint), 368640); let i32_b: int = 0x10101010; assert_eq!(i32_b + 1 - 1, i32_b); assert_eq!(i32_b << 1, i32_b << 1); diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index debe4d8ea53..63d9c6063b6 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -16,7 +16,7 @@ struct Point { x : int } pub fn main() { - assert_eq!(14,14); + assert_eq!(14i,14i); assert_eq!("abc".to_string(),"abc".to_string()); assert_eq!(box Point{x:34},box Point{x:34}); assert_eq!(&Point{x:34},&Point{x:34}); diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index 51af6444e9c..f1fe1e94587 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -17,5 +17,5 @@ struct Triple { x: int, y: int, z: int } pub fn main() { println!("{:?}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x); - println!("{:?}", f(5, 6).a); + println!("{:?}", f(5i, 6i).a); } diff --git a/src/test/run-pass/auto-loop.rs b/src/test/run-pass/auto-loop.rs index e5f4d078749..88884dfeb50 100644 --- a/src/test/run-pass/auto-loop.rs +++ b/src/test/run-pass/auto-loop.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut sum = 0; + let mut sum = 0i; let xs = vec!(1, 2, 3, 4, 5); for x in xs.iter() { sum += *x; diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index 652f21c2ae3..fd3ede07e21 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -20,7 +20,7 @@ fn push_val(&mut self, t: T) { } pub fn main() { - let mut v = vec!(1); + let mut v = vec!(1i); v.push_val(2); v.push_val(3); assert_eq!(v, vec!(1, 2, 3)); diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 894c54218b4..616b247bbb7 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -75,7 +75,7 @@ fn runtest(me: &str) { assert!(!out.status.success()); let s = str::from_utf8(out.error.as_slice()).unwrap(); let mut i = 0; - for _ in range(0, 2) { + for _ in range(0i, 2) { i += s.slice_from(i + 10).find_str("stack backtrace").unwrap() + 10; } assert!(s.slice_from(i + 10).find_str("stack backtrace").is_none(), diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index 3b2618c060d..c21ea343b16 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -16,5 +16,5 @@ pub fn main() { assert_eq!(-2147483648i32 - 1i32, 2147483647i32); assert_eq!(-9223372036854775808i64 - 1i64, 9223372036854775807i64); - assert_eq!(-9223372036854775808 - 1, 9223372036854775807); + assert_eq!(-9223372036854775808i - 1, 9223372036854775807); } diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index 78edf3e112e..9c6e6ab60ab 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -11,6 +11,6 @@ // Check that issue #954 stays fixed pub fn main() { - match -1 { -1 => {}, _ => fail!("wat") } - assert_eq!(1-1, 0); + match -1i { -1 => {}, _ => fail!("wat") } + assert_eq!(1i-1, 0i); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 9c1b64004a2..ff4dcc18bb4 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -47,14 +47,14 @@ fn test_bool() { } fn test_box() { - assert_eq!(box(GC) 10, box(GC) 10); + assert_eq!(box(GC) 10i, box(GC) 10i); } fn test_ptr() { unsafe { - let p1: *u8 = ::std::mem::transmute(0); - let p2: *u8 = ::std::mem::transmute(0); - let p3: *u8 = ::std::mem::transmute(1); + let p1: *u8 = ::std::mem::transmute(0u); + let p2: *u8 = ::std::mem::transmute(0u); + let p3: *u8 = ::std::mem::transmute(1u); assert_eq!(p1, p2); assert!(p1 != p3); diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index 38384c7789c..8c2dba243c8 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -19,5 +19,5 @@ fn bitv_test() { } pub fn main() { - for _ in range(0, 10000) { bitv_test(); } + for _ in range(0i, 10000) { bitv_test(); } } diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index d359f488ca5..305739a56d7 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -30,12 +30,12 @@ fn general() { println!("{}", b); assert_eq!(b, 1); assert_eq!(a, 2); - assert_eq!(!0xf0 & 0xff, 0xf); - assert_eq!(0xf0 | 0xf, 0xff); - assert_eq!(0xf << 4, 0xf0); - assert_eq!(0xf0 >> 4, 0xf); - assert_eq!(-16 >> 2, -4); - assert_eq!(0b1010_1010 | 0b0101_0101, 0xff); + assert_eq!(!0xf0i & 0xff, 0xf); + assert_eq!(0xf0i | 0xf, 0xff); + assert_eq!(0xfi << 4, 0xf0); + assert_eq!(0xf0i >> 4, 0xf); + assert_eq!(-16i >> 2, -4); + assert_eq!(0b1010_1010i | 0b0101_0101, 0xff); } pub fn main() { diff --git a/src/test/run-pass/block-expr-precedence.rs b/src/test/run-pass/block-expr-precedence.rs index ace372dd2d3..31d0d52f8b4 100644 --- a/src/test/run-pass/block-expr-precedence.rs +++ b/src/test/run-pass/block-expr-precedence.rs @@ -58,9 +58,9 @@ pub fn main() { let num = 12; - assert_eq!(if (true) { 12 } else { 12 } - num, 0); - assert_eq!(12 - if (true) { 12 } else { 12 }, 0); - if (true) { 12; } {-num}; - if (true) { 12; }; {-num}; - if (true) { 12; };;; -num; + assert_eq!(if (true) { 12i } else { 12 } - num, 0); + assert_eq!(12i - if (true) { 12i } else { 12 }, 0); + if (true) { 12i; } {-num}; + if (true) { 12i; }; {-num}; + if (true) { 12i; };;; -num; } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 4f0cf855dd1..dee013a9140 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -13,8 +13,8 @@ fn iter_vec(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { - let v = vec!(1, 2, 3, 4, 5, 6, 7); - let mut odds = 0; + let v = vec!(1i, 2, 3, 4, 5, 6, 7); + let mut odds = 0i; iter_vec(v, |i| { if *i % 2 == 1 { odds += 1; diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 8d28022bc1d..82b162ba4bc 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -13,7 +13,7 @@ fn iter_vec(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { - let v = vec!(1, 2, 3, 4, 5); + let v = vec!(1i, 2, 3, 4, 5); let mut sum = 0; iter_vec(v.clone(), |i| { iter_vec(v.clone(), |j| { diff --git a/src/test/run-pass/borrowck-fixed-length-vecs.rs b/src/test/run-pass/borrowck-fixed-length-vecs.rs index ee561fdb0be..71c8936570a 100644 --- a/src/test/run-pass/borrowck-fixed-length-vecs.rs +++ b/src/test/run-pass/borrowck-fixed-length-vecs.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let x = [22]; + let x = [22i]; let y = &x[0]; assert_eq!(*y, 22); } diff --git a/src/test/run-pass/borrowck-freeze-frozen-mut.rs b/src/test/run-pass/borrowck-freeze-frozen-mut.rs index 77e1a258dec..4044e9f06af 100644 --- a/src/test/run-pass/borrowck-freeze-frozen-mut.rs +++ b/src/test/run-pass/borrowck-freeze-frozen-mut.rs @@ -19,7 +19,7 @@ fn get<'a, T>(ms: &'a MutSlice<'a, T>, index: uint) -> &'a T { } pub fn main() { - let mut data = [1, 2, 3]; + let mut data = [1i, 2, 3]; { let slice = MutSlice { data: data }; slice.data[0] += 4; diff --git a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs index 4ccbf6b5b0f..6136bc90fd4 100644 --- a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs +++ b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs @@ -14,7 +14,7 @@ pub fn main() { None => { // It is ok to reassign x here, because there is in // fact no outstanding loan of x! - x = Some(0); + x = Some(0i); } Some(_) => { } } diff --git a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs index b5600cd7db2..e50317f71e8 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs @@ -11,7 +11,7 @@ #![feature(managed_boxes)] pub fn main() { - let (&x, &y) = (&3, &'a'); + let (&x, &y) = (&3i, &'a'); assert_eq!(x, 3); assert_eq!(y, 'a'); } diff --git a/src/test/run-pass/borrowed-ptr-pattern.rs b/src/test/run-pass/borrowed-ptr-pattern.rs index 7ccb40c8e7b..3636d4d769d 100644 --- a/src/test/run-pass/borrowed-ptr-pattern.rs +++ b/src/test/run-pass/borrowed-ptr-pattern.rs @@ -15,6 +15,6 @@ fn foo(x: &T) -> T{ } pub fn main() { - assert_eq!(foo(&3), 3); + assert_eq!(foo(&3i), 3i); assert_eq!(foo(&'a'), 'a'); } diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs index facd390620f..2ba2823eb91 100644 --- a/src/test/run-pass/box-compare.rs +++ b/src/test/run-pass/box-compare.rs @@ -13,7 +13,7 @@ use std::gc::GC; pub fn main() { - assert!((box(GC) 1 < box(GC) 3)); + assert!((box(GC) 1i < box(GC) 3i)); assert!((box(GC) box(GC) "hello ".to_string() > box(GC) box(GC) "hello".to_string())); assert!((box(GC) box(GC) box(GC) "hello".to_string() != diff --git a/src/test/run-pass/box-pattern.rs b/src/test/run-pass/box-pattern.rs index 101d7c19459..21d1d235901 100644 --- a/src/test/run-pass/box-pattern.rs +++ b/src/test/run-pass/box-pattern.rs @@ -9,8 +9,8 @@ // except according to those terms. fn main() { - let box x = box 3; - match box 3 { + let box x = box 3i; + match box 3i { box y => { assert!(x == y); println!("{} {}", x, y); diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index bcfb8f6f914..89745bd167c 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -9,12 +9,12 @@ // except according to those terms. pub fn main() { - let mut i = 0; + let mut i = 0i; while i < 20 { i += 1; if i == 10 { break; } } assert_eq!(i, 10); loop { i += 1; if i == 20 { break; } } assert_eq!(i, 20); - let xs = [1, 2, 3, 4, 5, 6]; + let xs = [1i, 2, 3, 4, 5, 6]; for x in xs.iter() { if *x == 3 { break; } assert!((*x <= 3)); } @@ -25,7 +25,7 @@ pub fn main() { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); if i >= 10 { break; } } - let ys = vec!(1, 2, 3, 4, 5, 6); + let ys = vec!(1i, 2, 3, 4, 5, 6); for x in ys.iter() { if *x % 2 == 0 { continue; } assert!((*x % 2 != 0)); diff --git a/src/test/run-pass/bug-7183-generics.rs b/src/test/run-pass/bug-7183-generics.rs index 239247cdd18..8c4d10a2d59 100644 --- a/src/test/run-pass/bug-7183-generics.rs +++ b/src/test/run-pass/bug-7183-generics.rs @@ -34,11 +34,11 @@ fn say(&self, s:&str) -> String { pub fn main() { - assert_eq!(3.hi(), "hello: 3".to_string()); - assert_eq!(Some(Some(3)).hi(), + assert_eq!(3i.hi(), "hello: 3".to_string()); + assert_eq!(Some(Some(3i)).hi(), "something!something!hello: 3".to_string()); assert_eq!(None::.hi(), "hello - none".to_string()); assert_eq!(Some(None::).hi(), "something!hello - none".to_string()); - assert_eq!(Some(3).hi(), "something!hello: 3".to_string()); + assert_eq!(Some(3i).hi(), "something!hello: 3".to_string()); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs index 92133bd7548..2abc58d8a49 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs @@ -26,6 +26,6 @@ fn foo(val: T, chan: Sender) { pub fn main() { let (tx, rx) = channel(); - foo(31337, tx); - assert!(rx.recv() == 31337); + foo(31337i, tx); + assert!(rx.recv() == 31337i); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index d52da212400..51238b0ee52 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -28,7 +28,7 @@ fn foo(val: T, chan: Sender) { } pub fn main() { - let (tx, rx) = channel(); - foo(X(31337), tx); - assert!(rx.recv() == X(31337)); + let (tx, rx): (Sender>, Receiver>) = channel(); + foo(X(31337i), tx); + assert!(rx.recv() == X(31337i)); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities.rs b/src/test/run-pass/builtin-superkinds-capabilities.rs index 33e9f57ba96..fb3e1b02728 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities.rs @@ -21,7 +21,7 @@ fn foo(val: T, chan: Sender) { } pub fn main() { - let (tx, rx) = channel(); - foo(31337, tx); - assert!(rx.recv() == 31337); + let (tx, rx): (Sender, Receiver) = channel(); + foo(31337i, tx); + assert!(rx.recv() == 31337i); } diff --git a/src/test/run-pass/byte-literals.rs b/src/test/run-pass/byte-literals.rs index 5317fdc391f..1e28c44206f 100644 --- a/src/test/run-pass/byte-literals.rs +++ b/src/test/run-pass/byte-literals.rs @@ -25,8 +25,6 @@ pub fn main() { assert_eq!(b'\xF0', 240u8); assert_eq!(FOO, 240u8); - assert_eq!([42, ..b'\t'].as_slice(), &[42, 42, 42, 42, 42, 42, 42, 42, 42]); - match 42 { b'*' => {}, _ => fail!() diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index 0519ba6662b..df03c93dad3 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -15,7 +15,7 @@ pub fn main() { //let bt0 = sys::rusti::frame_address(1u32); //println!("%?", bt0); - cci_iter_lib::iter([1, 2, 3], |i| { + cci_iter_lib::iter([1i, 2, 3], |i| { println!("{}", *i); //assert!(bt0 == sys::rusti::frame_address(2u32)); }) diff --git a/src/test/run-pass/closure-inference2.rs b/src/test/run-pass/closure-inference2.rs index fa16ea00145..6666b8e3cfa 100644 --- a/src/test/run-pass/closure-inference2.rs +++ b/src/test/run-pass/closure-inference2.rs @@ -12,6 +12,6 @@ pub fn main() { let f = {|i| i}; - assert_eq!(f(2), 2); - assert_eq!(f(5), 5); + assert_eq!(f(2i), 2i); + assert_eq!(f(5i), 5i); } diff --git a/src/test/run-pass/complex.rs b/src/test/run-pass/complex.rs index f8c8ac20d72..34292453ec4 100644 --- a/src/test/run-pass/complex.rs +++ b/src/test/run-pass/complex.rs @@ -35,8 +35,8 @@ fn foo(x: int) -> int { } pub fn main() { - let x: int = 2 + 2; + let x: int = 2i + 2; println!("{}", x); println!("hello, world"); - println!("{}", 10); + println!("{}", 10i); } diff --git a/src/test/run-pass/const-expr-in-vec-repeat.rs b/src/test/run-pass/const-expr-in-vec-repeat.rs index f10cef520ad..5dd9f829d0a 100644 --- a/src/test/run-pass/const-expr-in-vec-repeat.rs +++ b/src/test/run-pass/const-expr-in-vec-repeat.rs @@ -12,7 +12,7 @@ pub fn main() { - static FOO: int = 2; - let _v = [0, ..FOO*3*2/2]; + static FOO: uint = 2; + let _v = [0i, ..FOO*3*2/2]; } diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index 788c30562c1..2a15774fb17 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -12,11 +12,11 @@ static BAR: int = 3; pub fn main() { - let x: int = 3; + let x: int = 3i; let y = match x { - FOO => 1, - BAR => 2, - _ => 3 + FOO => 1i, + BAR => 2i, + _ => 3i }; assert_eq!(y, 2); } diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index f5079569606..753fada58ab 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -16,7 +16,7 @@ use std::gc::GC; pub fn main() { - let x = box(GC) Cell::new(5); - x.set(1000); + let x = box(GC) Cell::new(5i); + x.set(1000i); println!("{:?}", x.get()); } diff --git a/src/test/run-pass/deref-rc.rs b/src/test/run-pass/deref-rc.rs index fbb8a3a1720..03697875d56 100644 --- a/src/test/run-pass/deref-rc.rs +++ b/src/test/run-pass/deref-rc.rs @@ -11,6 +11,6 @@ use std::rc::Rc; fn main() { - let x = Rc::new([1, 2, 3, 4]); + let x = Rc::new([1i, 2, 3, 4]); assert!(*x == [1, 2, 3, 4]); } diff --git a/src/test/run-pass/deriving-cmp-generic-enum.rs b/src/test/run-pass/deriving-cmp-generic-enum.rs index 48e6cae706e..692a62f4ed0 100644 --- a/src/test/run-pass/deriving-cmp-generic-enum.rs +++ b/src/test/run-pass/deriving-cmp-generic-enum.rs @@ -17,10 +17,10 @@ enum E { pub fn main() { let e0 = E0; - let e11 = E1(1); - let e12 = E1(2); - let e21 = E2(1, 1); - let e22 = E2(1, 2); + let e11 = E1(1i); + let e12 = E1(2i); + let e21 = E2(1i, 1i); + let e22 = E2(1i, 2i); // in order for both PartialOrd and Ord let es = [e0, e11, e12, e21, e22]; diff --git a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs index 5958538d80e..2add2b6711f 100644 --- a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs +++ b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs @@ -18,7 +18,17 @@ enum ES { pub fn main() { - let (es11, es12, es21, es22) = (ES1 {x: 1}, ES1 {x: 2}, ES2 {x: 1, y: 1}, ES2 {x: 1, y: 2}); + let (es11, es12, es21, es22) = (ES1 { + x: 1i + }, ES1 { + x: 2i + }, ES2 { + x: 1i, + y: 1i + }, ES2 { + x: 1i, + y: 2i + }); // in order for both PartialOrd and Ord let ess = [es11, es12, es21, es22]; diff --git a/src/test/run-pass/deriving-cmp-generic-struct.rs b/src/test/run-pass/deriving-cmp-generic-struct.rs index 5a6daa6d520..2576cce6503 100644 --- a/src/test/run-pass/deriving-cmp-generic-struct.rs +++ b/src/test/run-pass/deriving-cmp-generic-struct.rs @@ -15,8 +15,8 @@ struct S { } pub fn main() { - let s1 = S {x: 1, y: 1}; - let s2 = S {x: 1, y: 2}; + let s1 = S {x: 1i, y: 1i}; + let s2 = S {x: 1i, y: 2i}; // in order for both PartialOrd and Ord let ss = [s1, s2]; diff --git a/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs b/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs index 875c33b9810..8ab529996e5 100644 --- a/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs +++ b/src/test/run-pass/deriving-cmp-generic-tuple-struct.rs @@ -13,8 +13,8 @@ pub fn main() { - let ts1 = TS(1, 1); - let ts2 = TS(1, 2); + let ts1 = TS(1i, 1i); + let ts2 = TS(1i, 2i); // in order for both PartialOrd and Ord let tss = [ts1, ts2]; diff --git a/src/test/run-pass/deriving-rand.rs b/src/test/run-pass/deriving-rand.rs index 4e9592950d3..f0f2f86a7c6 100644 --- a/src/test/run-pass/deriving-rand.rs +++ b/src/test/run-pass/deriving-rand.rs @@ -33,7 +33,7 @@ enum D { pub fn main() { // check there's no segfaults - for _ in range(0, 20) { + for _ in range(0i, 20) { rand::random::(); rand::random::(); rand::random::(); diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index 1af39da5202..a3151e0a8fa 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -17,8 +17,8 @@ struct Foo { } pub fn main() { - let a = Foo { x: 1, y: 2.0, z: 3 }; - let b = Foo { x: 1, y: 2.0, z: 3 }; + let a = Foo { x: 1, y: 2.0f64, z: 3 }; + let b = Foo { x: 1, y: 2.0f64, z: 3 }; assert_eq!(a, b); assert!(!(a != b)); assert!(a.eq(&b)); diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 89fee7358a1..70030c66ca2 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -19,5 +19,5 @@ fn foo_func>(x: B) -> Option { x.foo() } struct A { a: int } pub fn main() { - let _x: Option = foo_func(0); + let _x: Option = foo_func(0i); } diff --git a/src/test/run-pass/exponential-notation.rs b/src/test/run-pass/exponential-notation.rs index 7d79815f778..bb236638905 100644 --- a/src/test/run-pass/exponential-notation.rs +++ b/src/test/run-pass/exponential-notation.rs @@ -17,18 +17,18 @@ pub fn main() { // Basic usage - t!(to_str(1.2345678e-5, 10u, true, s::SignNeg, s::DigMax(6), s::ExpDec, false), + t!(to_str(1.2345678e-5f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpDec, false), "1.234568e-5") // Hexadecimal output - t!(to_str(7.281738281250e+01, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), + t!(to_str(7.281738281250e+01f64, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), "+1.2345p+6") - t!(to_str(-1.777768135071e-02, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), + t!(to_str(-1.777768135071e-02f64, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), "-1.2345p-6") // Some denormals - t!(to_str(4.9406564584124654e-324, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), + t!(to_str(4.9406564584124654e-324f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), "1p-1074") - t!(to_str(2.2250738585072009e-308, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), + t!(to_str(2.2250738585072009e-308f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), "1p-1022") } diff --git a/src/test/run-pass/expr-block.rs b/src/test/run-pass/expr-block.rs index ee1d955b0d3..7af9e790504 100644 --- a/src/test/run-pass/expr-block.rs +++ b/src/test/run-pass/expr-block.rs @@ -20,7 +20,7 @@ struct RS { v1: int, v2: int } fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert!((rs.v2 == 20)); } fn test_filled_with_stuff() { - let rs = { let mut a = 0; while a < 10 { a += 1; } a }; + let rs = { let mut a = 0i; while a < 10 { a += 1; } a }; assert_eq!(rs, 10); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index d1b5569f336..fc2912c184f 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -22,7 +22,7 @@ fn f() -> Vec { vec!(10, 11) } fn test_generic() { fn f(t: T) -> T { t } - assert_eq!(f(10), 10); + assert_eq!(f(10i), 10); } fn test_alt() { diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs index e1c6de0bf6b..ce101b0d23c 100644 --- a/src/test/run-pass/expr-if-box.rs +++ b/src/test/run-pass/expr-if-box.rs @@ -14,7 +14,7 @@ // Tests for if as expressions returning boxed types fn test_box() { - let rs = if true { box(GC) 100 } else { box(GC) 101 }; + let rs = if true { box(GC) 100i } else { box(GC) 101i }; assert_eq!(*rs, 100); } diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index f79b7198b50..023ba508ae5 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -11,13 +11,13 @@ fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert!((x == 10)); } fn test_else_fail() { - let x = if true { 10 } else { fail!() }; - assert_eq!(x, 10); + let x = if true { 10i } else { fail!() }; + assert_eq!(x, 10i); } fn test_elseif_fail() { - let x = if false { 0 } else if false { fail!() } else { 10 }; - assert_eq!(x, 10); + let x = if false { 0 } else if false { fail!() } else { 10i }; + assert_eq!(x, 10i); } pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } diff --git a/src/test/run-pass/expr-if-unique.rs b/src/test/run-pass/expr-if-unique.rs index aa96a93cdb3..b1fdf51d9b1 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -14,8 +14,8 @@ // Tests for if as expressions returning boxed types fn test_box() { - let rs = if true { box 100 } else { box 101 }; - assert_eq!(*rs, 100); + let rs = if true { box 100i } else { box 101i }; + assert_eq!(*rs, 100i); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-match-box.rs b/src/test/run-pass/expr-match-box.rs index 98218829d34..dc92df4d08e 100644 --- a/src/test/run-pass/expr-match-box.rs +++ b/src/test/run-pass/expr-match-box.rs @@ -14,8 +14,8 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { box(GC) 100 } _ => fail!("wat") }; - assert_eq!(*res, 100); + let res = match true { true => { box(GC) 100i } _ => fail!("wat") }; + assert_eq!(*res, 100i); } fn test_str() { diff --git a/src/test/run-pass/expr-match-fail.rs b/src/test/run-pass/expr-match-fail.rs index 1ef4e21c180..872701e33ee 100644 --- a/src/test/run-pass/expr-match-fail.rs +++ b/src/test/run-pass/expr-match-fail.rs @@ -15,8 +15,8 @@ fn test_simple() { } fn test_box() { - let r = match true { true => { vec!(10) } false => { fail!() } }; - assert_eq!(*r.get(0), 10); + let r = match true { true => { vec!(10i) } false => { fail!() } }; + assert_eq!(*r.get(0), 10i); } pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/expr-match-unique.rs b/src/test/run-pass/expr-match-unique.rs index ca6e8799eae..3ee0a232d19 100644 --- a/src/test/run-pass/expr-match-unique.rs +++ b/src/test/run-pass/expr-match-unique.rs @@ -11,8 +11,8 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { box 100 }, _ => fail!() }; - assert_eq!(*res, 100); + let res = match true { true => { box 100i }, _ => fail!() }; + assert_eq!(*res, 100i); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/fat-arrow-match.rs b/src/test/run-pass/fat-arrow-match.rs index e29cad9c2a3..a137aa5bd63 100644 --- a/src/test/run-pass/fat-arrow-match.rs +++ b/src/test/run-pass/fat-arrow-match.rs @@ -17,8 +17,8 @@ enum color { pub fn main() { println!("{}", match red { - red => { 1 } - green => { 2 } - blue => { 3 } + red => { 1i } + green => { 2i } + blue => { 3i } }); } diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index bbd7b9130e7..dc34cec7fa2 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - let arr = [1,2,3]; + let arr = [1i,2i,3i]; let arr2 = arr; - assert_eq!(arr[1], 2); - assert_eq!(arr2[2], 3); + assert_eq!(arr[1], 2i); + assert_eq!(arr2[2], 3i); } diff --git a/src/test/run-pass/float.rs b/src/test/run-pass/float.rs index 4cd7e7112a9..f2a41b4f09e 100644 --- a/src/test/run-pass/float.rs +++ b/src/test/run-pass/float.rs @@ -11,7 +11,7 @@ extern crate debug; pub fn main() { - let pi = 3.1415927; + let pi = 3.1415927f64; println!("{:?}", -pi * (pi + 2.0 / pi) - pi * 5.0); if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0 || pi > 1.0 { diff --git a/src/test/run-pass/float2.rs b/src/test/run-pass/float2.rs index 713d863029c..9c75979628f 100644 --- a/src/test/run-pass/float2.rs +++ b/src/test/run-pass/float2.rs @@ -11,17 +11,17 @@ pub fn main() { - let a = 1.5e6; - let b = 1.5E6; - let c = 1e6; - let d = 1E6; + let a = 1.5e6f64; + let b = 1.5E6f64; + let c = 1e6f64; + let d = 1E6f64; let e = 3.0f32; let f = 5.9f64; let g = 1e6f32; let h = 1.0e7f64; let i = 1.0E7f64; - let j = 3.1e+9; - let k = 3.2e-10; + let j = 3.1e+9f64; + let k = 3.2e-10f64; assert_eq!(a, b); assert!((c < b)); assert_eq!(c, d); diff --git a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs index d16a964ea79..4305ae95698 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs @@ -18,7 +18,7 @@ pub fn main() { let mut h = HashMap::new(); - let kvs = [(1, 10), (2, 20), (3, 30)]; + let kvs = [(1i, 10i), (2i, 20i), (3i, 30i)]; for &(k,v) in kvs.iter() { h.insert(k,v); } diff --git a/src/test/run-pass/foreach-external-iterators-hashmap.rs b/src/test/run-pass/foreach-external-iterators-hashmap.rs index 1878997de5a..ab20f9f9778 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap.rs @@ -14,12 +14,12 @@ pub fn main() { let mut h = HashMap::new(); - let kvs = [(1, 10), (2, 20), (3, 30)]; + let kvs = [(1i, 10i), (2i, 20i), (3i, 30i)]; for &(k,v) in kvs.iter() { h.insert(k,v); } - let mut x = 0; - let mut y = 0; + let mut x = 0i; + let mut y = 0i; for (&k,&v) in h.iter() { x += k; y += v; diff --git a/src/test/run-pass/foreach-external-iterators-loop.rs b/src/test/run-pass/foreach-external-iterators-loop.rs index 37576874312..c6c2d423927 100644 --- a/src/test/run-pass/foreach-external-iterators-loop.rs +++ b/src/test/run-pass/foreach-external-iterators-loop.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - let x = [1,..100]; - let mut y = 0; + let x = [1i,..100]; + let mut y = 0i; for (n,i) in x.iter().enumerate() { if n < 10 { continue; diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 0fd4ba3ec5f..f9d05458261 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -13,7 +13,7 @@ fn id(t: T) -> T { return t; } pub fn main() { - let expected = box 100; + let expected = box 100i; let actual = id::>(expected.clone()); println!("{:?}", *actual); assert_eq!(*expected, *actual); diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs index ef90eb2fa52..e7e189c0049 100644 --- a/src/test/run-pass/generic-fn-box.rs +++ b/src/test/run-pass/generic-fn-box.rs @@ -16,4 +16,4 @@ fn f(x: Gc) -> Gc { return x; } -pub fn main() { let x = f(box(GC) 3); println!("{:?}", *x); } +pub fn main() { let x = f(box(GC) 3i); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index d8f782d9773..14991ca3ba6 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -12,4 +12,4 @@ fn f(x: Box) -> Box { return x; } -pub fn main() { let x = f(box 3); println!("{:?}", *x); } +pub fn main() { let x = f(box 3i); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-static-methods.rs b/src/test/run-pass/generic-static-methods.rs index 2b7c860c2fa..032db16c617 100644 --- a/src/test/run-pass/generic-static-methods.rs +++ b/src/test/run-pass/generic-static-methods.rs @@ -24,5 +24,5 @@ fn map_(x: &Vec , f: |&T| -> U) -> Vec { } pub fn main() { - assert_eq!(vec_utils::map_(&vec!(1,2,3), |&x| x+1), vec!(2,3,4)); + assert_eq!(vec_utils::map_(&vec!(1i,2i,3i), |&x| x+1), vec!(2i,3i,4i)); } diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index d0ae17053ae..2f41cac6258 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -13,7 +13,7 @@ fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } pub fn main() { - println!("{:?}", get_third((1, 2, 3))); - assert_eq!(get_third((1, 2, 3)), 3); + println!("{:?}", get_third((1i, 2i, 3i))); + assert_eq!(get_third((1i, 2i, 3i)), 3); assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8); } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 8fa4af52856..450620767e3 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -11,11 +11,11 @@ struct Pair { x: int, y: int } pub fn main() { - let a = + let a: int = match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; assert_eq!(a, 2); - let b = + let b: int = match (Pair {x: 10, y: 20}) { x if x.x < 5 && x.y < 5 => { 1 } Pair {x: x, y: y} if x == 10 && y == 20 => { 2 } diff --git a/src/test/run-pass/hygienic-labels-in-let.rs b/src/test/run-pass/hygienic-labels-in-let.rs index ee90cfd3475..e6c1046d1fa 100644 --- a/src/test/run-pass/hygienic-labels-in-let.rs +++ b/src/test/run-pass/hygienic-labels-in-let.rs @@ -22,14 +22,14 @@ macro_rules! loop_x { macro_rules! run_once { ($e: expr) => { // ditto - 'x: for _ in range(0, 1) { $e } + 'x: for _ in range(0i, 1) { $e } } } pub fn main() { let mut i = 0i; - let j = { + let j: int = { 'x: loop { // this 'x should refer to the outer loop, lexically loop_x!(break 'x); @@ -39,8 +39,8 @@ pub fn main() { }; assert_eq!(j, 1i); - let k = { - 'x: for _ in range(0, 1) { + let k: int = { + 'x: for _ in range(0i, 1) { // ditto loop_x!(break 'x); i += 1; @@ -49,8 +49,8 @@ pub fn main() { }; assert_eq!(k, 1i); - let n = { - 'x: for _ in range(0, 1) { + let n: int = { + 'x: for _ in range(0i, 1) { // ditto run_once!(continue 'x); i += 1; diff --git a/src/test/run-pass/hygienic-labels.rs b/src/test/run-pass/hygienic-labels.rs index 35799a4b1a8..320441204df 100644 --- a/src/test/run-pass/hygienic-labels.rs +++ b/src/test/run-pass/hygienic-labels.rs @@ -20,12 +20,12 @@ macro_rules! loop_x { macro_rules! run_once { ($e: expr) => { // ditto - 'x: for _ in range(0, 1) { $e } + 'x: for _ in range(0i, 1) { $e } } } pub fn main() { - 'x: for _ in range(0, 1) { + 'x: for _ in range(0i, 1) { // this 'x should refer to the outer loop, lexically loop_x!(break 'x); fail!("break doesn't act hygienically inside for loop"); @@ -37,7 +37,7 @@ pub fn main() { fail!("break doesn't act hygienically inside infinite loop"); } - 'x: for _ in range(0, 1) { + 'x: for _ in range(0i, 1) { // ditto run_once!(continue 'x); fail!("continue doesn't act hygienically inside for loop"); diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 6638b80680e..4b678d78834 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -40,10 +40,10 @@ macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }) pub fn main() { // Make sure there's a poly formatter that takes anything - t!(format!("{:?}", 1), "1"); + t!(format!("{:?}", 1i), "1"); t!(format!("{:?}", A), "A"); t!(format!("{:?}", ()), "()"); - t!(format!("{:?}", box(GC) (box 1, "foo")), "box(GC) (box 1, \"foo\")"); + t!(format!("{:?}", box(GC) (box 1i, "foo")), "box(GC) (box 1, \"foo\")"); // Various edge cases without formats t!(format!(""), ""); @@ -61,8 +61,8 @@ pub fn main() { // At least exercise all the formats t!(format!("{:b}", true), "true"); t!(format!("{:c}", '☃'), "☃"); - t!(format!("{:d}", 10), "10"); - t!(format!("{:i}", 10), "10"); + t!(format!("{:d}", 10i), "10"); + t!(format!("{:i}", 10i), "10"); t!(format!("{:u}", 10u), "10"); t!(format!("{:o}", 10u), "12"); t!(format!("{:x}", 10u), "a"); @@ -74,12 +74,12 @@ pub fn main() { t!(format!("{:d}", A), "aloha"); t!(format!("{:d}", B), "adios"); t!(format!("foo {:s} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃"); - t!(format!("{1} {0}", 0, 1), "1 0"); - t!(format!("{foo} {bar}", foo=0, bar=1), "0 1"); - t!(format!("{foo} {1} {bar} {0}", 0, 1, foo=2, bar=3), "2 1 3 0"); + t!(format!("{1} {0}", 0i, 1i), "1 0"); + t!(format!("{foo} {bar}", foo=0i, bar=1i), "0 1"); + t!(format!("{foo} {1} {bar} {0}", 0i, 1i, foo=2i, bar=3i), "2 1 3 0"); t!(format!("{} {0}", "a"), "a a"); - t!(format!("{foo_bar}", foo_bar=1), "1"); - t!(format!("{:d}", 5 + 5), "10"); + t!(format!("{foo_bar}", foo_bar=1i), "1"); + t!(format!("{:d}", 5i + 5i), "10"); // Formatting strings and their arguments t!(format!("{:s}", "a"), "a"); @@ -132,7 +132,7 @@ pub fn main() { test_order(); // make sure that format! doesn't move out of local variables - let a = box 3; + let a = box 3i; format!("{:?}", a); format!("{:?}", a); @@ -154,10 +154,10 @@ pub fn main() { // io::Writer instance. fn test_write() { let mut buf = MemWriter::new(); - write!(&mut buf as &mut io::Writer, "{}", 3); + write!(&mut buf as &mut io::Writer, "{}", 3i); { let w = &mut buf as &mut io::Writer; - write!(w, "{foo}", foo=4); + write!(w, "{foo}", foo=4i); write!(w, "{:s}", "hello"); writeln!(w, "{}", "line"); writeln!(w, "{foo}", foo="bar"); @@ -183,9 +183,9 @@ fn test_format_args() { let mut buf = MemWriter::new(); { let w = &mut buf as &mut io::Writer; - format_args!(|args| { write!(w, "{}", args); }, "{}", 1); + format_args!(|args| { write!(w, "{}", args); }, "{}", 1i); format_args!(|args| { write!(w, "{}", args); }, "test"); - format_args!(|args| { write!(w, "{}", args); }, "{test}", test=3); + format_args!(|args| { write!(w, "{}", args); }, "{test}", test=3i); } let s = str::from_utf8(buf.unwrap().as_slice()).unwrap().to_string(); t!(s, "1test3"); diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index d8840041f29..5ffcbb7e0fd 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -16,7 +16,7 @@ pub fn main() { assert_eq!(size_of::(), 1); - let (mut x, mut y) = (1, 2); + let (mut x, mut y) = (1i, 2i); swap(&mut x, &mut y); assert_eq!(x, 2); assert_eq!(y, 1); diff --git a/src/test/run-pass/integer-literal-radix.rs b/src/test/run-pass/integer-literal-radix.rs index 0423e7b89f0..b1a92f70449 100644 --- a/src/test/run-pass/integer-literal-radix.rs +++ b/src/test/run-pass/integer-literal-radix.rs @@ -9,12 +9,12 @@ // except according to those terms. pub fn main() { - let a = 0xBEEF; - let b = 0o755; - let c = 0b10101; - let d = -0xBEEF; - let e = -0o755; - let f = -0b10101; + let a = 0xBEEFi; + let b = 0o755i; + let c = 0b10101i; + let d = -0xBEEFi; + let e = -0o755i; + let f = -0b10101i; assert_eq!(a, 48879); assert_eq!(b, 493); diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index 8a856b14eae..f28ba7b8bc0 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -38,7 +38,7 @@ mod rusti { pub fn main() { unsafe { - let mut x = box 1; + let mut x = box 1i; assert_eq!(rusti::atomic_load(&*x), 1); *x = 5; diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 84b80d43f09..4375c63a1b8 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -21,7 +21,7 @@ mod rusti { pub fn main() { unsafe { - let x = box 1; + let x = box 1i; let mut y = rusti::init(); let mut z: *uint = transmute(&x); rusti::move_val_init(&mut y, x); diff --git a/src/test/run-pass/issue-10626.rs b/src/test/run-pass/issue-10626.rs index dd513547212..8a6e300bd15 100644 --- a/src/test/run-pass/issue-10626.rs +++ b/src/test/run-pass/issue-10626.rs @@ -19,10 +19,10 @@ pub fn main () { let args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { - for _ in range(0, 1000) { + for _ in range(0i, 1000i) { println!("hello?"); } - for _ in range(0, 1000) { + for _ in range(0i, 1000i) { println!("hello?"); } return; diff --git a/src/test/run-pass/issue-11225-1.rs b/src/test/run-pass/issue-11225-1.rs index ecedeaba751..bcdbfb27753 100644 --- a/src/test/run-pass/issue-11225-1.rs +++ b/src/test/run-pass/issue-11225-1.rs @@ -13,5 +13,5 @@ extern crate foo = "issue-11225-1"; pub fn main() { - foo::foo(1); + foo::foo(1i); } diff --git a/src/test/run-pass/issue-11225-2.rs b/src/test/run-pass/issue-11225-2.rs index 774d9e6d1b8..a9b70b1d7c2 100644 --- a/src/test/run-pass/issue-11225-2.rs +++ b/src/test/run-pass/issue-11225-2.rs @@ -13,5 +13,5 @@ extern crate foo = "issue-11225-2"; pub fn main() { - foo::foo(1); + foo::foo(1i); } diff --git a/src/test/run-pass/issue-12582.rs b/src/test/run-pass/issue-12582.rs index a5e3c647453..418fd54cc13 100644 --- a/src/test/run-pass/issue-12582.rs +++ b/src/test/run-pass/issue-12582.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - let x = 1; - let y = 2; + let x = 1i; + let y = 2i; - assert_eq!(3, match (x, y) { + assert_eq!(3i, match (x, y) { (1, 1) => 1, (2, 2) => 2, (1..2, 2) => 3, @@ -20,7 +20,7 @@ pub fn main() { }); // nested tuple - assert_eq!(3, match ((x, y),) { + assert_eq!(3i, match ((x, y),) { ((1, 1),) => 1, ((2, 2),) => 2, ((1..2, 2),) => 3, diff --git a/src/test/run-pass/issue-13027.rs b/src/test/run-pass/issue-13027.rs index fc3b1c7cb1a..8acaa889a04 100644 --- a/src/test/run-pass/issue-13027.rs +++ b/src/test/run-pass/issue-13027.rs @@ -27,27 +27,27 @@ pub fn main() { } fn lit_shadow_range() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 1 if false => 1, 1..2 => 2, _ => 3 }); - let x = 0; - assert_eq!(2, match x+1 { + let x = 0i; + assert_eq!(2i, match x+1 { 0 => 0, 1 if false => 1, 1..2 => 2, _ => 3 }); - assert_eq!(2, match val() { + assert_eq!(2i, match val() { 1 if false => 1, 1..2 => 2, _ => 3 }); - assert_eq!(2, match CONST { + assert_eq!(2i, match CONST { 0 => 0, 1 if false => 1, 1..2 => 2, @@ -55,7 +55,7 @@ fn lit_shadow_range() { }); // value is out of the range of second arm, should match wildcard pattern - assert_eq!(3, match 3 { + assert_eq!(3i, match 3 { 1 if false => 1, 1..2 => 2, _ => 3 @@ -63,27 +63,27 @@ fn lit_shadow_range() { } fn range_shadow_lit() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 1..2 if false => 1, 1 => 2, _ => 3 }); - let x = 0; - assert_eq!(2, match x+1 { + let x = 0i; + assert_eq!(2i, match x+1 { 0 => 0, 1..2 if false => 1, 1 => 2, _ => 3 }); - assert_eq!(2, match val() { + assert_eq!(2i, match val() { 1..2 if false => 1, 1 => 2, _ => 3 }); - assert_eq!(2, match CONST { + assert_eq!(2i, match CONST { 0 => 0, 1..2 if false => 1, 1 => 2, @@ -91,7 +91,7 @@ fn range_shadow_lit() { }); // ditto - assert_eq!(3, match 3 { + assert_eq!(3i, match 3 { 1..2 if false => 1, 1 => 2, _ => 3 @@ -99,27 +99,27 @@ fn range_shadow_lit() { } fn range_shadow_range() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 0..2 if false => 1, 1..3 => 2, _ => 3, }); - let x = 0; - assert_eq!(2, match x+1 { + let x = 0i; + assert_eq!(2i, match x+1 { 100 => 0, 0..2 if false => 1, 1..3 => 2, _ => 3, }); - assert_eq!(2, match val() { + assert_eq!(2i, match val() { 0..2 if false => 1, 1..3 => 2, _ => 3, }); - assert_eq!(2, match CONST { + assert_eq!(2i, match CONST { 100 => 0, 0..2 if false => 1, 1..3 => 2, @@ -127,7 +127,7 @@ fn range_shadow_range() { }); // ditto - assert_eq!(3, match 5 { + assert_eq!(3i, match 5 { 0..2 if false => 1, 1..3 => 2, _ => 3, @@ -135,7 +135,7 @@ fn range_shadow_range() { } fn multi_pats_shadow_lit() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 100 => 0, 0 | 1..10 if false => 1, 1 => 2, @@ -144,7 +144,7 @@ fn multi_pats_shadow_lit() { } fn multi_pats_shadow_range() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 100 => 0, 0 | 1..10 if false => 1, 1..3 => 2, @@ -153,7 +153,7 @@ fn multi_pats_shadow_range() { } fn lit_shadow_multi_pats() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 100 => 0, 1 if false => 1, 0 | 1..10 => 2, @@ -162,7 +162,7 @@ fn lit_shadow_multi_pats() { } fn range_shadow_multi_pats() { - assert_eq!(2, match 1 { + assert_eq!(2i, match 1 { 100 => 0, 1..3 if false => 1, 0 | 1..10 => 2, @@ -178,9 +178,9 @@ enum Foo { // which is a rare combination of vector patterns, multiple wild-card // patterns and guard functions. let r = match [Bar(0, false)].as_slice() { - [Bar(_, pred)] if pred => 1, - [Bar(_, pred)] if !pred => 2, - _ => 0, + [Bar(_, pred)] if pred => 1i, + [Bar(_, pred)] if !pred => 2i, + _ => 0i, }; assert_eq!(2, r); } diff --git a/src/test/run-pass/issue-13494.rs b/src/test/run-pass/issue-13494.rs index 84da2d814d9..a4f88d7c04c 100644 --- a/src/test/run-pass/issue-13494.rs +++ b/src/test/run-pass/issue-13494.rs @@ -30,7 +30,7 @@ fn test() { let (tx, rx) = channel(); spawn(proc() { helper(rx) }); let (snd, rcv) = channel(); - for _ in range(1, 100000) { + for _ in range(1i, 100000i) { snd.send(1); let (tx2, rx2) = channel(); tx.send(tx2); diff --git a/src/test/run-pass/issue-13867.rs b/src/test/run-pass/issue-13867.rs index fb76dbf2f69..8bea2e78046 100644 --- a/src/test/run-pass/issue-13867.rs +++ b/src/test/run-pass/issue-13867.rs @@ -18,39 +18,39 @@ enum Foo { fn main() { let r = match (FooNullary, 'a') { - (FooUint(..), 'a'..'z') => 1, - (FooNullary, 'x') => 2, + (FooUint(..), 'a'..'z') => 1i, + (FooNullary, 'x') => 2i, _ => 0 }; assert_eq!(r, 0); let r = match (FooUint(0), 'a') { - (FooUint(1), 'a'..'z') => 1, - (FooUint(..), 'x') => 2, - (FooNullary, 'a') => 3, + (FooUint(1), 'a'..'z') => 1i, + (FooUint(..), 'x') => 2i, + (FooNullary, 'a') => 3i, _ => 0 }; assert_eq!(r, 0); let r = match ('a', FooUint(0)) { - ('a'..'z', FooUint(1)) => 1, - ('x', FooUint(..)) => 2, - ('a', FooNullary) => 3, + ('a'..'z', FooUint(1)) => 1i, + ('x', FooUint(..)) => 2i, + ('a', FooNullary) => 3i, _ => 0 }; assert_eq!(r, 0); let r = match ('a', 'a') { - ('a'..'z', 'b') => 1, - ('x', 'a'..'z') => 2, + ('a'..'z', 'b') => 1i, + ('x', 'a'..'z') => 2i, _ => 0 }; assert_eq!(r, 0); let r = match ('a', 'a') { - ('a'..'z', 'b') => 1, - ('x', 'a'..'z') => 2, - ('a', 'a') => 3, + ('a'..'z', 'b') => 1i, + ('x', 'a'..'z') => 2i, + ('a', 'a') => 3i, _ => 0 }; assert_eq!(r, 3); diff --git a/src/test/run-pass/issue-14308.rs b/src/test/run-pass/issue-14308.rs index 0e4b4a2c9cf..82a1a16ba57 100644 --- a/src/test/run-pass/issue-14308.rs +++ b/src/test/run-pass/issue-14308.rs @@ -13,12 +13,12 @@ fn main() { let x = match A(3) { - A(..) => 1 + A(..) => 1i }; assert_eq!(x, 1); let x = match A(4) { - A(1) => 1, - A(..) => 2 + A(1) => 1i, + A(..) => 2i }; assert_eq!(x, 2); @@ -26,7 +26,7 @@ fn main() { // There's no particularly good reason to support this, but it's currently allowed, // and this makes sure it doesn't ICE or break LLVM. let x = match B { - B(..) => 3 + B(..) => 3i }; assert_eq!(x, 3); } diff --git a/src/test/run-pass/issue-14865.rs b/src/test/run-pass/issue-14865.rs index 7fa88a7653a..c84b1eae8e0 100644 --- a/src/test/run-pass/issue-14865.rs +++ b/src/test/run-pass/issue-14865.rs @@ -15,14 +15,14 @@ enum X { fn main() { let x = match Foo(42) { - Foo(..) => 1, + Foo(..) => 1i, _ if true => 0, Bar(..) => fail!("Oh dear") }; assert_eq!(x, 1); let x = match Foo(42) { - _ if true => 0, + _ if true => 0i, Foo(..) => 1, Bar(..) => fail!("Oh dear") }; diff --git a/src/test/run-pass/issue-15080.rs b/src/test/run-pass/issue-15080.rs index b12f0c6462e..b0741391d80 100644 --- a/src/test/run-pass/issue-15080.rs +++ b/src/test/run-pass/issue-15080.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let mut x = &[1, 2, 3, 4]; + let mut x = &[1i, 2, 3, 4]; let mut result = vec!(); loop { diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index ae5cff0dddf..7276b11b181 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -11,7 +11,7 @@ extern crate debug; pub fn main() { - let mut x = 0; + let mut x = 0i; 'foo: loop { 'bar: loop { diff --git a/src/test/run-pass/issue-2633-2.rs b/src/test/run-pass/issue-2633-2.rs index 42170bfe832..e2a03c696f2 100644 --- a/src/test/run-pass/issue-2633-2.rs +++ b/src/test/run-pass/issue-2633-2.rs @@ -14,6 +14,6 @@ fn a_val(x: Box, y: Box) -> int { } pub fn main() { - let z = box 22; + let z = box 22i; a_val(z.clone(), z.clone()); } diff --git a/src/test/run-pass/issue-3091.rs b/src/test/run-pass/issue-3091.rs index c4c2c2b7da8..2e287e24e23 100644 --- a/src/test/run-pass/issue-3091.rs +++ b/src/test/run-pass/issue-3091.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let x = 1; - let y = 1; + let x = 1i; + let y = 1i; assert_eq!(&x, &y); } diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index 6921ba649e6..c52c23b5d75 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - let mut x = 0; - for _ in range(0, 4096) { x += 1; } + let mut x = 0i; + for _ in range(0i, 4096) { x += 1; } assert_eq!(x, 4096); println!("x = {}", x); } diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index 00b78ee8e40..139d984b507 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut x = box 3; + let mut x = box 3i; x = x; assert_eq!(*x, 3); } diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index 3220c8d0c69..53f92246e54 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -22,8 +22,8 @@ fn check_strs(actual: &str, expected: &str) -> bool { pub fn main() { let mut table = HashMap::new(); - table.insert("one".to_string(), 1); - table.insert("two".to_string(), 2); + table.insert("one".to_string(), 1i); + table.insert("two".to_string(), 2i); assert!(check_strs(table.to_str().as_slice(), "{one: 1, two: 2}") || check_strs(table.to_str().as_slice(), "{two: 2, one: 1}")); } diff --git a/src/test/run-pass/issue-3743.rs b/src/test/run-pass/issue-3743.rs index 13455bd4ca8..bebaad2d297 100644 --- a/src/test/run-pass/issue-3743.rs +++ b/src/test/run-pass/issue-3743.rs @@ -36,15 +36,15 @@ fn mul_vec2_by(&self, lhs: &Vec2) -> Vec2 { lhs.vmul(*self) } // Usage with failing inference pub fn main() { - let a = Vec2 { x: 3.0, y: 4.0 }; + let a = Vec2 { x: 3.0f64, y: 4.0f64 }; // the following compiles and works properly - let v1: Vec2 = a * 3.0; + let v1: Vec2 = a * 3.0f64; println!("{} {}", v1.x, v1.y); // the following compiles but v2 will not be Vec2 yet and // using it later will cause an error that the type of v2 // must be known - let v2 = a * 3.0; + let v2 = a * 3.0f64; println!("{} {}", v2.x, v2.y); // error regarding v2's type } diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index 35675225aae..c251fafc24b 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - let mut count = 0; - for _ in range(0, 999_999) { count += 1; } + let mut count = 0i; + for _ in range(0i, 999_999) { count += 1; } assert_eq!(count, 999_999); println!("{}", count); } diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs index 6dd2a2ec133..39c8562e458 100644 --- a/src/test/run-pass/issue-5708.rs +++ b/src/test/run-pass/issue-5708.rs @@ -41,7 +41,7 @@ fn new<'r>(inner: &'r Inner) -> Outer<'r> { } pub fn main() { - let inner = 5; + let inner = 5i; let outer = Outer::new(&inner as &Inner); outer.inner.print(); } diff --git a/src/test/run-pass/issue-7784.rs b/src/test/run-pass/issue-7784.rs index 52c2d57753a..d307a057038 100644 --- a/src/test/run-pass/issue-7784.rs +++ b/src/test/run-pass/issue-7784.rs @@ -16,7 +16,7 @@ fn bar(a: &'static str, b: &'static str) -> [&'static str, ..4] { } fn main() { - assert_eq!(foo([1, 2, 3]), (1, 3, 6)); + assert_eq!(foo([1i, 2i, 3i]), (1i, 3i, 6i)); let [a, b, c, d] = bar("foo", "bar"); assert_eq!(a, "foo"); @@ -33,4 +33,4 @@ fn main() { assert_eq!(a, "baz"); assert!(xs == ["foo", "foo"]); assert_eq!(d, "baz"); -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-8391.rs b/src/test/run-pass/issue-8391.rs index 86c9b8c6964..468e6563182 100644 --- a/src/test/run-pass/issue-8391.rs +++ b/src/test/run-pass/issue-8391.rs @@ -9,9 +9,9 @@ // except according to those terms. fn main() { - let x = match Some(1) { - ref _y @ Some(_) => 1, - None => 2, + let x = match Some(1i) { + ref _y @ Some(_) => 1i, + None => 2i, }; assert_eq!(x, 1); } diff --git a/src/test/run-pass/issue-8827.rs b/src/test/run-pass/issue-8827.rs index 73e4a2716b8..173414d1d41 100644 --- a/src/test/run-pass/issue-8827.rs +++ b/src/test/run-pass/issue-8827.rs @@ -46,7 +46,7 @@ fn main() { let ints = integers(); let threes = periodical(3); let fives = periodical(5); - for _ in range(1, 100) { + for _ in range(1i, 100i) { match (ints.recv(), threes.recv(), fives.recv()) { (_, true, true) => println!("FizzBuzz"), (_, true, false) => println!("Fizz"), diff --git a/src/test/run-pass/issue-9719.rs b/src/test/run-pass/issue-9719.rs index 52204c9e0c2..ac200e6c1ac 100644 --- a/src/test/run-pass/issue-9719.rs +++ b/src/test/run-pass/issue-9719.rs @@ -17,7 +17,7 @@ pub trait X {} impl X for int {} pub struct Z<'a>(Enum<&'a X>); - fn foo() { let x = 42; let z = Z(A(&x as &X)); let _ = z; } + fn foo() { let x = 42i; let z = Z(A(&x as &X)); let _ = z; } } mod b { @@ -28,7 +28,7 @@ struct Y<'a>{ } fn bar() { - let x = 42; + let x = 42i; let _y = Y { x: Some(&x as &X) }; } } @@ -37,7 +37,7 @@ mod c { pub trait X { fn f(&self); } impl X for int { fn f(&self) {} } pub struct Z<'a>(Option<&'a X>); - fn main() { let x = 42; let z = Z(Some(&x as &X)); let _ = z; } + fn main() { let x = 42i; let z = Z(Some(&x as &X)); let _ = z; } } pub fn main() {} diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs index 49bec6f1e9e..c453a538c7e 100644 --- a/src/test/run-pass/issue2378c.rs +++ b/src/test/run-pass/issue2378c.rs @@ -18,6 +18,6 @@ use issue2378b::{two_maybes}; pub fn main() { - let x = two_maybes{a: just(3), b: just(5)}; + let x = two_maybes{a: just(3i), b: just(5i)}; assert_eq!(x[0u], (3, 5)); } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index ed8115cd6ca..511629a6d7a 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -23,7 +23,7 @@ fn repeater(v: Box) -> Box> { } pub fn main() { - let x = 3; + let x = 3i; let y = repeater(box x); assert_eq!(x, y.get()); } diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs index d7d210c7524..091a57620f0 100644 --- a/src/test/run-pass/labeled-break.rs +++ b/src/test/run-pass/labeled-break.rs @@ -15,7 +15,7 @@ pub fn main() { } } - 'bar: for _ in range(0, 100) { + 'bar: for _ in range(0i, 100i) { loop { break 'bar; } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index 463ea0c6863..c9ea520576a 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -14,7 +14,7 @@ struct A { a: Box } fn foo() -> ||: 'static -> int { - let k = box 22; + let k = box 22i; let _u = A {a: k.clone()}; let result: ||: 'static -> int = || 22; result diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index f381bb02e54..fa3f3117c64 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -16,7 +16,7 @@ struct A { a: Box } pub fn main() { fn invoke(f: ||) { f(); } - let k = box 22; + let k = box 22i; let _u = A {a: k.clone()}; invoke(|| println!("{:?}", k.clone()) ) } diff --git a/src/test/run-pass/let-var-hygiene.rs b/src/test/run-pass/let-var-hygiene.rs index bc1bccf3bd8..7b9fa3bcf7f 100644 --- a/src/test/run-pass/let-var-hygiene.rs +++ b/src/test/run-pass/let-var-hygiene.rs @@ -11,8 +11,8 @@ #![feature(macro_rules)] // shouldn't affect evaluation of $ex: -macro_rules! bad_macro (($ex:expr) => ({let _x = 9; $ex})) +macro_rules! bad_macro (($ex:expr) => ({let _x = 9i; $ex})) pub fn main() { - let _x = 8; - assert_eq!(bad_macro!(_x),8) + let _x = 8i; + assert_eq!(bad_macro!(_x),8i) } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index 665456bb457..1dc212ba8e9 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -11,8 +11,8 @@ extern crate debug; pub fn main() { - let x = vec!(1, 2, 3); - let mut y = 0; + let x = vec!(1i, 2i, 3i); + let mut y = 0i; for i in x.iter() { println!("{:?}", *i); y += *i; } println!("{:?}", y); assert_eq!(y, 6); diff --git a/src/test/run-pass/liveness-loop-break.rs b/src/test/run-pass/liveness-loop-break.rs index 0dba1830cbd..6ad2be68e8f 100644 --- a/src/test/run-pass/liveness-loop-break.rs +++ b/src/test/run-pass/liveness-loop-break.rs @@ -11,7 +11,7 @@ fn test() { let v; loop { - v = 3; + v = 3i; break; } println!("{}", v); diff --git a/src/test/run-pass/log-poly.rs b/src/test/run-pass/log-poly.rs index 17fa14ec92d..c265bb0bcb1 100644 --- a/src/test/run-pass/log-poly.rs +++ b/src/test/run-pass/log-poly.rs @@ -15,8 +15,8 @@ enum Numbers { } pub fn main() { - println!("{}", 1); - println!("{}", 2.0); + println!("{}", 1i); + println!("{}", 2.0f64); println!("{:?}", Three); - println!("{:?}", vec!(4)); + println!("{:?}", vec!(4i)); } diff --git a/src/test/run-pass/loop-scope.rs b/src/test/run-pass/loop-scope.rs index 1dc3700194c..4b8ccad068c 100644 --- a/src/test/run-pass/loop-scope.rs +++ b/src/test/run-pass/loop-scope.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - let x = vec!(10, 20, 30); - let mut sum = 0; + let x = vec!(10i, 20i, 30i); + let mut sum = 0i; for x in x.iter() { sum += *x; } assert_eq!(sum, 60); } diff --git a/src/test/run-pass/macro-crate-def-only.rs b/src/test/run-pass/macro-crate-def-only.rs index 25da809babd..70080fcc3c9 100644 --- a/src/test/run-pass/macro-crate-def-only.rs +++ b/src/test/run-pass/macro-crate-def-only.rs @@ -16,5 +16,5 @@ extern crate macro_crate_def_only; pub fn main() { - assert_eq!(5, make_a_5!()); + assert_eq!(5i, make_a_5!()); } diff --git a/src/test/run-pass/macro-export-inner-module.rs b/src/test/run-pass/macro-export-inner-module.rs index c7911a69ce4..88ca466b4af 100644 --- a/src/test/run-pass/macro-export-inner-module.rs +++ b/src/test/run-pass/macro-export-inner-module.rs @@ -17,5 +17,5 @@ extern crate macro_export_inner_module; pub fn main() { - assert_eq!(1, foo!()); + assert_eq!(1i, foo!()); } diff --git a/src/test/run-pass/macro-pat.rs b/src/test/run-pass/macro-pat.rs index 6dc663c5620..3e89466bc0f 100644 --- a/src/test/run-pass/macro-pat.rs +++ b/src/test/run-pass/macro-pat.rs @@ -49,27 +49,27 @@ fn f(c: Option) -> uint { } pub fn main() { - assert_eq!(1, f(Some('x'))); - assert_eq!(2, f(Some('y'))); - assert_eq!(3, f(None)); + assert_eq!(1u, f(Some('x'))); + assert_eq!(2u, f(Some('y'))); + assert_eq!(3u, f(None)); - assert_eq!(1, match Some('x') { - Some(char_x!()) => 1, - _ => 2, + assert_eq!(1i, match Some('x') { + Some(char_x!()) => 1i, + _ => 2i, }); - assert_eq!(1, match Some('x') { - some!(char_x!()) => 1, - _ => 2, + assert_eq!(1i, match Some('x') { + some!(char_x!()) => 1i, + _ => 2i, }); - assert_eq!(1, match Some('x') { - indirect!() => 1, - _ => 2, + assert_eq!(1i, match Some('x') { + indirect!() => 1i, + _ => 2i, }); - assert_eq!(3, { - let ident_pat!(x) = 2; - x+1 + assert_eq!(3i, { + let ident_pat!(x) = 2i; + x+1i }); } diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index d8cde95a1dc..49e146cb0cf 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -28,17 +28,17 @@ macro_rules! mylet( ) ); - mylet!(y, 8*2); - assert_eq!(y, 16); + mylet!(y, 8i*2); + assert_eq!(y, 16i); myfn!(mult, (a,b), { a*b } ); assert_eq!(mult(2, add(4,4)), 16); macro_rules! actually_an_expr_macro ( - () => ( 16 ) + () => ( 16i ) ) - assert_eq!({ actually_an_expr_macro!() }, 16); + assert_eq!({ actually_an_expr_macro!() }, 16i); } diff --git a/src/test/run-pass/macro-with-attrs1.rs b/src/test/run-pass/macro-with-attrs1.rs index 3bd0aba8b6d..aaa2be66ff4 100644 --- a/src/test/run-pass/macro-with-attrs1.rs +++ b/src/test/run-pass/macro-with-attrs1.rs @@ -13,11 +13,11 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1) ) +macro_rules! foo( () => (1i) ) #[cfg(not(foo))] -macro_rules! foo( () => (2) ) +macro_rules! foo( () => (2i) ) pub fn main() { - assert_eq!(foo!(), 1); + assert_eq!(foo!(), 1i); } diff --git a/src/test/run-pass/macro-with-attrs2.rs b/src/test/run-pass/macro-with-attrs2.rs index 33b053c9dc7..4a191b2fa66 100644 --- a/src/test/run-pass/macro-with-attrs2.rs +++ b/src/test/run-pass/macro-with-attrs2.rs @@ -11,12 +11,12 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1) ) +macro_rules! foo( () => (1i) ) #[cfg(not(foo))] -macro_rules! foo( () => (2) ) +macro_rules! foo( () => (2i) ) pub fn main() { - assert_eq!(foo!(), 2); + assert_eq!(foo!(), 2i); } diff --git a/src/test/run-pass/match-pipe-binding.rs b/src/test/run-pass/match-pipe-binding.rs index d17bf8500e0..52d966a12d7 100644 --- a/src/test/run-pass/match-pipe-binding.rs +++ b/src/test/run-pass/match-pipe-binding.rs @@ -20,7 +20,7 @@ fn test1() { } fn test2() { - match (1, 2, 3) { + match (1i, 2i, 3i) { (1, a, b) | (2, b, a) => { assert_eq!(a, 2); assert_eq!(b, 3); @@ -30,7 +30,7 @@ fn test2() { } fn test3() { - match (1, 2, 3) { + match (1i, 2i, 3i) { (1, ref a, ref b) | (2, ref b, ref a) => { assert_eq!(*a, 2); assert_eq!(*b, 3); @@ -40,7 +40,7 @@ fn test3() { } fn test4() { - match (1, 2, 3) { + match (1i, 2i, 3i) { (1, a, b) | (2, b, a) if a == 2 => { assert_eq!(a, 2); assert_eq!(b, 3); @@ -50,7 +50,7 @@ fn test4() { } fn test5() { - match (1, 2, 3) { + match (1i, 2i, 3i) { (1, ref a, ref b) | (2, ref b, ref a) if *a == 2 => { assert_eq!(*a, 2); assert_eq!(*b, 3); diff --git a/src/test/run-pass/match-ref-binding-mut-option.rs b/src/test/run-pass/match-ref-binding-mut-option.rs index 8d1e483bcd8..c983903ac18 100644 --- a/src/test/run-pass/match-ref-binding-mut-option.rs +++ b/src/test/run-pass/match-ref-binding-mut-option.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut v = Some(22); + let mut v = Some(22i); match v { None => {} Some(ref mut p) => { *p += 1; } diff --git a/src/test/run-pass/match-str.rs b/src/test/run-pass/match-str.rs index 574d7c3bf7f..d31f7a60715 100644 --- a/src/test/run-pass/match-str.rs +++ b/src/test/run-pass/match-str.rs @@ -23,7 +23,7 @@ enum t { tag1(String), tag2, } _ => fail!() } - let x = match "a" { "a" => 1, "b" => 2, _ => fail!() }; + let x = match "a" { "a" => 1i, "b" => 2i, _ => fail!() }; assert_eq!(x, 1); match "a" { "a" => { } "b" => { }, _ => fail!() } diff --git a/src/test/run-pass/match-unique-bind.rs b/src/test/run-pass/match-unique-bind.rs index 26d5a018a66..f6b2027e0fe 100644 --- a/src/test/run-pass/match-unique-bind.rs +++ b/src/test/run-pass/match-unique-bind.rs @@ -11,7 +11,7 @@ extern crate debug; pub fn main() { - match box 100 { + match box 100i { box x => { println!("{:?}", x); assert_eq!(x, 100); diff --git a/src/test/run-pass/match-vec-rvalue.rs b/src/test/run-pass/match-vec-rvalue.rs index ab945253679..70c3b386a8a 100644 --- a/src/test/run-pass/match-vec-rvalue.rs +++ b/src/test/run-pass/match-vec-rvalue.rs @@ -12,7 +12,7 @@ pub fn main() { - match vec!(1, 2, 3) { + match vec!(1i, 2i, 3i) { x => { assert_eq!(x.len(), 3); assert_eq!(*x.get(0), 1); diff --git a/src/test/run-pass/mod-view-items.rs b/src/test/run-pass/mod-view-items.rs index 8a546a729d5..2b23787dd0f 100644 --- a/src/test/run-pass/mod-view-items.rs +++ b/src/test/run-pass/mod-view-items.rs @@ -16,7 +16,7 @@ // begin failing. mod m { - pub fn f() -> Vec { Vec::from_elem(1u, 0) } + pub fn f() -> Vec { Vec::from_elem(1u, 0i) } } pub fn main() { let _x = m::f(); } diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index dc165f63c9a..04d642094e3 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -33,9 +33,9 @@ impl Serializer for int { } pub fn main() { - let foo = F { a: 1 }; + let foo = F { a: 1i }; foo.serialize(1i); - let bar = F { a: F {a: 1 } }; + let bar = F { a: F {a: 1i } }; bar.serialize(2i); } diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs index 7ce1afb52a2..10abe4ce710 100644 --- a/src/test/run-pass/multiple-trait-bounds.rs +++ b/src/test/run-pass/multiple-trait-bounds.rs @@ -12,5 +12,5 @@ fn f(_: T) { } pub fn main() { - f(3); + f(3i); } diff --git a/src/test/run-pass/mut-in-ident-patterns.rs b/src/test/run-pass/mut-in-ident-patterns.rs index 13303e7b108..f90e5a56d99 100644 --- a/src/test/run-pass/mut-in-ident-patterns.rs +++ b/src/test/run-pass/mut-in-ident-patterns.rs @@ -20,7 +20,7 @@ fn foo(&self, mut x: int) -> int { impl Foo for X {} pub fn main() { - let (a, mut b) = (23, 4); + let (a, mut b) = (23i, 4i); assert_eq!(a, 23); assert_eq!(b, 4); b = a + b; @@ -34,7 +34,7 @@ enum Bar { Baz(f32, u8) } - let (x, mut y) = (32, Foo(21)); + let (x, mut y) = (32i, Foo(21)); match x { mut z @ 32 => { diff --git a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs index 855c77e92cf..ffab06e2203 100644 --- a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs +++ b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs @@ -9,13 +9,13 @@ // except according to those terms. fn test1() { - let mut ints = [0, ..32]; + let mut ints = [0i, ..32]; ints[0] += 1; assert_eq!(ints[0], 1); } fn test2() { - let mut ints = [0, ..32]; + let mut ints = [0i, ..32]; for i in ints.mut_iter() { *i += 22; } for i in ints.iter() { assert!(*i == 22); } } diff --git a/src/test/run-pass/nested-matchs.rs b/src/test/run-pass/nested-matchs.rs index 571b3371fe6..e95ee4c99c5 100644 --- a/src/test/run-pass/nested-matchs.rs +++ b/src/test/run-pass/nested-matchs.rs @@ -16,7 +16,7 @@ fn foo() { match Some::(5) { Some::(_x) => { let mut bar; - match None:: { None:: => { bar = 5; } _ => { baz(); } } + match None:: { None:: => { bar = 5i; } _ => { baz(); } } println!("{:?}", bar); } None:: => { println!("hello"); } diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 0a30a80314a..4d15e4fe215 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -23,7 +23,7 @@ fn myvec_elt(mv: myvec) -> X { } pub fn main() { - let mv = myvec(vec!(1, 2, 3)); + let mv = myvec(vec!(1i, 2, 3)); let mv_clone = mv.clone(); let mv_clone = myvec_deref(mv_clone); assert_eq!(*mv_clone.get(1), 2); diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index 6ac079f4616..de5456ef1c0 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -46,8 +46,8 @@ pub fn main() { let bar = "bar".to_string(); let mut list = AssociationList {pairs: Vec::new()}; - list.push(foo.clone(), 22); - list.push(bar.clone(), 44); + list.push(foo.clone(), 22i); + list.push(bar.clone(), 44i); assert!(list[foo] == 22) assert!(list[bar] == 44) diff --git a/src/test/run-pass/overloaded-autoderef-indexing.rs b/src/test/run-pass/overloaded-autoderef-indexing.rs index c8885a3090c..37e7ee6c216 100644 --- a/src/test/run-pass/overloaded-autoderef-indexing.rs +++ b/src/test/run-pass/overloaded-autoderef-indexing.rs @@ -19,6 +19,6 @@ fn deref<'b>(&'b self) -> &'b &'a [T] { } pub fn main() { - let a = &[1, 2, 3]; + let a = &[1i, 2i, 3i]; assert_eq!(DerefArray {inner: a}[1], 2); } diff --git a/src/test/run-pass/overloaded-autoderef-order.rs b/src/test/run-pass/overloaded-autoderef-order.rs index 1276171853f..188c62751bc 100644 --- a/src/test/run-pass/overloaded-autoderef-order.rs +++ b/src/test/run-pass/overloaded-autoderef-order.rs @@ -50,7 +50,7 @@ fn deref<'a>(&'a self) -> &'a Y { } pub fn main() { - let nested = DerefWrapper {x: true, y: DerefWrapper {x: 0, y: 1}}; + let nested = DerefWrapper {x: true, y: DerefWrapper {x: 0i, y: 1i}}; // Use the first field that you can find. assert_eq!(nested.x, true); @@ -64,7 +64,7 @@ pub fn main() { // Also go through multiple levels of indirection. assert_eq!(Rc::new(nested).x, true); - let nested_priv = priv_test::DerefWrapperHideX::new(true, DerefWrapper {x: 0, y: 1}); + let nested_priv = priv_test::DerefWrapperHideX::new(true, DerefWrapper {x: 0i, y: 1i}); // FIXME(eddyb) #12808 should skip private fields. // assert_eq!(nested_priv.x, 0); assert_eq!((*nested_priv).x, 0); diff --git a/src/test/run-pass/overloaded-autoderef-xcrate.rs b/src/test/run-pass/overloaded-autoderef-xcrate.rs index f8dd729ec67..4f449b344e3 100644 --- a/src/test/run-pass/overloaded-autoderef-xcrate.rs +++ b/src/test/run-pass/overloaded-autoderef-xcrate.rs @@ -13,5 +13,5 @@ extern crate overloaded_autoderef_xc; fn main() { - assert!(overloaded_autoderef_xc::check(5, 5)); + assert!(overloaded_autoderef_xc::check(5i, 5i)); } diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index cd5903ad4e3..a0686e7f17f 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -25,7 +25,7 @@ pub fn main() { assert_eq!(point.x, 2); assert_eq!(point.y, 4); - let i = Rc::new(RefCell::new(2)); + let i = Rc::new(RefCell::new(2i)); let i_value = *i.borrow(); *i.borrow_mut() = 5; assert_eq!((i_value, *i.borrow()), (2, 5)); @@ -45,7 +45,7 @@ pub fn main() { p.borrow_mut().y += 3; assert_eq!(*p.borrow(), Point {x: 3, y: 5}); - let v = Rc::new(RefCell::new([1, 2, 3])); + let v = Rc::new(RefCell::new([1i, 2, 3])); v.borrow_mut()[0] = 3; v.borrow_mut()[1] += 3; assert_eq!((v.borrow()[0], v.borrow()[1], v.borrow()[2]), (3, 5, 3)); diff --git a/src/test/run-pass/overloaded-deref-count.rs b/src/test/run-pass/overloaded-deref-count.rs index 24dde8ada18..49edf1bad57 100644 --- a/src/test/run-pass/overloaded-deref-count.rs +++ b/src/test/run-pass/overloaded-deref-count.rs @@ -47,7 +47,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T { } pub fn main() { - let mut n = DerefCounter::new(0); + let mut n = DerefCounter::new(0i); let mut v = DerefCounter::new(Vec::new()); let _ = *n; // Immutable deref + copy a POD. @@ -60,7 +60,7 @@ pub fn main() { assert_eq!(n.counts(), (2, 1)); assert_eq!(v.counts(), (1, 1)); let mut v2 = Vec::new(); - v2.push(1); + v2.push(1i); *n = 5; *v = v2; // Mutable deref + assignment. assert_eq!(n.counts(), (2, 2)); assert_eq!(v.counts(), (1, 2)); diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index 17cd9f8ef05..96cf3102a42 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -19,11 +19,11 @@ struct Point { } pub fn main() { - assert_eq!(*Rc::new(5), 5); - assert_eq!(***Rc::new(box box 5), 5); + assert_eq!(*Rc::new(5i), 5); + assert_eq!(***Rc::new(box box 5i), 5); assert_eq!(*Rc::new(Point {x: 2, y: 4}), Point {x: 2, y: 4}); - let i = Rc::new(RefCell::new(2)); + let i = Rc::new(RefCell::new(2i)); let i_value = *(*i).borrow(); *(*i).borrow_mut() = 5; assert_eq!((i_value, *(*i).borrow()), (2, 5)); @@ -43,7 +43,7 @@ pub fn main() { (*(*p).borrow_mut()).y += 3; assert_eq!(*(*p).borrow(), Point {x: 3, y: 5}); - let v = Rc::new(RefCell::new(vec!(1, 2, 3))); + let v = Rc::new(RefCell::new(vec!(1i, 2, 3))); *(*(*v).borrow_mut()).get_mut(0) = 3; *(*(*v).borrow_mut()).get_mut(1) += 3; assert_eq!((*(*(*v).borrow()).get(0), diff --git a/src/test/run-pass/proc-bounds.rs b/src/test/run-pass/proc-bounds.rs index b6076cc26fc..8968b700540 100644 --- a/src/test/run-pass/proc-bounds.rs +++ b/src/test/run-pass/proc-bounds.rs @@ -27,7 +27,7 @@ pub fn main() { is_static::(); - let a = 3; + let a = 3i; bar::(proc() { let b = &a; println!("{}", *b); diff --git a/src/test/run-pass/reexported-static-methods-cross-crate.rs b/src/test/run-pass/reexported-static-methods-cross-crate.rs index 5399f3cfd35..0d0fdb13db3 100644 --- a/src/test/run-pass/reexported-static-methods-cross-crate.rs +++ b/src/test/run-pass/reexported-static-methods-cross-crate.rs @@ -17,8 +17,8 @@ use reexported_static_methods::Bort; pub fn main() { - assert_eq!(42, Foo::foo()); - assert_eq!(84, Baz::bar()); - assert!(Boz::boz(1)); + assert_eq!(42i, Foo::foo()); + assert_eq!(84i, Baz::bar()); + assert!(Boz::boz(1i)); assert_eq!("bort()".to_string(), Bort::bort()); } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index ac40fb885a1..65cecb2d500 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -17,7 +17,7 @@ fn box_it<'r>(x: ||: 'r) -> closure_box<'r> { } pub fn main() { - let mut i = 3; + let mut i = 3i; assert_eq!(i, 3); { let cl = || i += 1; diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index a7ba496dc4a..6deae8618fa 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -79,7 +79,7 @@ fn short<'b>(&'b self) -> int { } impl<'t> MakerTrait<'t> for Box> { - fn mk() -> Box> { box() (4,5) as Box } + fn mk() -> Box> { box() (4i,5i) as Box } } enum List<'l> { @@ -109,7 +109,7 @@ fn mk(l:List<'t>) -> &'t List<'t> { } pub fn main() { - let t = (2,3); + let t = (2i,3i); let o = &t as &Trait; let s1 = Struct1 { f: o }; let s2 = Struct2 { f: o }; diff --git a/src/test/run-pass/regions-early-bound-used-in-bound.rs b/src/test/run-pass/regions-early-bound-used-in-bound.rs index 22ea87c8d28..c262370ac5d 100644 --- a/src/test/run-pass/regions-early-bound-used-in-bound.rs +++ b/src/test/run-pass/regions-early-bound-used-in-bound.rs @@ -30,6 +30,6 @@ fn add<'a,G:GetRef<'a, int>>(g1: G, g2: G) -> int { } pub fn main() { - let b1 = Box { t: &3 }; - assert_eq!(add(b1, b1), 6); + let b1 = Box { t: &3i }; + assert_eq!(add(b1, b1), 6i); } diff --git a/src/test/run-pass/regions-early-bound-used-in-type-param.rs b/src/test/run-pass/regions-early-bound-used-in-type-param.rs index 592f4822393..708664f33e9 100644 --- a/src/test/run-pass/regions-early-bound-used-in-type-param.rs +++ b/src/test/run-pass/regions-early-bound-used-in-type-param.rs @@ -30,6 +30,6 @@ fn add<'a,G:Get<&'a int>>(g1: G, g2: G) -> int { } pub fn main() { - let b1 = Box { t: &3 }; - assert_eq!(add(b1, b1), 6); + let b1 = Box { t: &3i }; + assert_eq!(add(b1, b1), 6i); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index ee01a3837dc..8f055318533 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -13,7 +13,7 @@ fn borrow<'r, T>(x: &'r T) -> &'r T {x} pub fn main() { - let x = box(GC) 3; + let x = box(GC) 3i; loop { let y = borrow(x); assert_eq!(*x, *y); diff --git a/src/test/run-pass/regions-return-interior-of-option.rs b/src/test/run-pass/regions-return-interior-of-option.rs index aa4630717db..d1530c4c7b9 100644 --- a/src/test/run-pass/regions-return-interior-of-option.rs +++ b/src/test/run-pass/regions-return-interior-of-option.rs @@ -16,14 +16,14 @@ fn get<'r, T>(opt: &'r Option) -> &'r T { } pub fn main() { - let mut x = Some(23); + let mut x = Some(23i); { let y = get(&x); assert_eq!(*y, 23); } - x = Some(24); + x = Some(24i); { let y = get(&x); diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index 27c5e5397f9..07ea2534b9f 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -14,7 +14,7 @@ pub fn main() { let x = [ [true], ..512 ]; - let y = [ 0, ..1 ]; + let y = [ 0i, ..1 ]; println!("{:?}", x); println!("{:?}", y); diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index ef14e0ba931..29729b15aa8 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -13,13 +13,13 @@ pub fn main() { assert!(("hello".to_string() < "hellr".to_string())); assert!(("hello ".to_string() > "hello".to_string())); assert!(("hello".to_string() != "there".to_string())); - assert!((vec!(1, 2, 3, 4) > vec!(1, 2, 3))); - assert!((vec!(1, 2, 3) < vec!(1, 2, 3, 4))); - assert!((vec!(1, 2, 4, 4) > vec!(1, 2, 3, 4))); - assert!((vec!(1, 2, 3, 4) < vec!(1, 2, 4, 4))); - assert!((vec!(1, 2, 3) <= vec!(1, 2, 3))); - assert!((vec!(1, 2, 3) <= vec!(1, 2, 3, 3))); - assert!((vec!(1, 2, 3, 4) > vec!(1, 2, 3))); - assert_eq!(vec!(1, 2, 3), vec!(1, 2, 3)); - assert!((vec!(1, 2, 3) != vec!(1, 1, 3))); + assert!((vec!(1i, 2, 3, 4) > vec!(1, 2, 3))); + assert!((vec!(1i, 2, 3) < vec!(1, 2, 3, 4))); + assert!((vec!(1i, 2, 4, 4) > vec!(1, 2, 3, 4))); + assert!((vec!(1i, 2, 3, 4) < vec!(1, 2, 4, 4))); + assert!((vec!(1i, 2, 3) <= vec!(1, 2, 3))); + assert!((vec!(1i, 2, 3) <= vec!(1, 2, 3, 3))); + assert!((vec!(1i, 2, 3, 4) > vec!(1, 2, 3))); + assert_eq!(vec!(1i, 2, 3), vec!(1, 2, 3)); + assert!((vec!(1i, 2, 3) != vec!(1, 1, 3))); } diff --git a/src/test/run-pass/shift.rs b/src/test/run-pass/shift.rs index 945bb885ad1..d8a67eef3f6 100644 --- a/src/test/run-pass/shift.rs +++ b/src/test/run-pass/shift.rs @@ -18,44 +18,44 @@ pub fn main() { } fn test_misc() { - assert_eq!(1 << 1i8 << 1u8 << 1i16 << 1u8 << 1u64, 32); + assert_eq!(1i << 1 << 1 << 1 << 1 << 1, 32); } fn test_expr() { let v10 = 10 as uint; let v4 = 4 as u8; let v2 = 2 as u8; - assert_eq!(v10 >> v2, v2 as uint); - assert_eq!(v10 << v4, 160 as uint); + assert_eq!(v10 >> v2 as uint, v2 as uint); + assert_eq!(v10 << v4 as uint, 160 as uint); let v10 = 10 as u8; let v4 = 4 as uint; let v2 = 2 as uint; - assert_eq!(v10 >> v2, v2 as u8); - assert_eq!(v10 << v4, 160 as u8); + assert_eq!(v10 >> v2 as uint, v2 as u8); + assert_eq!(v10 << v4 as uint, 160 as u8); let v10 = 10 as int; let v4 = 4 as i8; let v2 = 2 as i8; - assert_eq!(v10 >> v2, v2 as int); - assert_eq!(v10 << v4, 160 as int); + assert_eq!(v10 >> v2 as uint, v2 as int); + assert_eq!(v10 << v4 as uint, 160 as int); let v10 = 10 as i8; let v4 = 4 as int; let v2 = 2 as int; - assert_eq!(v10 >> v2, v2 as i8); - assert_eq!(v10 << v4, 160 as i8); + assert_eq!(v10 >> v2 as uint, v2 as i8); + assert_eq!(v10 << v4 as uint, 160 as i8); let v10 = 10 as uint; let v4 = 4 as int; let v2 = 2 as int; - assert_eq!(v10 >> v2, v2 as uint); - assert_eq!(v10 << v4, 160 as uint); + assert_eq!(v10 >> v2 as uint, v2 as uint); + assert_eq!(v10 << v4 as uint, 160 as uint); } fn test_const() { - static r1_1: uint = 10u >> 2u8; - static r2_1: uint = 10u << 4u8; + static r1_1: uint = 10u >> 2u; + static r2_1: uint = 10u << 4u; assert_eq!(r1_1, 2 as uint); assert_eq!(r2_1, 160 as uint); @@ -64,18 +64,18 @@ fn test_const() { assert_eq!(r1_2, 2 as u8); assert_eq!(r2_2, 160 as u8); - static r1_3: int = 10 >> 2i8; - static r2_3: int = 10 << 4i8; + static r1_3: int = 10 >> 2u; + static r2_3: int = 10 << 4u; assert_eq!(r1_3, 2 as int); assert_eq!(r2_3, 160 as int); - static r1_4: i8 = 10i8 >> 2; - static r2_4: i8 = 10i8 << 4; + static r1_4: i8 = 10i8 >> 2u; + static r2_4: i8 = 10i8 << 4u; assert_eq!(r1_4, 2 as i8); assert_eq!(r2_4, 160 as i8); - static r1_5: uint = 10u >> 2i8; - static r2_5: uint = 10u << 4i8; + static r1_5: uint = 10u >> 2u; + static r2_5: uint = 10u << 4u; assert_eq!(r1_5, 2 as uint); assert_eq!(r2_5, 160 as uint); } diff --git a/src/test/run-pass/simple-infer.rs b/src/test/run-pass/simple-infer.rs index 04c1af4326b..4f6feb544f4 100644 --- a/src/test/run-pass/simple-infer.rs +++ b/src/test/run-pass/simple-infer.rs @@ -10,4 +10,4 @@ -pub fn main() { let mut n; n = 1; println!("{}", n); } +pub fn main() { let mut n; n = 1i; println!("{}", n); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index f6c314b20dd..9267fcac011 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -61,10 +61,10 @@ pub fn main() { assert_eq!(10u.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!((vec!(1i)).length_().str(), "1".to_string()); + let vect = vec!(3i, 4).map_(|a| *a + 4); assert_eq!(*vect.get(0), 7); - let vect = (vec!(3, 4)).map_::(|a| *a as uint + 4u); + let vect = (vec!(3i, 4)).map_::(|a| *a as uint + 4u); assert_eq!(*vect.get(0), 7u); let mut x = 0u; 10u.multi(|_n| x += 2u ); diff --git a/src/test/run-pass/struct-lit-functional-no-fields.rs b/src/test/run-pass/struct-lit-functional-no-fields.rs index 9212a72e5d4..b8d6aa40ae9 100644 --- a/src/test/run-pass/struct-lit-functional-no-fields.rs +++ b/src/test/run-pass/struct-lit-functional-no-fields.rs @@ -16,8 +16,8 @@ struct Foo { pub fn main() { let foo = Foo { - bar: 0, - baz: 1 + bar: 0i, + baz: 1i }; let foo_ = foo.clone(); diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index f6b5531770b..dbf8a084da1 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -21,14 +21,14 @@ fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } } pub fn main() { - let a = (1, 2, 3); - let b = (1, 2, 3); + let a = (1i, 2i, 3i); + let b = (1i, 2i, 3i); assert_eq!(a, b); assert!((a != (1, 2, 4))); assert!((a < (1, 2, 4))); assert!((a <= (1, 2, 4))); - assert!(((1, 2, 4) > a)); - assert!(((1, 2, 4) >= a)); + assert!(((1i, 2i, 4i) > a)); + assert!(((1i, 2i, 4i) >= a)); let x = large; let y = small; assert!((x != y)); diff --git a/src/test/run-pass/supertrait-default-generics.rs b/src/test/run-pass/supertrait-default-generics.rs index 2cfc22111a7..873941395fe 100644 --- a/src/test/run-pass/supertrait-default-generics.rs +++ b/src/test/run-pass/supertrait-default-generics.rs @@ -36,7 +36,7 @@ fn X(&self) -> S { impl> Movable for Point {} pub fn main() { - let mut p = Point{ x: 1, y: 2}; + let mut p = Point{ x: 1i, y: 2i}; p.translate(3); assert_eq!(p.X(), 4); } diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs index 6116ed29e1a..b066d8a8ae0 100644 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ b/src/test/run-pass/tcp-connect-timeouts.rs @@ -70,7 +70,7 @@ fn f() $b rx1.recv(); let mut v = Vec::new(); - for _ in range(0, 10000) { + for _ in range(0u, 10000) { match TcpStream::connect_timeout(addr, 100) { Ok(e) => v.push(e), Err(ref e) if e.kind == io::TimedOut => return, diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 99bf247229e..efad0cecbde 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -58,7 +58,7 @@ fn main() { let addr = rx.recv(); let (tx, rx) = channel(); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { let tx = tx.clone(); TaskBuilder::new().stack_size(64 * 1024).spawn(proc() { let host = addr.ip.to_str(); @@ -79,7 +79,7 @@ fn main() { // Wait for all clients to exit, but don't wait for the server to exit. The // server just runs infinitely. drop(tx); - for _ in range(0, 1000) { + for _ in range(0u, 1000) { rx.recv(); } unsafe { libc::exit(0) } diff --git a/src/test/run-pass/trait-cast-generic.rs b/src/test/run-pass/trait-cast-generic.rs index c48d6e243b9..8f0ec5ec7a1 100644 --- a/src/test/run-pass/trait-cast-generic.rs +++ b/src/test/run-pass/trait-cast-generic.rs @@ -25,6 +25,6 @@ struct Bar { impl Foo for Bar { } pub fn main() { - let a = Bar { x: 1 }; + let a = Bar { x: 1u }; let b = &a as &Foo; } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 18209be0dec..daab40f5d90 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -58,10 +58,10 @@ fn foo(x: T) -> String { x.to_str_() } pub fn main() { let t1 = Tree(box(GC) RefCell::new(TreeR{left: None, right: None, - val: box 1 as Box})); + val: box 1i as Box})); let t2 = Tree(box(GC) RefCell::new(TreeR{left: Some(t1), right: Some(t1), - val: box 2 as Box})); + val: box 2i as Box})); let expected = "[2, some([1, none, none]), some([1, none, none])]".to_string(); assert!(t2.to_str_() == expected); diff --git a/src/test/run-pass/trait-default-method-bound-subst.rs b/src/test/run-pass/trait-default-method-bound-subst.rs index ff0c23b2eed..6b0ab8910de 100644 --- a/src/test/run-pass/trait-default-method-bound-subst.rs +++ b/src/test/run-pass/trait-default-method-bound-subst.rs @@ -21,6 +21,6 @@ fn f>(i: V, j: T, k: U) -> (T, U) { } pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0u, 1, 2), (1, 2)); + assert_eq!(f(0i, 1i, 2i), (1, 2)); + assert_eq!(f(0u, 1i, 2i), (1, 2)); } diff --git a/src/test/run-pass/trait-default-method-bound-subst2.rs b/src/test/run-pass/trait-default-method-bound-subst2.rs index 1ea3879e7fa..d9ba9ca9220 100644 --- a/src/test/run-pass/trait-default-method-bound-subst2.rs +++ b/src/test/run-pass/trait-default-method-bound-subst2.rs @@ -20,5 +20,5 @@ fn f>(i: V, j: T) -> T { } pub fn main () { - assert_eq!(f(0, 2), 2); + assert_eq!(f(0i, 2i), 2); } diff --git a/src/test/run-pass/trait-default-method-bound-subst3.rs b/src/test/run-pass/trait-default-method-bound-subst3.rs index aff20ffe962..43fb19a58ed 100644 --- a/src/test/run-pass/trait-default-method-bound-subst3.rs +++ b/src/test/run-pass/trait-default-method-bound-subst3.rs @@ -20,6 +20,6 @@ fn f(i: V, j: T, k: T) -> (T, T) { } pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); + assert_eq!(f(0i, 1i, 2i), (1, 2)); + assert_eq!(f(0i, 1u8, 2u8), (1u8, 2u8)); } diff --git a/src/test/run-pass/trait-default-method-bound.rs b/src/test/run-pass/trait-default-method-bound.rs index 8a2f1b1743b..1505d48839e 100644 --- a/src/test/run-pass/trait-default-method-bound.rs +++ b/src/test/run-pass/trait-default-method-bound.rs @@ -20,5 +20,5 @@ fn f(i: T) { } pub fn main () { - f(0); + f(0i); } diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index 27db6d2f3b8..8201c7ec347 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -52,9 +52,9 @@ fn test_eq(&self, rhs: &stuff::thing) -> bool { pub fn main() { // Some tests of random things - f(0); + f(0i); - assert_eq!(A::lurr(&0, &1), 21); + assert_eq!(A::lurr(&0i, &1i), 21); let a = stuff::thing { x: 0 }; let b = stuff::thing { x: 1 }; @@ -65,25 +65,25 @@ pub fn main() { assert_eq!(a.h(), 11); assert_eq!(c.h(), 11); - assert_eq!(0i.thing(3.14, 1), (3.14, 1)); - assert_eq!(B::staticthing(&0i, 3.14, 1), (3.14, 1)); + assert_eq!(0i.thing(3.14f64, 1i), (3.14f64, 1i)); + assert_eq!(B::staticthing(&0i, 3.14f64, 1i), (3.14f64, 1i)); assert_eq!(B::::staticthing::(&0i, 3.14, 1), (3.14, 1)); - assert_eq!(g(0i, 3.14, 1), (3.14, 1)); - assert_eq!(g(false, 3.14, 1), (3.14, 1)); + assert_eq!(g(0i, 3.14f64, 1i), (3.14f64, 1i)); + assert_eq!(g(false, 3.14f64, 1i), (3.14, 1)); let obj = box 0i as Box; assert_eq!(obj.h(), 11); // Trying out a real one - assert!(12.test_neq(&10)); - assert!(!10.test_neq(&10)); + assert!(12i.test_neq(&10i)); + assert!(!10i.test_neq(&10i)); assert!(a.test_neq(&b)); assert!(!a.test_neq(&a)); - assert!(neq(&12, &10)); - assert!(!neq(&10, &10)); + assert!(neq(&12i, &10i)); + assert!(!neq(&10i, &10i)); assert!(neq(&a, &b)); assert!(!neq(&a, &a)); } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 78e1e100bd6..9ec50d3f593 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -45,7 +45,7 @@ fn bar>(x: T) -> Vec { } pub fn main() { - assert_eq!(foo(vec!(1)), vec!("hi".to_string())); + assert_eq!(foo(vec!(1i)), vec!("hi".to_string())); assert_eq!(bar:: >(vec!(4, 5)), vec!("4".to_string(), "5".to_string())); assert_eq!(bar:: >(vec!("x".to_string(), "y".to_string())), vec!("x".to_string(), "y".to_string())); diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index 8cf83fdf2d0..3b61a85995f 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -16,7 +16,7 @@ pub trait NumExt: Num + NumCast + PartialEq + PartialOrd {} pub trait FloatExt: NumExt {} -fn greater_than_one(n: &T) -> bool { *n > NumCast::from(1).unwrap() } -fn greater_than_one_float(n: &T) -> bool { *n > NumCast::from(1).unwrap() } +fn greater_than_one(n: &T) -> bool { *n > NumCast::from(1i).unwrap() } +fn greater_than_one_float(n: &T) -> bool { *n > NumCast::from(1i).unwrap() } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index 51d889d1098..58709ab4c85 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -21,7 +21,7 @@ trait Num { pub trait NumExt: Num + NumCast { } fn greater_than_one(n: &T) -> bool { - n.gt(&NumCast::from(1).unwrap()) + n.gt(&NumCast::from(1i).unwrap()) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 379acf26c19..5a2e88631a6 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -14,7 +14,7 @@ pub trait NumExt: Num + NumCast + PartialOrd { } fn greater_than_one(n: &T) -> bool { - *n > NumCast::from(1).unwrap() + *n > NumCast::from(1i).unwrap() } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index fc17aa11340..415d0a04c8b 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -16,7 +16,7 @@ pub trait NumExt: PartialEq + PartialOrd + Num + NumCast {} impl NumExt for f32 {} fn num_eq_one(n: T) { - println!("{}", n == NumCast::from(1).unwrap()) + println!("{}", n == NumCast::from(1i).unwrap()) } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index 3a0605302a2..e3d631013c0 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -17,7 +17,7 @@ impl NumExt for f32 {} impl NumExt for int {} fn num_eq_one() -> T { - NumCast::from(1).unwrap() + NumCast::from(1i).unwrap() } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-visibility.rs b/src/test/run-pass/trait-inheritance-visibility.rs index 3cdedd884a4..dc84cbfb09a 100644 --- a/src/test/run-pass/trait-inheritance-visibility.rs +++ b/src/test/run-pass/trait-inheritance-visibility.rs @@ -24,5 +24,5 @@ fn f(x: &T) { } pub fn main() { - f(&0) + f(&0i) } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index cd7c5c6f8f7..54a21caafa0 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -30,15 +30,15 @@ fn to_string(&self) -> String { pub fn main() { assert!(1.to_string() == "1".to_string()); - assert!((vec!(2, 3, 4)).to_string() == "[2, 3, 4]".to_string()); + assert!((vec!(2i, 3, 4)).to_string() == "[2, 3, 4]".to_string()); fn indirect(x: T) -> String { format!("{}!", x.to_string()) } - assert!(indirect(vec!(10, 20)) == "[10, 20]!".to_string()); + assert!(indirect(vec!(10i, 20)) == "[10, 20]!".to_string()); fn indirect2(x: T) -> String { indirect(x) } - assert!(indirect2(vec!(1)) == "[1]!".to_string()); + assert!(indirect2(vec!(1i)) == "[1]!".to_string()); } diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs index 2b60cf12cc5..964d6ca317e 100644 --- a/src/test/run-pass/trivial-message.rs +++ b/src/test/run-pass/trivial-message.rs @@ -17,7 +17,7 @@ pub fn main() { let (tx, rx) = channel(); - tx.send(42); + tx.send(42i); let r = rx.recv(); println!("{:?}", r); } diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index b295701d186..fb5f6e4a8aa 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut i = box 1; + let mut i = box 1i; // Should be a copy let mut j; j = i.clone(); diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index 90e5e82f0d8..505e9b46e03 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -11,8 +11,8 @@ #![allow(dead_assignment)] pub fn main() { - let i = box 1; - let mut j = box 2; + let i = box 1i; + let mut j = box 2i; // Should drop the previous value of j j = i; assert_eq!(*j, 1); diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index da77921e5c3..9f98465ddee 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -18,8 +18,8 @@ fn f(t: T) -> T { } pub fn main() { - let t = f(box 100); - assert_eq!(t, box 100); - let t = f(box box(GC) vec!(100)); - assert_eq!(t, box box(GC) vec!(100)); + let t = f(box 100i); + assert_eq!(t, box 100i); + let t = f(box box(GC) vec!(100i)); + assert_eq!(t, box box(GC) vec!(100i)); } diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index d332e235809..64d65a7b2e5 100644 --- a/src/test/run-pass/unique-assign.rs +++ b/src/test/run-pass/unique-assign.rs @@ -10,6 +10,6 @@ pub fn main() { let mut i; - i = box 1; + i = box 1i; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index fc5bac249ba..ec328d65ac8 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -10,6 +10,6 @@ pub fn main() { - let i = box vec!(100); - assert_eq!(*i.get(0), 100); + let i = box vec!(100i); + assert_eq!(*i.get(0), 100i); } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index 037faee9599..38be635d837 100644 --- a/src/test/run-pass/unique-cmp.rs +++ b/src/test/run-pass/unique-cmp.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - let i = box 100; - assert!(i == box 100); - assert!(i < box 101); - assert!(i <= box 100); - assert!(i > box 99); - assert!(i >= box 99); + let i = box 100i; + assert!(i == box 100i); + assert!(i < box 101i); + assert!(i <= box 100i); + assert!(i > box 99i); + assert!(i >= box 99i); } diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index a5cb19ebad7..ddc2bb6c30f 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -9,11 +9,11 @@ // except according to those terms. pub fn main() { - let mut i = box 1; + let mut i = box 1i; // Should be a copy let mut j = i.clone(); - *i = 2; - *j = 3; - assert_eq!(*i, 2); - assert_eq!(*j, 3); + *i = 2i; + *j = 3i; + assert_eq!(*i, 2i); + assert_eq!(*j, 3i); } diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index 9cf28415481..1d98cfb6b4b 100644 --- a/src/test/run-pass/unique-decl-init.rs +++ b/src/test/run-pass/unique-decl-init.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = box 1; + let i = box 1i; let j = i; assert_eq!(*j, 1); } diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index d2e8f991d21..e2e7b2ec771 100644 --- a/src/test/run-pass/unique-decl-move.rs +++ b/src/test/run-pass/unique-decl-move.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = box 100; + let i = box 100i; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 346b7d0bfcc..37ca58913ab 100644 --- a/src/test/run-pass/unique-deref.rs +++ b/src/test/run-pass/unique-deref.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let i = box 100; + let i = box 100i; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-fn-arg-move.rs b/src/test/run-pass/unique-fn-arg-move.rs index 762c2c7ea0c..68290d85d0e 100644 --- a/src/test/run-pass/unique-fn-arg-move.rs +++ b/src/test/run-pass/unique-fn-arg-move.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn f(i: Box) { assert_eq!(*i, 100); } pub fn main() { - let i = box 100; + let i = box 100i; f(i); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index f1f6a29dd22..fda3c53bdf4 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -10,7 +10,7 @@ pub fn main() { - let mut a = vec!(box 10); + let mut a = vec!(box 10i); let b = a.clone(); assert_eq!(**a.get(0), 10); diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 9b2b66231e5..b7029ab38bc 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let vect = vec!(box 100); + let vect = vec!(box 100i); assert!(*vect.get(0) == box 100); } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 65a8314fe8e..d3f4a8b1090 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -20,11 +20,11 @@ fn g(i: T, j: T) { assert!(i != j); } - let i = box 100; - let j = box 100; + let i = box 100i; + let j = box 100i; f(i, j); - let i = box 100; - let j = box 101; + let i = box 100i; + let j = box 101i; g(i, j); } @@ -38,11 +38,11 @@ fn g(i: T, j: T) { assert!(i != j); } - let i = box 100; - let j = box 100; + let i = box 100i; + let j = box 100i; f(i, j); - let i = box 100; - let j = box 101; + let i = box 100i; + let j = box 101i; g(i, j); } @@ -56,11 +56,11 @@ fn g(i: T, j: T) { assert!(i != j); } - let i = box 100; - let j = box 100; + let i = box 100i; + let j = box 100i; f(i, j); - let i = box 100; - let j = box 101; + let i = box 100i; + let j = box 101i; g(i, j); } diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index 994e8df417d..108b0f43962 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -11,6 +11,6 @@ extern crate debug; pub fn main() { - let i = box 100; + let i = box 100i; println!("{:?}", i); } diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index 7ec0ce62329..1b6ef92865c 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -11,8 +11,8 @@ #![allow(unused_variable)] pub fn main() { - let i = box 100; - let j = box 200; + let i = box 100i; + let j = box 200i; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index 18cbbfa08df..1902fabe639 100644 --- a/src/test/run-pass/unique-move-temp.rs +++ b/src/test/run-pass/unique-move-temp.rs @@ -10,6 +10,6 @@ pub fn main() { let mut i; - i = box 100; + i = box 100i; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index 14f6077be7a..398db63ce08 100644 --- a/src/test/run-pass/unique-move.rs +++ b/src/test/run-pass/unique-move.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = box 100; + let i = box 100i; let mut j; j = i; assert_eq!(*j, 100); diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index 01a3ba6a3b4..eebb1705590 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut i = box 0; + let mut i = box 0i; *i = 1; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index 5d622f5cfe8..22b5a8cdaa4 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -10,7 +10,7 @@ pub fn main() { let (tx, rx) = channel(); - tx.send(box 100); + tx.send(box 100i); let v = rx.recv(); - assert_eq!(v, box 100); + assert_eq!(v, box 100i); } diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index 1299b28a67e..d467d042e4e 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -11,9 +11,9 @@ use std::mem::swap; pub fn main() { - let mut i = box 100; - let mut j = box 200; + let mut i = box 100i; + let mut j = box 200i; swap(&mut i, &mut j); - assert_eq!(i, box 200); - assert_eq!(j, box 100); + assert_eq!(i, box 200i); + assert_eq!(j, box 100i); } diff --git a/src/test/run-pass/use-uninit-match.rs b/src/test/run-pass/use-uninit-match.rs index a5659a4648e..7382d7a1acf 100644 --- a/src/test/run-pass/use-uninit-match.rs +++ b/src/test/run-pass/use-uninit-match.rs @@ -21,4 +21,4 @@ fn foo(o: myoption) -> int { enum myoption { none, some(T), } -pub fn main() { println!("{}", 5); } +pub fn main() { println!("{}", 5i); } diff --git a/src/test/run-pass/use-uninit-match2.rs b/src/test/run-pass/use-uninit-match2.rs index 9bf98baa303..b5d2b9ef84c 100644 --- a/src/test/run-pass/use-uninit-match2.rs +++ b/src/test/run-pass/use-uninit-match2.rs @@ -21,4 +21,4 @@ fn foo(o: myoption) -> int { enum myoption { none, some(T), } -pub fn main() { println!("{}", 5); } +pub fn main() { println!("{}", 5i); } diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index 6cd95f1af36..ee4b2061a5d 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -14,8 +14,8 @@ use std::num; pub fn main() { - let ε = 0.00001; - let Π = 3.14; + let ε = 0.00001f64; + let Π = 3.14f64; let लंच = Π * Π + 1.54; assert!(num::abs((लंच - 1.54) - (Π * Π)) < ε); assert_eq!(საჭმელად_გემრიელი_სადილი(), 0); @@ -25,25 +25,25 @@ fn საჭმელად_გემრიელი_სადილი() -> int // Lunch in several languages. - let ランチ = 10; - let 午餐 = 10; + let ランチ = 10i; + let 午餐 = 10i; - let ארוחת_צהריי = 10; - let غداء = 10; - let լանչ = 10; - let обед = 10; - let абед = 10; - let μεσημεριανό = 10; - let hádegismatur = 10; - let ручек = 10; + let ארוחת_צהריי = 10i; + let غداء = 10u; + let լանչ = 10i; + let обед = 10i; + let абед = 10i; + let μεσημεριανό = 10i; + let hádegismatur = 10i; + let ручек = 10i; - let ăn_trưa = 10; - let อาหารกลางวัน = 10; + let ăn_trưa = 10i; + let อาหารกลางวัน = 10i; // Lunchy arithmetic, mm. assert_eq!(hádegismatur * ручек * обед, 1000); - assert_eq!(10, ארוחת_צהריי); + assert_eq!(10i, ארוחת_צהריי); assert_eq!(ランチ + 午餐 + μεσημεριανό, 30); assert_eq!(ăn_trưa + อาหารกลางวัน, 20); return (абед + լանչ) >> غداء; diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index ba51c49fac2..08f9b3c176b 100644 --- a/src/test/run-pass/vec-growth.rs +++ b/src/test/run-pass/vec-growth.rs @@ -10,11 +10,11 @@ pub fn main() { - let mut v = vec!(1); - v.push(2); - v.push(3); - v.push(4); - v.push(5); + let mut v = vec!(1i); + v.push(2i); + v.push(3i); + v.push(4i); + v.push(5i); assert_eq!(*v.get(0), 1); assert_eq!(*v.get(1), 2); assert_eq!(*v.get(2), 3); diff --git a/src/test/run-pass/vec-macro-with-trailing-comma.rs b/src/test/run-pass/vec-macro-with-trailing-comma.rs index 07033d60497..80c2a5fe83e 100644 --- a/src/test/run-pass/vec-macro-with-trailing-comma.rs +++ b/src/test/run-pass/vec-macro-with-trailing-comma.rs @@ -10,6 +10,6 @@ pub fn main() { - assert_eq!(vec!(1), vec!(1,)); - assert_eq!(vec!(1, 2, 3), vec!(1, 2, 3,)); + assert_eq!(vec!(1i), vec!(1i,)); + assert_eq!(vec!(1i, 2, 3), vec!(1i, 2, 3,)); } diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index a318e0a75fb..9992c059ac4 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let x = [1, 2, 3]; + let x = [1i, 2, 3]; match x { [2, _, _] => fail!(), [1, a, b] => { @@ -18,7 +18,7 @@ pub fn main() { [_, _, _] => fail!(), } - let y = ([(1, true), (2, false)], 0.5); + let y = ([(1i, true), (2i, false)], 0.5f64); match y { ([(1, a), (b, false)], _) => { assert_eq!(a, true); diff --git a/src/test/run-pass/vec-matching-fixed.rs b/src/test/run-pass/vec-matching-fixed.rs index 17633f12ce5..3e9d4b9fc3a 100644 --- a/src/test/run-pass/vec-matching-fixed.rs +++ b/src/test/run-pass/vec-matching-fixed.rs @@ -9,7 +9,7 @@ // except according to those terms. fn a() { - let x = [1, 2, 3]; + let x = [1i, 2, 3]; match x { [1, 2, 4] => unreachable!(), [0, 2, 3, ..] => unreachable!(), diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 5ba42b68f27..07ee5f535e9 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -31,11 +31,11 @@ fn foldr(values: &[T], } pub fn main() { - let x = [1, 2, 3, 4, 5]; + let x = [1i, 2, 3, 4, 5]; - let product = foldl(x, 1, |a, b| a * *b); + let product = foldl(x, 1i, |a, b| a * *b); assert_eq!(product, 120); - let sum = foldr(x, 0, |a, b| *a + b); + let sum = foldr(x, 0i, |a, b| *a + b); assert_eq!(sum, 15); } diff --git a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs index fbdcc1ab69c..c070e5dab77 100644 --- a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs +++ b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let x = &[1, 2, 3, 4, 5]; + let x = &[1i, 2, 3, 4, 5]; if !x.is_empty() { let el = match x { [1, ..ref tail] => &tail[0], diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 11143ba0c84..ac869a10d2e 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -9,7 +9,7 @@ // except according to those terms. fn a() { - let x = [1]; + let x = [1i]; match x { [a] => { assert_eq!(a, 1); @@ -18,7 +18,7 @@ fn a() { } fn b() { - let x = [1, 2, 3]; + let x = [1i, 2, 3]; match x { [a, b, ..c] => { assert_eq!(a, 1); @@ -50,7 +50,7 @@ fn b() { } fn c() { - let x = [1]; + let x = [1i]; match x { [2, ..] => fail!(), [..] => () @@ -58,11 +58,11 @@ fn c() { } fn d() { - let x = [1, 2, 3]; + let x = [1i, 2, 3]; let branch = match x { - [1, 1, ..] => 0, - [1, 2, 3, ..] => 1, - [1, 2, ..] => 2, + [1, 1, ..] => 0i, + [1, 2, 3, ..] => 1i, + [1, 2, ..] => 2i, _ => 3 }; assert_eq!(branch, 1); diff --git a/src/test/run-pass/vec-slice.rs b/src/test/run-pass/vec-slice.rs index 946b6a469da..b0799e49447 100644 --- a/src/test/run-pass/vec-slice.rs +++ b/src/test/run-pass/vec-slice.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let v = vec!(1,2,3,4,5); + let v = vec!(1i,2,3,4,5); let v2 = v.slice(1, 3); assert_eq!(v2[0], 2); assert_eq!(v2[1], 3); diff --git a/src/test/run-pass/vec-to_str.rs b/src/test/run-pass/vec-to_str.rs index 2eadd2fc3c8..4d9f80cec6a 100644 --- a/src/test/run-pass/vec-to_str.rs +++ b/src/test/run-pass/vec-to_str.rs @@ -9,11 +9,11 @@ // except according to those terms. pub fn main() { - assert_eq!((vec!(0, 1)).to_str(), "[0, 1]".to_string()); - assert_eq!((&[1, 2]).to_str(), "[1, 2]".to_string()); + assert_eq!((vec!(0i, 1)).to_str(), "[0, 1]".to_string()); + assert_eq!((&[1i, 2]).to_str(), "[1, 2]".to_string()); - let foo = vec!(3, 4); - let bar = &[4, 5]; + let foo = vec!(3i, 4); + let bar = &[4i, 5]; assert_eq!(foo.to_str(), "[3, 4]".to_string()); assert_eq!(bar.to_str(), "[4, 5]".to_string()); diff --git a/src/test/run-pass/vector-sort-failure-safe.rs b/src/test/run-pass/vector-sort-failure-safe.rs index 2575e53b6a3..542f4dbdf23 100644 --- a/src/test/run-pass/vector-sort-failure-safe.rs +++ b/src/test/run-pass/vector-sort-failure-safe.rs @@ -43,7 +43,7 @@ fn drop(&mut self) { pub fn main() { // len can't go above 64. for len in range(2u, MAX_LEN) { - for _ in range(0, 10) { + for _ in range(0i, 10) { let main = task_rng().gen_iter::() .take(len) .collect::>(); @@ -54,7 +54,7 @@ pub fn main() { main.clone().as_mut_slice().sort_by(|a, b| { count += 1; a.cmp(b) }); // ... and then fail on each and every single one. - for fail_countdown in range(0, count) { + for fail_countdown in range(0i, count) { // refresh the counters. unsafe { drop_counts = [0, .. MAX_LEN]; diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 1eb34f9df25..61578578ab6 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -67,7 +67,7 @@ fn canttouchthis() -> uint { 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!("{}", 0i) == (return 0u)); } fn angrydome() { diff --git a/src/test/run-pass/while-cont.rs b/src/test/run-pass/while-cont.rs index 3e1a232115f..50feb3ef4e1 100644 --- a/src/test/run-pass/while-cont.rs +++ b/src/test/run-pass/while-cont.rs @@ -10,7 +10,7 @@ // Issue #825: Should recheck the loop condition after continuing pub fn main() { - let mut i = 1; + let mut i = 1i; while i > 0 { assert!((i > 0)); println!("{}", i);