librustc: Remove the fallback to int for integers and f64 for

floating point numbers for real.

This will break code that looks like:

    let mut x = 0;
    while ... {
        x += 1;
    }
    println!("{}", x);

Change that code to:

    let mut x = 0i;
    while ... {
        x += 1;
    }
    println!("{}", x);

Closes #15201.

[breaking-change]
This commit is contained in:
Patrick Walton 2014-06-27 12:30:25 -07:00
parent bd9563aa38
commit a5bb0a3a45
338 changed files with 1148 additions and 1146 deletions

View File

@ -267,12 +267,12 @@ impl<T: Send> Drop for Unique<T> {
// A comparison between the built-in `Box` and this reimplementation
fn main() {
{
let mut x = box 5;
let mut x = box 5i;
*x = 10;
} // `x` is freed here
{
let mut y = Unique::new(5);
let mut y = Unique::new(5i);
*y.borrow_mut() = 10;
} // `y` is freed here
}
@ -678,7 +678,7 @@ unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
#[start]
fn main(argc: int, argv: *const *const u8) -> int {
let x = box 1;
let x = box 1i;
0
}

View File

@ -133,7 +133,7 @@ Check it out:
```
fn dangling() -> Box<int> {
let i = box 1234;
let i = box 1234i;
return i;
}
@ -143,8 +143,8 @@ fn add_one() -> int {
}
```
Now instead of a stack allocated `1234`,
we have a heap allocated `box 1234`.
Now instead of a stack allocated `1234i`,
we have a heap allocated `box 1234i`.
Whereas `&` borrows a pointer to existing memory,
creating an owned box allocates memory on the heap and places a value in it,
giving you the sole pointer to that memory.
@ -152,7 +152,7 @@ You can roughly compare these two lines:
```
// Rust
let i = box 1234;
let i = box 1234i;
```
```cpp

View File

@ -442,17 +442,14 @@ of integer literal suffix:
The type of an _unsuffixed_ integer literal is determined by type inference.
If an integer type can be _uniquely_ determined from the surrounding program
context, the unsuffixed integer literal has that type. If the program context
underconstrains the type, the unsuffixed integer literal's type is `int`; if
the program context overconstrains the type, it is considered a static type
error.
underconstrains the type, it is considered a static type error;
if the program context overconstrains the type,
it is also considered a static type error.
Examples of integer literals of various forms:
~~~~
123; 0xff00; // type determined by program context
// defaults to int in absence of type
// information
123i; // type int
123u; // type uint
123_u; // type uint
0xff_u8; // type u8
@ -469,8 +466,10 @@ A _floating-point literal_ has one of two forms:
second decimal literal.
* A single _decimal literal_ followed by an _exponent_.
By default, a floating-point literal has a generic type, but will fall back to
`f64`. A floating-point literal may be followed (immediately, without any
By default, a floating-point literal has a generic type,
and, like integer literals, the type must be uniquely determined
from the context.
A floating-point literal may be followed (immediately, without any
spaces) by a _floating-point suffix_, which changes the type of the literal.
There are two floating-point suffixes: `f32`, and `f64` (the 32-bit and 64-bit
floating point types).
@ -478,8 +477,8 @@ floating point types).
Examples of floating-point literals of various forms:
~~~~
123.0; // type f64
0.1; // type f64
123.0f64; // type f64
0.1f64; // type f64
0.1f32; // type f32
12E+99_f64; // type f64
~~~~
@ -2700,9 +2699,9 @@ must be a constant expression that can be evaluated at compile time, such
as a [literal](#literals) or a [static item](#static-items).
~~~~
[1, 2, 3, 4];
[1i, 2, 3, 4];
["a", "b", "c", "d"];
[0, ..128]; // vector with 128 zeros
[0i, ..128]; // vector with 128 zeros
[0u8, 0u8, 0u8, 0u8];
~~~~
@ -2881,7 +2880,7 @@ equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
Evaluating an assignment expression [either copies or moves](#moved-and-copied-types) its right-hand operand to its left-hand operand.
~~~~
# let mut x = 0;
# let mut x = 0i;
# let y = 0;
x = y;
@ -2932,7 +2931,7 @@ paren_expr : '(' expr ')' ;
An example of a parenthesized expression:
~~~~
let x = (2 + 3) * 4;
let x: int = (2 + 3) * 4;
~~~~
@ -3016,7 +3015,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
An example:
~~~~
let mut i = 0;
let mut i = 0u;
while i < 10 {
println!("hello");
@ -3262,7 +3261,7 @@ Patterns can also dereference pointers by using the `&`,
on `x: &int` are equivalent:
~~~~
# let x = &3;
# let x = &3i;
let y = match *x { 0 => "zero", _ => "some" };
let z = match x { &0 => "zero", _ => "some" };
@ -3285,7 +3284,7 @@ A range of values may be specified with `..`.
For example:
~~~~
# let x = 2;
# let x = 2i;
let message = match x {
0 | 1 => "not many",

View File

@ -262,7 +262,7 @@ write function, variable, and module names with lowercase letters, using
underscores where they help readability, while writing types in camel case.
~~~
let my_variable = 100;
let my_variable = 100i;
type MyType = int; // primitive types are _not_ camel case
~~~
@ -276,7 +276,7 @@ write a piece of code like this:
~~~~
# let item = "salad";
let price;
let price: f64;
if item == "salad" {
price = 3.50;
} else if item == "muffin" {
@ -290,7 +290,7 @@ But, in Rust, you don't have to repeat the name `price`:
~~~~
# let item = "salad";
let price =
let price: f64 =
if item == "salad" {
3.50
} else if item == "muffin" {
@ -337,11 +337,10 @@ suffix that can be used to indicate the type of a literal: `i` for `int`,
In the absence of an integer literal suffix, Rust will infer the
integer type based on type annotations and function signatures in the
surrounding program. In the absence of any type information at all,
Rust will assume that an unsuffixed integer literal has type
`int`.
Rust will report an error and request that the type be specified explicitly.
~~~~
let a = 1; // `a` is an `int`
let a: int = 1; // `a` is an `int`
let b = 10i; // `b` is an `int`, due to the `i` suffix
let c = 100u; // `c` is a `uint`
let d = 1000i32; // `d` is an `i32`
@ -475,7 +474,7 @@ against each pattern in order until one matches. The matching pattern
executes its corresponding arm.
~~~~
let my_number = 1;
let my_number = 1i;
match my_number {
0 => println!("zero"),
1 | 2 => println!("one or two"),
@ -501,7 +500,7 @@ matches any single value. (`..`) is a different wildcard that can match
one or more fields in an `enum` variant.
~~~
# let my_number = 1;
# let my_number = 1i;
match my_number {
0 => { println!("zero") }
_ => { println!("something else") }
@ -584,7 +583,7 @@ keyword `break` aborts the loop, and `continue` aborts the current
iteration and continues with the next.
~~~~
let mut cake_amount = 8;
let mut cake_amount = 8i;
while cake_amount > 0 {
cake_amount -= 1;
}
@ -944,7 +943,7 @@ The `box` operator performs memory allocation on the heap:
~~~~
{
// an integer allocated on the heap
let y = box 10;
let y = box 10i;
}
// the destructor frees the heap memory as soon as `y` goes out of scope
~~~~
@ -1165,7 +1164,7 @@ let z = x;
The mutability of a value may be changed by moving it to a new owner:
~~~~
let r = box 13;
let r = box 13i;
let mut s = r; // box becomes mutable
*s += 1;
let t = s; // box becomes immutable
@ -1285,9 +1284,9 @@ Using the generic `List<T>` works much like before, thanks to type inference:
# Cons(value, box xs)
# }
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
xs = prepend(xs, 15);
xs = prepend(xs, 20);
xs = prepend(xs, 10i); // Here the compiler infers `xs`'s type as `List<int>`.
xs = prepend(xs, 15i);
xs = prepend(xs, 20i);
~~~
The code sample above demonstrates type inference making most type annotations optional. It is
@ -1410,12 +1409,12 @@ Beyond the properties granted by the size, an owned box behaves as a regular
value by inheriting the mutability and lifetime of the owner:
~~~~
let x = 5; // immutable
let mut y = 5; // mutable
let x = 5i; // immutable
let mut y = 5i; // mutable
y += 2;
let x = box 5; // immutable
let mut y = box 5; // mutable
let x = box 5i; // immutable
let mut y = box 5i; // mutable
*y += 2; // the `*` operator is needed to access the contained value
~~~~
@ -1507,7 +1506,7 @@ freezing enforced statically at compile-time. An example of a non-`Freeze` type
is [`RefCell<T>`][refcell].
~~~~
let mut x = 5;
let mut x = 5i;
{
let y = &x; // `x` is now frozen. It cannot be modified or re-assigned.
}
@ -1523,8 +1522,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
box or pointer, similarly to C.
~~~
let owned = box 10;
let borrowed = &20;
let owned = box 10i;
let borrowed = &20i;
let sum = *owned + *borrowed;
~~~
@ -1534,9 +1533,9 @@ assignments. Such an assignment modifies the value that the pointer
points to.
~~~
let mut owned = box 10;
let mut owned = box 10i;
let mut value = 20;
let mut value = 20i;
let borrowed = &mut value;
*owned = *borrowed + 100;
@ -1654,12 +1653,12 @@ Unicode code points, so they cannot be freely mutated without the ability to
alter the length.
~~~
let mut xs = [1, 2, 3];
let mut xs = [1i, 2i, 3i];
let view = xs.mut_slice(0, 2);
view[0] = 5;
// The type of a mutable slice is written as `&mut [T]`
let ys: &mut [int] = &mut [1, 2, 3];
let ys: &mut [int] = &mut [1i, 2i, 3i];
~~~
Square brackets denote indexing into a slice or fixed-size vector:

View File

@ -376,14 +376,14 @@ mod tests {
#[test]
fn test_live() {
let x = Arc::new(5);
let x = Arc::new(5i);
let y = x.downgrade();
assert!(y.upgrade().is_some());
}
#[test]
fn test_dead() {
let x = Arc::new(5);
let x = Arc::new(5i);
let y = x.downgrade();
drop(x);
assert!(y.upgrade().is_none());

View File

@ -329,7 +329,7 @@ mod bench {
#[bench]
fn alloc_owned_small(b: &mut Bencher) {
b.iter(|| {
box 10
box 10i
})
}
}

View File

@ -342,12 +342,12 @@ mod tests {
assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
unsafe {
let ptr: *const int = mem::transmute(5);
let ptr: *const int = mem::transmute(5i);
assert_eq!(hasher.hash(&ptr), 5);
}
unsafe {
let ptr: *mut int = mem::transmute(5);
let ptr: *mut int = mem::transmute(5i);
assert_eq!(hasher.hash(&ptr), 5);
}
}

View File

@ -572,7 +572,7 @@ mod tests {
fn bench_push_back(b: &mut test::Bencher) {
let mut deq = RingBuf::new();
b.iter(|| {
deq.push_back(0);
deq.push_back(0i);
})
}
@ -580,7 +580,7 @@ mod tests {
fn bench_push_front(b: &mut test::Bencher) {
let mut deq = RingBuf::new();
b.iter(|| {
deq.push_front(0);
deq.push_front(0i);
})
}
@ -589,7 +589,7 @@ mod tests {
let mut deq = RingBuf::new();
b.iter(|| {
for _ in range(0i, 65) {
deq.push_front(1);
deq.push_front(1i);
}
})
}
@ -651,10 +651,10 @@ mod tests {
#[test]
fn test_with_capacity() {
let mut d = RingBuf::with_capacity(0);
d.push_back(1);
d.push_back(1i);
assert_eq!(d.len(), 1);
let mut d = RingBuf::with_capacity(50);
d.push_back(1);
d.push_back(1i);
assert_eq!(d.len(), 1);
}

View File

@ -17,7 +17,7 @@ Vectors are Rust's list type. Vectors contain zero or more values of
homogeneous types:
```rust
let int_vector = [1,2,3];
let int_vector = [1i, 2i, 3i];
let str_vector = ["one", "two", "three"];
```
@ -41,9 +41,9 @@ An example is the method `.slice(a, b)` that returns an immutable "view" into
a vector or a vector slice from the index interval `[a, b)`:
```rust
let numbers = [0, 1, 2];
let numbers = [0i, 1i, 2i];
let last_numbers = numbers.slice(1, 3);
// last_numbers is now &[1, 2]
// last_numbers is now &[1i, 2i]
```
Traits defined for the `~[T]` type, like `OwnedVector`, can only be called
@ -54,9 +54,9 @@ An example is the method `.push(element)` that will add an element at the end
of the vector:
```rust
let mut numbers = vec![0, 1, 2];
let mut numbers = vec![0i, 1i, 2i];
numbers.push(7);
// numbers is now vec![0, 1, 2, 7];
// numbers is now vec![0i, 1i, 2i, 7i];
```
## Implementations of other traits
@ -779,7 +779,7 @@ mod tests {
fn test_is_empty() {
let xs: [int, ..0] = [];
assert!(xs.is_empty());
assert!(![0].is_empty());
assert!(![0i].is_empty());
}
#[test]
@ -1528,7 +1528,7 @@ mod tests {
fn test_permute_fail() {
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;
let mut i = 0u;
for _ in v.permutations() {
if i == 2 {
fail!()
@ -1870,16 +1870,16 @@ mod tests {
fn test_overflow_does_not_cause_segfault() {
let mut v = vec![];
v.reserve_exact(-1);
v.push(1);
v.push(1i);
v.push(2);
}
#[test]
#[should_fail]
fn test_overflow_does_not_cause_segfault_managed() {
let mut v = vec![Rc::new(1)];
let mut v = vec![Rc::new(1i)];
v.reserve_exact(-1);
v.push(Rc::new(2));
v.push(Rc::new(2i));
}
#[test]
@ -2279,7 +2279,7 @@ mod bench {
v.set_len(1024);
}
for x in v.mut_iter() {
*x = 0;
*x = 0i;
}
v
});

View File

@ -1103,7 +1103,7 @@ mod tests {
assert_eq!("bc", unsafe {raw::slice_bytes("abc", 1, 3)});
assert_eq!("", unsafe {raw::slice_bytes("abc", 1, 1)});
fn a_million_letter_a() -> String {
let mut i = 0;
let mut i = 0u;
let mut rs = String::new();
while i < 100000 {
rs.push_str("aaaaaaaaaa");
@ -1112,7 +1112,7 @@ mod tests {
rs
}
fn half_a_million_letter_a() -> String {
let mut i = 0;
let mut i = 0u;
let mut rs = String::new();
while i < 100000 {
rs.push_str("aaaaa");
@ -1220,7 +1220,7 @@ mod tests {
assert_eq!("", data.slice(30, 33));
fn a_million_letter_x() -> String {
let mut i = 0;
let mut i = 0u;
let mut rs = String::new();
while i < 100000 {
rs.push_str("华华华华华华华华华华");
@ -1229,7 +1229,7 @@ mod tests {
rs
}
fn half_a_million_letter_x() -> String {
let mut i = 0;
let mut i = 0u;
let mut rs = String::new();
while i < 100000 {
rs.push_str("华华华华华");

View File

@ -67,10 +67,10 @@
//!
//! fn main() {
//! let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
//! shared_map.borrow_mut().insert("africa", 92388);
//! shared_map.borrow_mut().insert("kyoto", 11837);
//! shared_map.borrow_mut().insert("piccadilly", 11826);
//! shared_map.borrow_mut().insert("marbles", 38);
//! shared_map.borrow_mut().insert("africa", 92388i);
//! shared_map.borrow_mut().insert("kyoto", 11837i);
//! shared_map.borrow_mut().insert("piccadilly", 11826i);
//! shared_map.borrow_mut().insert("marbles", 38i);
//! }
//! ```
//!
@ -433,35 +433,35 @@ mod test {
#[test]
fn double_imm_borrow() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b1 = x.borrow();
x.borrow();
}
#[test]
fn no_mut_then_imm_borrow() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b1 = x.borrow_mut();
assert!(x.try_borrow().is_none());
}
#[test]
fn no_imm_then_borrow_mut() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b1 = x.borrow();
assert!(x.try_borrow_mut().is_none());
}
#[test]
fn no_double_borrow_mut() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b1 = x.borrow_mut();
assert!(x.try_borrow_mut().is_none());
}
#[test]
fn imm_release_borrow_mut() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
{
let _b1 = x.borrow();
}
@ -470,7 +470,7 @@ mod test {
#[test]
fn mut_release_borrow_mut() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
{
let _b1 = x.borrow_mut();
}
@ -479,7 +479,7 @@ mod test {
#[test]
fn double_borrow_single_release_no_borrow_mut() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b1 = x.borrow();
{
let _b2 = x.borrow();
@ -490,7 +490,7 @@ mod test {
#[test]
#[should_fail]
fn discard_doesnt_unborrow() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
let _b = x.borrow();
let _ = _b;
let _b = x.borrow_mut();
@ -499,7 +499,7 @@ mod test {
#[test]
#[allow(experimental)]
fn clone_ref_updates_flag() {
let x = RefCell::new(0);
let x = RefCell::new(0i);
{
let b1 = x.borrow();
assert!(x.try_borrow_mut().is_none());

View File

@ -86,11 +86,11 @@ pub trait Eq: PartialEq {
#[deriving(Clone, PartialEq, Show)]
pub enum Ordering {
/// An ordering where a compared value is less [than another].
Less = -1,
Less = -1i,
/// An ordering where a compared value is equal [to another].
Equal = 0,
Equal = 0i,
/// An ordering where a compared value is greater [than another].
Greater = 1
Greater = 1i,
}
/// Trait for types that form a [total order](

View File

@ -686,7 +686,7 @@ macro_rules! tuple (
fn fmt(&self, f: &mut Formatter) -> Result {
try!(write!(f, "("));
let ($(ref $name,)*) = *self;
let mut n = 0;
let mut n = 0i;
$(
if n > 0 {
try!(write!(f, ", "));

View File

@ -388,7 +388,7 @@ mod tests {
#[test]
#[should_fail]
fn test_radix_base_too_large() {
let _ = radix(55, 37);
let _ = radix(55i, 37);
}
}

View File

@ -2649,10 +2649,10 @@ mod tests {
assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));
assert_eq!(c.chain(vi.map(|&i| i)).size_hint(), (uint::MAX, None));
assert_eq!(c.zip(vi).size_hint(), (10, Some(10)));
assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None));
assert_eq!(c.scan(0i, |_,_| Some(0i)).size_hint(), (0, None));
assert_eq!(c.filter(|_| false).size_hint(), (0, None));
assert_eq!(c.map(|_| 0).size_hint(), (uint::MAX, None));
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
assert_eq!(c.map(|_| 0i).size_hint(), (uint::MAX, None));
assert_eq!(c.filter_map(|_| Some(0i)).size_hint(), (0, None));
assert_eq!(vi.take(5).size_hint(), (5, Some(5)));
assert_eq!(vi.take(12).size_hint(), (10, Some(10)));
@ -2663,10 +2663,10 @@ mod tests {
assert_eq!(vi.enumerate().size_hint(), (10, Some(10)));
assert_eq!(vi.chain(v2.iter()).size_hint(), (13, Some(13)));
assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
assert_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10)));
assert_eq!(vi.scan(0i, |_,_| Some(0i)).size_hint(), (0, Some(10)));
assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
assert_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10)));
assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10)));
assert_eq!(vi.filter_map(|_| Some(0i)).size_hint(), (0, Some(10)));
}
#[test]

View File

@ -475,7 +475,7 @@ mod tests {
#[test]
fn test_transmute_copy() {
assert_eq!(1u, unsafe { ::mem::transmute_copy(&1) });
assert_eq!(1u, unsafe { ::mem::transmute_copy(&1i) });
}
#[test]
@ -541,7 +541,7 @@ mod bench {
#[bench]
fn match_option_some(b: &mut Bencher) {
let x = Some(10);
let x = Some(10i);
b.iter(|| {
match x {
Some(y) => y,
@ -552,11 +552,11 @@ mod bench {
#[bench]
fn match_vec_pattern(b: &mut Bencher) {
let x = [1,2,3,4,5,6];
let x = [1i,2,3,4,5,6];
b.iter(|| {
match x {
[1,2,3,..] => 10,
_ => 11
[1,2,3,..] => 10i,
_ => 11i,
}
});
}

View File

@ -627,7 +627,7 @@ mod tests {
#[test]
fn test_get_ptr() {
unsafe {
let x = box 0;
let x = box 0i;
let addr_x: *const int = ::mem::transmute(&*x);
let opt = Some(x);
let y = opt.unwrap();
@ -750,7 +750,7 @@ mod tests {
#[test]
fn test_option_while_some() {
let mut i = 0i;
Some(10).while_some(|j| {
Some(10i).while_some(|j| {
i += 1;
if j > 0 {
Some(j-1)

View File

@ -588,22 +588,22 @@ fn test_repr() {
assert_eq!(s.as_slice(), e);
}
exact_test(&10, "10");
exact_test(&10i, "10");
exact_test(&true, "true");
exact_test(&false, "false");
exact_test(&1.234, "1.234f64");
exact_test(&1.234f64, "1.234f64");
exact_test(&("hello"), "\"hello\"");
exact_test(&(box(GC) 10), "box(GC) 10");
exact_test(&(box 10), "box 10");
exact_test(&(&10), "&10");
let mut x = 10;
exact_test(&(box(GC) 10i), "box(GC) 10");
exact_test(&(box 10i), "box 10");
exact_test(&(&10i), "&10");
let mut x = 10i;
exact_test(&(&mut x), "&mut 10");
exact_test(&(0 as *const ()), "(0x0 as *const ())");
exact_test(&(0 as *mut ()), "(0x0 as *mut ())");
exact_test(&(0i as *const()), "(0x0 as *const ())");
exact_test(&(0i as *mut ()), "(0x0 as *mut ())");
exact_test(&(1,), "(1,)");
exact_test(&(1i,), "(1,)");
exact_test(&(&["hi", "there"]),
"&[\"hi\", \"there\"]");
exact_test(&(P{a:10, b:1.234}),
@ -613,8 +613,8 @@ fn test_repr() {
exact_test(&(box P{a:10, b:1.234}),
"box repr::P{a: 10, b: 1.234f64}");
exact_test(&(&[1, 2]), "&[1, 2]");
exact_test(&(&mut [1, 2]), "&mut [1, 2]");
exact_test(&(&[1i, 2i]), "&[1, 2]");
exact_test(&(&mut [1i, 2i]), "&mut [1, 2]");
exact_test(&'\'', "'\\''");
exact_test(&'"', "'\"'");

View File

@ -1413,7 +1413,7 @@ mod test {
impl Drop for S {
fn drop(&mut self) {
let _foo = box 0;
let _foo = box 0i;
}
}

View File

@ -77,12 +77,12 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, String)> {
if chars.next() != Some('x') {
return Some((i, "Expected 'x'".to_string()));
} i+=1;
let mut d_len = 0;
let mut d_len = 0i;
for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; d_len += 1;}
if chars.next() != Some('.') {
return Some((i, "Expected '.'".to_string()));
} i+=1;
let mut f_len = 0;
let mut f_len = 0i;
for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; f_len += 1;}
if d_len == 0 && f_len == 0 {
return Some((i, "Expected digits before or after decimal \
@ -92,7 +92,7 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, String)> {
return Some((i, "Expected 'p'".to_string()));
} i+=1;
if chars.peek() == Some(&'-') { chars.next(); i+= 1 }
let mut e_len = 0;
let mut e_len = 0i;
for _ in chars.take_while(|c| c.is_digit()) { chars.next(); i+=1; e_len += 1}
if e_len == 0 {
return Some((i, "Expected exponent digits".to_string()));

View File

@ -1136,7 +1136,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
// which will wake up the other end at some point, so we just allow this
// signal to be coalesced with the pending signals on the pipe.
extern fn sigchld_handler(_signum: libc::c_int) {
let msg = 1;
let msg = 1i;
match unsafe {
libc::write(WRITE_FD, &msg as *const _ as *const libc::c_void, 1)
} {

View File

@ -215,7 +215,7 @@ impl Sub<BigUint, BigUint> for BigUint {
let zeros = ZERO_VEC.iter().cycle();
let (a, b) = (self.data.iter().chain(zeros.clone()), other.data.iter().chain(zeros));
let mut borrow = 0;
let mut borrow = 0i;
let diff: Vec<BigDigit> = a.take(new_len).zip(b).map(|(ai, bi)| {
let (hi, lo) = BigDigit::from_doublebigdigit(
BigDigit::base

View File

@ -389,10 +389,10 @@ impl Isaac64Rng {
}
}}
);
rngstepp!(0, 21);
rngstepn!(1, 5);
rngstepp!(2, 12);
rngstepn!(3, 33);
rngstepp!(0u, 21);
rngstepn!(1u, 5);
rngstepp!(2u, 12);
rngstepn!(3u, 33);
}
}

View File

@ -111,7 +111,7 @@ pub trait Rng {
// (3) adds more `unsafe` that needs to be checked, (4)
// probably doesn't give much performance gain if
// optimisations are on.
let mut count = 0;
let mut count = 0i;
let mut num = 0;
for byte in dest.mut_iter() {
if count == 0 {

View File

@ -770,7 +770,7 @@ impl<'a> Parser<'a> {
}
let start = self.chari;
let mut flags = self.flags;
let mut sign = 1;
let mut sign = 1i;
let mut saw_flag = false;
loop {
try!(self.noteof("expected non-empty set of flags or closing ')'"))

View File

@ -391,8 +391,8 @@ pub struct HeapMemory;
impl HeapMemory {
fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) {
let mut n_box = 0;
let mut n_uniq = 0;
let mut n_box = 0i;
let mut n_uniq = 0i;
ty::fold_ty(cx.tcx, ty, |t| {
match ty::get(t).sty {
ty::ty_box(_) => {

View File

@ -90,7 +90,7 @@ impl<'a> SpanUtils<'a> {
let mut result = None;
let mut toks = self.retokenise_span(span);
let mut bracket_count = 0;
let mut bracket_count = 0u;
loop {
let ts = toks.next_token();
if ts.tok == token::EOF {
@ -113,7 +113,7 @@ impl<'a> SpanUtils<'a> {
// Return the span for the first identifier in the path.
pub fn span_for_first_ident(&self, span: Span) -> Option<Span> {
let mut toks = self.retokenise_span(span);
let mut bracket_count = 0;
let mut bracket_count = 0u;
loop {
let ts = toks.next_token();
if ts.tok == token::EOF {
@ -139,7 +139,7 @@ impl<'a> SpanUtils<'a> {
let mut toks = self.retokenise_span(span);
let mut prev = toks.next_token();
let mut result = None;
let mut bracket_count = 0;
let mut bracket_count = 0u;
let mut last_span = None;
while prev.tok != token::EOF {
last_span = None;
@ -187,7 +187,7 @@ impl<'a> SpanUtils<'a> {
let mut toks = self.retokenise_span(span);
let mut prev = toks.next_token();
let mut result = None;
let mut bracket_count = 0;
let mut bracket_count = 0u;
loop {
let next = toks.next_token();
@ -232,7 +232,7 @@ impl<'a> SpanUtils<'a> {
let mut toks = self.retokenise_span(span);
// We keep track of how many brackets we're nested in
let mut bracket_count = 0;
let mut bracket_count = 0i;
loop {
let ts = toks.next_token();
if ts.tok == token::EOF {
@ -291,7 +291,7 @@ impl<'a> SpanUtils<'a> {
let mut next = toks.next_token();
let mut stored_val = false;
let mut found_val = false;
let mut bracket_count = 0;
let mut bracket_count = 0u;
while next.tok != token::EOF {
if bracket_count == 1 {
if next.tok == tok2 {

View File

@ -957,7 +957,11 @@ pub fn lltype_for_foreign_fn(ccx: &CrateContext, ty: ty::t) -> Type {
fn add_argument_attributes(tys: &ForeignTypes,
llfn: ValueRef) {
let mut i = if tys.fn_ty.ret_ty.is_indirect() { 1 } else { 0 };
let mut i = if tys.fn_ty.ret_ty.is_indirect() {
1i
} else {
0i
};
match tys.fn_ty.ret_ty.attr {
Some(attr) => unsafe {

View File

@ -3805,7 +3805,15 @@ pub fn check_enum_variants(ccx: &CrateCtxt,
let inh = blank_inherited_fields(ccx);
let fcx = blank_fn_ctxt(ccx, &inh, rty, e.id);
let declty = ty::mk_int_var(ccx.tcx, fcx.infcx().next_int_var_id());
let declty = match hint {
attr::ReprAny | attr::ReprExtern => ty::mk_int(),
attr::ReprInt(_, attr::SignedInt(ity)) => {
ty::mk_mach_int(ity)
}
attr::ReprInt(_, attr::UnsignedInt(ity)) => {
ty::mk_mach_uint(ity)
}
};
check_const_with_ty(&fcx, e.span, &*e, declty);
// check_expr (from check_const pass) doesn't guarantee
// that the expression is in a form that eval_const_expr can

View File

@ -247,9 +247,13 @@ 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_int_ty(_) => {
"cannot determine the type of this integer; add a suffix to \
specify the type explicitly".to_string()
}
unresolved_float_ty(_) => {
"unconstrained floating point type".to_string()
"cannot determine the type of this number; add a suffix to specify \
the type explicitly".to_string()
}
unresolved_ty(_) => "unconstrained type".to_string(),
cyclic_ty(_) => "cyclic type of infinite size".to_string(),

View File

@ -52,14 +52,12 @@ use middle::ty::{type_is_bot, IntType, UintType};
use middle::ty;
use middle::ty_fold;
use middle::typeck::infer::{Bounds, cyclic_ty, fixup_err, fres, InferCtxt};
use middle::typeck::infer::unresolved_ty;
use middle::typeck::infer::unify::Root;
use middle::typeck::infer::{unresolved_float_ty, unresolved_int_ty};
use middle::typeck::infer::{unresolved_ty};
use syntax::codemap::Span;
use util::common::indent;
use util::ppaux::{Repr, ty_to_str};
use syntax::ast;
pub static resolve_nested_tvar: uint = 0b0000000001;
pub static resolve_rvar: uint = 0b0000000010;
pub static resolve_ivar: uint = 0b0000000100;
@ -83,21 +81,18 @@ pub struct ResolveState<'a> {
err: Option<fixup_err>,
v_seen: Vec<TyVid> ,
type_depth: uint,
span: Option<Span>,
}
pub fn resolver<'a>(infcx: &'a InferCtxt,
modes: uint,
span: Option<Span>)
-> ResolveState<'a>
{
_: Option<Span>)
-> ResolveState<'a> {
ResolveState {
infcx: infcx,
modes: modes,
err: None,
v_seen: Vec::new(),
type_depth: 0,
span: span
}
}
@ -258,27 +253,13 @@ impl<'a> ResolveState<'a> {
Some(UintType(t)) => ty::mk_mach_uint(t),
None => {
if self.should(force_ivar) {
// 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");
// As a last resort, emit an error.
self.err = Some(unresolved_int_ty(vid));
}
None => { }
}
ty
} else {
ty::mk_int_var(self.infcx.tcx, vid)
}
}
}
}
pub fn resolve_float_var(&mut self, vid: FloatVid) -> ty::t {
if !self.should(resolve_fvar) {
@ -292,25 +273,11 @@ impl<'a> ResolveState<'a> {
Some(t) => ty::mk_mach_float(t),
None => {
if self.should(force_fvar) {
// 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");
// As a last resort, emit an error.
self.err = Some(unresolved_float_ty(vid));
}
None => { }
}
ty
} else {
ty::mk_float_var(self.infcx.tcx, vid)
}
}
}
}
}

View File

@ -185,7 +185,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
let mut generics = String::new();
let last = path.segments.last().unwrap();
if last.lifetimes.len() > 0 || last.types.len() > 0 {
let mut counter = 0;
let mut counter = 0u;
generics.push_str("&lt;");
for lifetime in last.lifetimes.iter() {
if counter > 0 { generics.push_str(", "); }

View File

@ -335,11 +335,11 @@ mod bench {
#[bench]
fn alloc_managed_small(b: &mut Bencher) {
b.iter(|| { box(GC) 10 });
b.iter(|| { box(GC) 10i });
}
#[bench]
fn alloc_managed_big(b: &mut Bencher) {
b.iter(|| { box(GC) ([10, ..1000]) });
b.iter(|| { box(GC) ([10i, ..1000]) });
}
}

View File

@ -172,7 +172,7 @@ pub mod compiled {
rtassert!(!ptr.is_null());
let ptr: Box<T> = mem::transmute(ptr);
// can't use `as`, due to type not matching with `cfg(test)`
RT_TLS_PTR = mem::transmute(0);
RT_TLS_PTR = mem::transmute(0u);
ptr
}
@ -189,7 +189,7 @@ pub mod compiled {
} else {
let ptr: Box<T> = mem::transmute(ptr);
// can't use `as`, due to type not matching with `cfg(test)`
RT_TLS_PTR = mem::transmute(0);
RT_TLS_PTR = mem::transmute(0u);
Some(ptr)
}
}

View File

@ -560,7 +560,7 @@ mod test {
#[test]
fn local_heap() {
let a = box(GC) 5;
let a = box(GC) 5i;
let b = a;
assert!(*a == 5);
assert!(*b == 5);
@ -596,14 +596,14 @@ mod test {
#[test]
fn comm_stream() {
let (tx, rx) = channel();
tx.send(10);
tx.send(10i);
assert!(rx.recv() == 10);
}
#[test]
fn comm_shared_chan() {
let (tx, rx) = channel();
tx.send(10);
tx.send(10i);
assert!(rx.recv() == 10);
}

View File

@ -100,15 +100,15 @@ mod test {
use std::mem::transmute;
unsafe {
let mut key = 0;
let value = box 20;
let value = box 20i;
create(&mut key);
set(key, transmute(value));
let value: Box<int> = transmute(get(key));
assert_eq!(value, box 20);
let value = box 30;
assert_eq!(value, box 20i);
let value = box 30i;
set(key, transmute(value));
let value: Box<int> = transmute(get(key));
assert_eq!(value, box 30);
assert_eq!(value, box 30i);
}
}
}

View File

@ -1160,7 +1160,7 @@ mod test {
let expected = 32;
let mut current = 0;
let mut reads = 0;
let mut reads = 0u;
while current < expected {
let nread = stream.read(buf).ok().unwrap();

View File

@ -176,7 +176,7 @@ impl Drop for Queue {
impl Drop for State {
fn drop(&mut self) {
unsafe {
uvll::uv_close(self.handle, mem::transmute(0));
uvll::uv_close(self.handle, mem::transmute(0u));
// Note that this does *not* free the handle, that is the
// responsibility of the caller because the uv loop must be closed
// before we deallocate this uv handle.

View File

@ -208,7 +208,7 @@ impl<'a> FromBase64 for &'a str {
fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> {
let mut r = Vec::new();
let mut buf: u32 = 0;
let mut modulus = 0;
let mut modulus = 0i;
let mut it = self.bytes().enumerate();
for (idx, byte) in it {

View File

@ -104,7 +104,7 @@ impl<'a> FromHex for &'a str {
fn from_hex(&self) -> Result<Vec<u8>, FromHexError> {
// This may be an overestimate if there is any whitespace
let mut b = Vec::with_capacity(self.len() / 2);
let mut modulus = 0;
let mut modulus = 0i;
let mut buf = 0u8;
for (idx, byte) in self.bytes().enumerate() {

View File

@ -3424,7 +3424,7 @@ mod tests {
hash_map.insert("a".to_string(), 1i);
hash_map.insert("b".to_string(), 2);
assert_eq!(hash_map.to_json(), object);
assert_eq!(Some(15i).to_json(), Number(15 as f64));
assert_eq!(Some(15i).to_json(), Number(15f64));
assert_eq!(None::<int>.to_json(), Null);
}

View File

@ -1051,7 +1051,7 @@ mod test {
let initial_msg = "food-is-yummy";
let overwrite_msg = "-the-bar!!";
let final_msg = "foo-the-bar!!";
let seek_idx = 3;
let seek_idx = 3i;
let mut read_mem = [0, .. 13];
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt");

View File

@ -1816,7 +1816,7 @@ mod tests {
#[ignore]
fn test_getenv_big() {
let mut s = "".to_string();
let mut i = 0;
let mut i = 0i;
while i < 100 {
s.push_str("aaaaaaaaaa");
i += 1;

View File

@ -143,7 +143,7 @@ impl<T> AtomicOption<T> {
/// Remove the value, leaving the `AtomicOption` empty.
#[inline]
pub fn take(&self, order: Ordering) -> Option<Box<T>> {
unsafe { self.swap(mem::transmute(0), order) }
unsafe { self.swap(mem::transmute(0u), order) }
}
/// Replace an empty value with a non-empty value.
@ -155,7 +155,7 @@ impl<T> AtomicOption<T> {
pub fn fill(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
unsafe {
let val = mem::transmute(val);
let expected = mem::transmute(0);
let expected = mem::transmute(0u);
let oldval = self.p.compare_and_swap(expected, val, order);
if oldval == expected {
None

View File

@ -64,7 +64,7 @@ mod test {
let (left, right) = duplex();
left.send("abc".to_string());
right.send(123);
right.send(123i);
assert!(left.recv() == 123);
assert!(right.recv() == "abc".to_string());

View File

@ -1543,7 +1543,7 @@ mod test {
let (tx, rx) = channel();
let (cdone, pdone) = channel();
let t = Thread::start(proc() {
let mut hits = 0;
let mut hits = 0u;
while hits < 10 {
match rx.try_recv() {
Ok(()) => { hits += 1; }
@ -1993,7 +1993,7 @@ mod sync_tests {
let (tx, rx) = sync_channel::<()>(0);
let (cdone, pdone) = channel();
let t = Thread::start(proc() {
let mut hits = 0;
let mut hits = 0u;
while hits < 10 {
match rx.try_recv() {
Ok(()) => { hits += 1; }

View File

@ -30,15 +30,15 @@
//! let (mut worker, mut stealer) = pool.deque();
//!
//! // Only the worker may push/pop
//! worker.push(1);
//! worker.push(1i);
//! worker.pop();
//!
//! // Stealers take data from the other end of the deque
//! worker.push(1);
//! worker.push(1i);
//! stealer.steal();
//!
//! // Stealers can be cloned to have many stealers stealing in parallel
//! worker.push(1);
//! worker.push(1i);
//! let mut stealer2 = stealer.clone();
//! stealer2.steal();

View File

@ -158,7 +158,7 @@ impl<'a> Condvar<'a> {
/// ```
/// use sync::{Mutex, Arc};
///
/// let mutex = Arc::new(Mutex::new(1));
/// let mutex = Arc::new(Mutex::new(1i));
/// let mutex2 = mutex.clone();
///
/// spawn(proc() {
@ -487,7 +487,7 @@ mod tests {
#[test] #[should_fail]
fn test_arc_condvar_poison() {
let arc = Arc::new(Mutex::new(1));
let arc = Arc::new(Mutex::new(1i));
let arc2 = arc.clone();
let (tx, rx) = channel();

View File

@ -167,8 +167,8 @@ mod tests {
#[test]
fn test_full() {
let q = Queue::new();
q.push(box 1);
q.push(box 2);
q.push(box 1i);
q.push(box 2i);
}
#[test]

View File

@ -252,8 +252,8 @@ mod test {
#[test]
fn drop_full() {
let q = Queue::new(0);
q.push(box 1);
q.push(box 2);
q.push(box 1i);
q.push(box 2i);
}
#[test]
@ -284,7 +284,7 @@ mod test {
for _ in range(0u, 100000) {
loop {
match b.pop() {
Some(1) => break,
Some(1i) => break,
Some(_) => fail!(),
None => {}
}

View File

@ -998,7 +998,7 @@ impl<'a> State<'a> {
pub fn print_outer_attributes(&mut self,
attrs: &[ast::Attribute]) -> IoResult<()> {
let mut count = 0;
let mut count = 0u;
for attr in attrs.iter() {
match attr.node.style {
ast::AttrOuter => {
@ -1016,7 +1016,7 @@ impl<'a> State<'a> {
pub fn print_inner_attributes(&mut self,
attrs: &[ast::Attribute]) -> IoResult<()> {
let mut count = 0;
let mut count = 0u;
for attr in attrs.iter() {
match attr.node.style {
ast::AttrInner => {

View File

@ -166,8 +166,8 @@ mod test {
let v: SmallVector<int> = SmallVector::zero();
assert_eq!(0, v.len());
assert_eq!(1, SmallVector::one(1).len());
assert_eq!(5, SmallVector::many(vec!(1, 2, 3, 4, 5)).len());
assert_eq!(1, SmallVector::one(1i).len());
assert_eq!(5, SmallVector::many(vec!(1i, 2, 3, 4, 5)).len());
}
#[test]
@ -215,7 +215,7 @@ mod test {
#[test]
#[should_fail]
fn test_expect_one_many() {
SmallVector::many(vec!(1, 2)).expect_one("");
SmallVector::many(vec!(1i, 2)).expect_one("");
}
#[test]

View File

@ -546,7 +546,7 @@ fn get_authority(rawurl: &str) ->
let mut host = "".to_string();
let mut port = None;
let mut colon_count = 0;
let mut colon_count = 0u;
let mut pos = 0;
let mut begin = 2;
let mut end = len;

View File

@ -23,5 +23,5 @@ pub fn leaf<V>(value: V) -> TreeItem<V> {
}
fn main() {
BTree::<int> { node: leaf(1) };
BTree::<int> { node: leaf(1i) };
}

View File

@ -22,6 +22,6 @@ mod other {
}
pub fn foo(){
1+1;
1i+1;
}
}

View File

@ -12,7 +12,7 @@
// anonymous fields of a tuple vs the same anonymous field.
fn distinct_variant() {
let mut y = (1, 2);
let mut y = (1i, 2i);
let a = match y {
(ref mut a, _) => a
@ -27,7 +27,7 @@ fn distinct_variant() {
}
fn same_variant() {
let mut y = (1, 2);
let mut y = (1i, 2i);
let a = match y {
(ref mut a, _) => a

View File

@ -9,9 +9,9 @@
// except according to those terms.
fn f() {
let mut a = [box 0, box 1];
let mut a = [box 0i, box 1i];
drop(a[0]);
a[1] = box 2;
a[1] = box 2i;
drop(a[0]); //~ ERROR use of moved value: `a[..]`
}

View File

@ -11,14 +11,14 @@
fn foo() -> int {
let x: int;
while 1 != 2 {
while 1i != 2 {
break;
x = 0;
}
println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
return 17;
return 17i;
}
fn main() { println!("{}", foo()); }

View File

@ -21,37 +21,37 @@ fn set(x: &mut int) {
}
fn a() {
let mut x = 3;
let mut x = 3i;
let c1 = || x = 4;
let c2 = || x * 5; //~ ERROR cannot borrow `x`
}
fn b() {
let mut x = 3;
let mut x = 3i;
let c1 = || set(&mut x);
let c2 = || get(&x); //~ ERROR cannot borrow `x`
}
fn c() {
let mut x = 3;
let mut x = 3i;
let c1 = || set(&mut x);
let c2 = || x * 5; //~ ERROR cannot borrow `x`
}
fn d() {
let mut x = 3;
let mut x = 3i;
let c2 = || x * 5;
x = 5; //~ ERROR cannot assign
}
fn e() {
let mut x = 3;
let mut x = 3i;
let c1 = || get(&x);
x = 5; //~ ERROR cannot assign
}
fn f() {
let mut x = box 3;
let mut x = box 3i;
let c1 = || get(&*x);
*x = 5; //~ ERROR cannot assign
}

View File

@ -14,7 +14,7 @@
fn a() {
let mut x = 3;
let mut x = 3i;
let c1 = || x = 4;
let c2 = || x = 5; //~ ERROR cannot borrow `x` as mutable more than once
}
@ -24,19 +24,19 @@ fn set(x: &mut int) {
}
fn b() {
let mut x = 3;
let mut x = 3i;
let c1 = || set(&mut x);
let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
}
fn c() {
let mut x = 3;
let mut x = 3i;
let c1 = || x = 5;
let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
}
fn d() {
let mut x = 3;
let mut x = 3i;
let c1 = || x = 5;
let c2 = || { let _y = || set(&mut x); }; // (nested closure)
//~^ ERROR cannot borrow `x` as mutable more than once

View File

@ -11,6 +11,6 @@
fn foo(x: int) { println!("{}", x); }
fn main() {
let x: int; if 1 > 2 { x = 10; }
let x: int; if 1i > 2 { x = 10; }
foo(x); //~ ERROR use of possibly uninitialized variable: `x`
}

View File

@ -14,7 +14,7 @@ fn foo(x: int) { println!("{:?}", x); }
fn main() {
let x: int;
if 1 > 2 {
if 1i > 2 {
println!("whoops");
} else {
x = 10;

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let mut _a = 3;
let mut _a = 3i;
let _b = &mut _a;
{
let _c = &*_b;

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let x = Some(box 1);
let x = Some(box 1i);
match x {
Some(ref _y) => {
let _a = x; //~ ERROR cannot move

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let x = Some(box 1);
let x = Some(box 1i);
match x {
Some(ref y) => {
let _b = *y; //~ ERROR cannot move out

View File

@ -35,20 +35,20 @@ fn guard() {
// Here the guard performs a borrow. This borrow "infects" all
// subsequent arms (but not the prior ones).
let mut a = box 3;
let mut b = box 4;
let mut a = box 3u;
let mut b = box 4u;
let mut w = &*a;
match 22 {
match 22i {
_ if cond() => {
b = box 5;
b = box 5u;
}
_ if link(&*b, &mut w) => {
b = box 6; //~ ERROR cannot assign
b = box 6u; //~ ERROR cannot assign
}
_ => {
b = box 7; //~ ERROR cannot assign
b = box 7u; //~ ERROR cannot assign
}
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn f() {
let x = [1].iter(); //~ ERROR borrowed value does not live long enough
let x = [1i].iter(); //~ ERROR borrowed value does not live long enough
//~^^ NOTE reference must be valid for the block
//~^^ NOTE consider using a `let` binding to increase its lifetime
}

View File

@ -24,10 +24,10 @@ fn foo<'a>(x: &'a Gc<int>) -> &'a int {
}
fn bar() {
let a = 3;
let a = 3i;
let mut y = &a;
if true {
let x = box(GC) 3;
let x = box(GC) 3i;
y = &*x; //~ ERROR `*x` does not live long enough
}
}

View File

@ -43,7 +43,7 @@ pub fn main() {
}
}
match [1,2,3] {
match [1i,2,3] {
[x,_,_] => {
x += 1; //~ ERROR re-assignment of immutable variable `x`
}

View File

@ -12,7 +12,7 @@
// borrowed path.
fn main() {
let a = box box 2;
let a = box box 2i;
let b = &a;
let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed

View File

@ -11,6 +11,6 @@
use std::rc::Rc;
pub fn main() {
let _x = Rc::new(vec!(1, 2)).move_iter();
let _x = Rc::new(vec!(1i, 2)).move_iter();
//~^ ERROR cannot move out of dereference of `&`-pointer
}

View File

@ -13,9 +13,9 @@ use std::task;
fn borrow<T>(_: &T) { }
fn different_vars_after_borrows() {
let x1 = box 1;
let x1 = box 1i;
let p1 = &x1;
let x2 = box 2;
let x2 = box 2i;
let p2 = &x2;
task::spawn(proc() {
drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed
@ -26,9 +26,9 @@ fn different_vars_after_borrows() {
}
fn different_vars_after_moves() {
let x1 = box 1;
let x1 = box 1i;
drop(x1);
let x2 = box 2;
let x2 = box 2i;
drop(x2);
task::spawn(proc() {
drop(x1); //~ ERROR capture of moved value: `x1`
@ -37,7 +37,7 @@ fn different_vars_after_moves() {
}
fn same_var_after_borrow() {
let x = box 1;
let x = box 1i;
let p = &x;
task::spawn(proc() {
drop(x); //~ ERROR cannot move `x` into closure because it is borrowed
@ -47,7 +47,7 @@ fn same_var_after_borrow() {
}
fn same_var_after_move() {
let x = box 1;
let x = box 1i;
drop(x);
task::spawn(proc() {
drop(x); //~ ERROR capture of moved value: `x`

View File

@ -12,7 +12,7 @@
fn borrow(_v: &int) {}
fn local() {
let mut v = box 3;
let mut v = box 3i;
borrow(v);
}
@ -31,27 +31,27 @@ fn local_recs() {
}
fn aliased_imm() {
let mut v = box 3;
let mut v = box 3i;
let _w = &v;
borrow(v);
}
fn aliased_mut() {
let mut v = box 3;
let mut v = box 3i;
let _w = &mut v;
borrow(v); //~ ERROR cannot borrow `*v`
}
fn aliased_other() {
let mut v = box 3;
let mut w = box 4;
let mut v = box 3i;
let mut w = box 4i;
let _x = &mut w;
borrow(v);
}
fn aliased_other_reassign() {
let mut v = box 3;
let mut w = box 4;
let mut v = box 3i;
let mut w = box 4i;
let mut _x = &mut w;
_x = &mut v;
borrow(v); //~ ERROR cannot borrow `*v`

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let mut a = [1, 2, 3, 4];
let mut a = [1i, 2, 3, 4];
let t = match a {
[1, 2, ..tail] => tail,
_ => unreachable!()

View File

@ -10,7 +10,7 @@
fn a() {
let mut vec = [box 1, box 2, box 3];
let mut vec = [box 1i, box 2, box 3];
match vec {
[box ref _a, _, _] => {
vec[0] = box 4; //~ ERROR cannot assign
@ -19,7 +19,7 @@ fn a() {
}
fn b() {
let mut vec = vec!(box 1, box 2, box 3);
let mut vec = vec!(box 1i, box 2, box 3);
let vec: &mut [Box<int>] = vec.as_mut_slice();
match vec {
[.._b] => {
@ -29,7 +29,7 @@ fn b() {
}
fn c() {
let mut vec = vec!(box 1, box 2, box 3);
let mut vec = vec!(box 1i, box 2, box 3);
let vec: &mut [Box<int>] = vec.as_mut_slice();
match vec {
[_a, //~ ERROR cannot move out
@ -47,7 +47,7 @@ fn c() {
}
fn d() {
let mut vec = vec!(box 1, box 2, box 3);
let mut vec = vec!(box 1i, box 2, box 3);
let vec: &mut [Box<int>] = vec.as_mut_slice();
match vec {
[.._a, //~ ERROR cannot move out
@ -58,7 +58,7 @@ fn d() {
}
fn e() {
let mut vec = vec!(box 1, box 2, box 3);
let mut vec = vec!(box 1i, box 2, box 3);
let vec: &mut [Box<int>] = vec.as_mut_slice();
match vec {
[_a, _b, _c] => {} //~ ERROR cannot move out

View File

@ -10,7 +10,7 @@
fn f() -> int {
let mut x: int;
while 1 == 1 { x = 10; }
while 1i == 1 { x = 10; }
return x; //~ ERROR use of possibly uninitialized variable: `x`
}

View File

@ -21,6 +21,6 @@ impl <T: Share> Foo for T { }
fn main() {
let (tx, rx) = channel();
1193182.foo(tx);
assert!(rx.recv() == 1193182);
1193182i.foo(tx);
assert!(rx.recv() == 1193182i);
}

View File

@ -10,7 +10,7 @@
#![feature(macro_rules)]
static A: uint = { 1; 2 };
static A: uint = { 1u; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
static B: uint = { { } 2 };
@ -21,7 +21,7 @@ macro_rules! foo {
}
static C: uint = { foo!() 2 };
static D: uint = { let x = 4; 2 };
static D: uint = { let x = 4u; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
pub fn main() {

View File

@ -11,6 +11,6 @@
fn main() {
for
&1 //~ ERROR refutable pattern in `for` loop binding
in [1].iter() {}
&1i //~ ERROR refutable pattern in `for` loop binding
in [1i].iter() {}
}

View File

@ -0,0 +1,17 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(_: *const ()) {}
fn main() {
let a = 3; //~ ERROR cannot determine a type for this local variable
foo(&a as *const _ as *const ());
}

View File

@ -0,0 +1,15 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
println!("{}", std::mem::size_of_val(&1));
//~^ ERROR cannot determine a type for this expression
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let x = box 1;
let x = box 1i;
let f: proc() = proc() {
let _a = x;
drop(x);

View File

@ -11,6 +11,6 @@
// This file must never have a trailing newline
fn main() {
let x = Some(3);
let y = x.as_ref().unwrap_or(&5); //~ ERROR: borrowed value does not live long enough
let x = Some(3i);
let y = x.as_ref().unwrap_or(&5i); //~ ERROR: borrowed value does not live long enough
}

View File

@ -9,8 +9,8 @@
// except according to those terms.
fn main() {
let mut v = vec!(1);
let f = || v.push(2);
let mut v = vec!(1i);
let f = || v.push(2i);
let _w = v; //~ ERROR: cannot move out of `v`
f();

View File

@ -10,7 +10,7 @@
fn main() {
let r = {
let x = box 42;
let x = box 42i;
let f = proc() &x; //~ ERROR: `x` does not live long enough
f()
};

View File

@ -14,7 +14,7 @@ fn main() {
loop {
let tx = tx;
//~^ ERROR: use of moved value: `tx`
tx.send(1);
tx.send(1i);
}
});
}

View File

@ -10,9 +10,9 @@
// compile-flags: -D while-true
fn main() {
let mut i = 0;
let mut i = 0i;
while true { //~ ERROR denote infinite loops with loop
i += 1;
if i == 5 { break; }
i += 1i;
if i == 5i { break; }
}
}

View File

@ -14,7 +14,7 @@ struct Obj {
impl Obj {
pub fn boom() -> bool {
return 1+1 == 2
return 1i+1 == 2
}
pub fn chirp(&self) {
self.boom(); //~ ERROR `&Obj` does not implement any method in scope named `boom`
@ -24,5 +24,5 @@ impl Obj {
fn main() {
let o = Obj { member: 0 };
o.chirp();
1 + 1;
1i + 1;
}

View File

@ -35,7 +35,7 @@ static priv_static: int = 0; //~ ERROR: code is never used
static used_static: int = 0;
pub static used_static2: int = used_static;
static USED_STATIC: int = 0;
static STATIC_USED_IN_ENUM_DISCRIMINANT: uint = 10;
static STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10;
pub type typ = *const UsedStruct4;
pub struct PubStruct;
@ -77,7 +77,7 @@ pub fn pub_fn() {
let e = foo3;
SemiUsedStruct::la_la_la();
let i = 1;
let i = 1i;
match i {
USED_STATIC => (),
_ => ()

View File

@ -21,11 +21,11 @@ struct Foo {
struct Bar { x: Box<int> } //~ ERROR type uses owned
fn main() {
let _x : Bar = Bar {x : box 10}; //~ ERROR type uses owned
let _x : Bar = Bar {x : box 10i}; //~ ERROR type uses owned
box(GC) 2; //~ ERROR type uses managed
box(GC) 2i; //~ ERROR type uses managed
box 2; //~ ERROR type uses owned
box 2i; //~ ERROR type uses owned
fn g(_: Box<Clone>) {} //~ ERROR type uses owned
proc() {}; //~ ERROR type uses owned
}

View File

@ -17,7 +17,7 @@ impl X {
}
fn foo() -> int {
return (1); //~ ERROR unnecessary parentheses around `return` value
return (1i); //~ ERROR unnecessary parentheses around `return` value
}
fn bar() -> X {
return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value
@ -45,7 +45,7 @@ fn main() {
_ => {}
}
let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
_a = (0); //~ ERROR unnecessary parentheses around assigned value
_a += (1); //~ ERROR unnecessary parentheses around assigned value
let mut _a = (0i); //~ ERROR unnecessary parentheses around assigned value
_a = (0i); //~ ERROR unnecessary parentheses around assigned value
_a += (1i); //~ ERROR unnecessary parentheses around assigned value
}

View File

@ -55,7 +55,7 @@ mod bar {
pub mod c {
use foo::Point;
use foo::Square; //~ ERROR unused import
pub fn cc(p: Point) -> int { return 2 * (p.x + p.y); }
pub fn cc(p: Point) -> int { return 2i * (p.x + p.y); }
}
#[allow(unused_imports)]
@ -66,8 +66,8 @@ mod bar {
fn main() {
cal(foo::Point{x:3, y:9});
let mut a = 3;
let mut b = 4;
let mut a = 3i;
let mut b = 4i;
swap(&mut a, &mut b);
test::C.b();
let _a = foo();

View File

@ -18,16 +18,16 @@
fn main() {
// negative cases
let mut a = 3; //~ ERROR: variable does not need to be mutable
let mut a = 2; //~ ERROR: variable does not need to be mutable
let mut b = 3; //~ ERROR: variable does not need to be mutable
let mut a = vec!(3); //~ ERROR: variable does not need to be mutable
let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable
let mut a = 3i; //~ ERROR: variable does not need to be mutable
let mut a = 2i; //~ ERROR: variable does not need to be mutable
let mut b = 3i; //~ ERROR: variable does not need to be mutable
let mut a = vec!(3i); //~ ERROR: variable does not need to be mutable
let (mut a, b) = (1i, 2i); //~ ERROR: variable does not need to be mutable
match 30 {
match 30i {
mut x => {} //~ ERROR: variable does not need to be mutable
}
match (30, 2) {
match (30i, 2i) {
(mut x, 1) | //~ ERROR: variable does not need to be mutable
(mut x, 2) |
(mut x, 3) => {
@ -35,28 +35,28 @@ fn main() {
_ => {}
}
let x = |mut y: int| 10; //~ ERROR: variable does not need to be mutable
let x = |mut y: int| 10i; //~ ERROR: variable does not need to be mutable
fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
// positive cases
let mut a = 2;
a = 3;
let mut a = 2i;
a = 3i;
let mut a = Vec::new();
a.push(3);
a.push(3i);
let mut a = Vec::new();
callback(|| {
a.push(3);
a.push(3i);
});
let (mut a, b) = (1, 2);
let (mut a, b) = (1i, 2i);
a = 34;
match 30 {
match 30i {
mut x => {
x = 21;
x = 21i;
}
}
match (30, 2) {
match (30i, 2i) {
(mut x, 1) |
(mut x, 2) |
(mut x, 3) => {
@ -65,12 +65,12 @@ fn main() {
_ => {}
}
let x = |mut y: int| y = 32;
fn nothing(mut foo: int) { foo = 37; }
let x = |mut y: int| y = 32i;
fn nothing(mut foo: int) { foo = 37i; }
// leading underscore should avoid the warning, just like the
// unused variable lint.
let mut _allowed = 1;
let mut _allowed = 1i;
}
fn callback(f: ||) {}
@ -78,6 +78,6 @@ fn callback(f: ||) {}
// make sure the lint attribute can be turned off
#[allow(unused_mut)]
fn foo(mut a: int) {
let mut a = 3;
let mut b = vec!(2);
let mut a = 3i;
let mut b = vec!(2i);
}

View File

@ -29,40 +29,40 @@ fn f1d() {
}
fn f2() {
let x = 3;
let x = 3i;
//~^ ERROR unused variable: `x`
}
fn f3() {
let mut x = 3;
let mut x = 3i;
//~^ ERROR variable `x` is assigned to, but never used
x += 4;
x += 4i;
//~^ ERROR value assigned to `x` is never read
}
fn f3b() {
let mut z = 3;
let mut z = 3i;
//~^ ERROR variable `z` is assigned to, but never used
loop {
z += 4;
z += 4i;
}
}
#[allow(unused_variable)]
fn f3c() {
let mut z = 3;
loop { z += 4; }
let mut z = 3i;
loop { z += 4i; }
}
#[allow(unused_variable)]
#[allow(dead_assignment)]
fn f3d() {
let mut x = 3;
x += 4;
let mut x = 3i;
x += 4i;
}
fn f4() {
match Some(3) {
match Some(3i) {
Some(i) => {
//~^ ERROR unused variable: `i`
}
@ -75,7 +75,7 @@ enum tri {
}
fn f4b() -> int {
match a(3) {
match a(3i) {
a(i) | b(i) | c(i) => {
i
}

View File

@ -9,9 +9,9 @@
// except according to those terms.
fn main() {
match 1 {
1 => 1, //~ ERROR mismatched types between arms
2u => 1,
_ => 2,
match 1i {
1i => 1i,
2u => 1i, //~ ERROR mismatched types
_ => 2i,
};
}

View File

@ -9,6 +9,6 @@
// except according to those terms.
fn main() {
match 0 { 1 => () } //~ ERROR non-exhaustive patterns
match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns
match 0i { 1i => () } //~ ERROR non-exhaustive patterns
match 0i { 0i if false => () } //~ ERROR non-exhaustive patterns
}

View File

@ -39,9 +39,9 @@ fn main() {
_ => {}
};
match 1.0 {
0.01 .. 6.5 => {}
0.02 => {}
match 1.0f64 {
0.01f64 .. 6.5f64 => {}
0.02f64 => {}
_ => {}
};
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn a() {
let v = [1, 2, 3];
let v = [1i, 2, 3];
match v {
[_, _, _] => {}
[_, _, _] => {} //~ ERROR unreachable pattern

View File

@ -25,13 +25,13 @@ fn f10() {
fn f20() {
let x = "hi".to_string();
let _y = (x, 3);
let _y = (x, 3i);
touch(&x); //~ ERROR use of moved value: `x`
}
fn f21() {
let x = vec!(1, 2, 3);
let _y = (*x.get(0), 3);
let x = vec!(1i, 2, 3);
let _y = (*x.get(0), 3i);
touch(&x);
}
@ -62,9 +62,9 @@ fn f50(cond: bool) {
let x = "hi".to_string();
let y = "ho".to_string();
let _y = match cond {
_ if guard(x) => 10,
true => 10,
false => 20,
_ if guard(x) => 10i,
true => 10i,
false => 20i,
};
touch(&x); //~ ERROR use of moved value: `x`
touch(&y);

View File

@ -11,7 +11,7 @@
use std::cell::RefCell;
fn main() {
let m = RefCell::new(0);
let m = RefCell::new(0i);
let mut b = m.borrow_mut();
let b1 = &mut *b;
let b2 = &mut *b; //~ ERROR cannot borrow

Some files were not shown because too many files have changed in this diff Show More