Skip to content

librustc: Remove the fallback to int from typechecking. #15026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 17 additions & 17 deletions src/doc/guide-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -155,16 +155,16 @@ 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);
~~~

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);
~~~
Expand All @@ -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| {
Expand Down Expand Up @@ -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"
}
~~~
Expand All @@ -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
Expand All @@ -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::<Vec<int>>();
assert_eq!(ys, vec![10, 6, 4, 2, 2, 0]);
~~~
Expand Down Expand Up @@ -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)`
Expand All @@ -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)`
Expand All @@ -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
Expand All @@ -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)`
Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/doc/guide-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
~~~
Expand All @@ -293,7 +293,7 @@ example above by adjusting the `bh.iter` call to
# struct X; impl X { fn iter<T>(&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)
});
~~~

Expand All @@ -307,7 +307,7 @@ extern crate test;
# fn main() {
# struct X; impl X { fn iter<T>(&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));
});
# }
~~~
Expand Down
16 changes: 8 additions & 8 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand Down
15 changes: 8 additions & 7 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,12 @@ use std::option::{Some, None};
# fn foo<T>(_: 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]);
}
~~~~

Expand Down Expand Up @@ -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<Shape> = box mycircle as Box<Shape>;
~~~~

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -3685,7 +3686,7 @@ fn print(a: Box<Printable>) {
}

fn main() {
print(box 10 as Box<Printable>);
print(box 10i as Box<Printable>);
}
~~~~

Expand Down
Loading