Skip to content

Commit 265a233

Browse files
committed
Auto merge of #21677 - japaric:no-range, r=alexcrichton
Note: Do not merge until we get a newer snapshot that includes #21374 There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672). r? @alexcrichton
2 parents 3d6f510 + a6f9180 commit 265a233

File tree

366 files changed

+1314
-1337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+1314
-1337
lines changed

src/compiletest/common.rs

-14
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ pub use self::Mode::*;
1212
use std::fmt;
1313
use std::str::FromStr;
1414

15-
#[cfg(stage0)] // NOTE: remove impl after snapshot
16-
#[derive(Clone, Copy, PartialEq, Show)]
17-
pub enum Mode {
18-
CompileFail,
19-
RunFail,
20-
RunPass,
21-
RunPassValgrind,
22-
Pretty,
23-
DebugInfoGdb,
24-
DebugInfoLldb,
25-
Codegen
26-
}
27-
28-
#[cfg(not(stage0))] // NOTE: remove cfg after snapshot
2915
#[derive(Clone, Copy, PartialEq, Debug)]
3016
pub enum Mode {
3117
CompileFail,

src/compiletest/compiletest.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#![feature(os)]
2424
#![feature(unicode)]
2525

26+
#![allow(unstable)]
2627
#![deny(warnings)]
2728

2829
extern crate test;

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct ExpectedError {
1717
pub msg: String,
1818
}
1919

20-
#[derive(PartialEq, Show)]
20+
#[derive(PartialEq, Debug)]
2121
enum WhichLine { ThisLine, FollowPrevious(uint), AdjustBackward(uint) }
2222

2323
/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"

src/doc/trpl/error-handling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ for all but the most trivial of situations.
147147
Here's an example of using `Result`:
148148

149149
```rust
150-
#[derive(Show)]
150+
#[derive(Debug)]
151151
enum Version { Version1, Version2 }
152152

153-
#[derive(Show)]
153+
#[derive(Debug)]
154154
enum ParseError { InvalidHeaderLength, InvalidVersion }
155155

156156
fn parse_version(header: &[u8]) -> Result<Version, ParseError> {

src/doc/trpl/pointers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ Sometimes, you need a recursive data structure. The simplest is known as a
605605

606606

607607
```{rust}
608-
#[derive(Show)]
608+
#[derive(Debug)]
609609
enum List<T> {
610610
Cons(T, Box<List<T>>),
611611
Nil,

src/liballoc/arc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
//!
3838
//! let five = Arc::new(5i);
3939
//!
40-
//! for _ in range(0u, 10) {
40+
//! for _ in 0u..10 {
4141
//! let five = five.clone();
4242
//!
4343
//! Thread::spawn(move || {
@@ -54,7 +54,7 @@
5454
//!
5555
//! let five = Arc::new(Mutex::new(5i));
5656
//!
57-
//! for _ in range(0u, 10) {
57+
//! for _ in 0u..10 {
5858
//! let five = five.clone();
5959
//!
6060
//! Thread::spawn(move || {
@@ -95,10 +95,10 @@ use heap::deallocate;
9595
/// use std::thread::Thread;
9696
///
9797
/// fn main() {
98-
/// let numbers: Vec<_> = range(0, 100u32).map(|i| i as f32).collect();
98+
/// let numbers: Vec<_> = (0..100u32).map(|i| i as f32).collect();
9999
/// let shared_numbers = Arc::new(numbers);
100100
///
101-
/// for _ in range(0u, 10) {
101+
/// for _ in 0u..10 {
102102
/// let child_numbers = shared_numbers.clone();
103103
///
104104
/// Thread::spawn(move || {
@@ -814,6 +814,6 @@ mod tests {
814814
}
815815

816816
// Make sure deriving works with Arc<T>
817-
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Show, Default)]
817+
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
818818
struct Foo { inner: Arc<int> }
819819
}

src/liballoc/boxed.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! Creating a recursive data structure:
3030
//!
3131
//! ```
32-
//! #[derive(Show)]
32+
//! #[derive(Debug)]
3333
//! enum List<T> {
3434
//! Cons(T, Box<List<T>>),
3535
//! Nil,
@@ -250,8 +250,6 @@ impl<T: ?Sized> DerefMut for Box<T> {
250250
fn deref_mut(&mut self) -> &mut T { &mut **self }
251251
}
252252

253-
// FIXME(#21363) remove `old_impl_check` when bug is fixed
254-
#[old_impl_check]
255253
impl<'a, T> Iterator for Box<Iterator<Item=T> + 'a> {
256254
type Item = T;
257255

src/liballoc/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
#![feature(lang_items, unsafe_destructor)]
7171
#![feature(box_syntax)]
7272
#![feature(optin_builtin_traits)]
73-
// FIXME(#21363) remove `old_impl_check` when bug is fixed
74-
#![feature(old_impl_check)]
7573
#![allow(unknown_features)] #![feature(int_uint)]
7674
#![feature(core)]
7775
#![feature(hash)]

src/libarena/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl Arena {
311311
#[test]
312312
fn test_arena_destructors() {
313313
let arena = Arena::new();
314-
for i in range(0u, 10) {
314+
for i in 0u..10 {
315315
// Arena allocate something with drop glue to make sure it
316316
// doesn't leak.
317317
arena.alloc(|| Rc::new(i));
@@ -340,7 +340,7 @@ fn test_arena_alloc_nested() {
340340
fn test_arena_destructors_fail() {
341341
let arena = Arena::new();
342342
// Put some stuff in the arena.
343-
for i in range(0u, 10) {
343+
for i in 0u..10 {
344344
// Arena allocate something with drop glue to make sure it
345345
// doesn't leak.
346346
arena.alloc(|| { Rc::new(i) });
@@ -410,7 +410,7 @@ impl<T> TypedArenaChunk<T> {
410410
// Destroy all the allocated objects.
411411
if intrinsics::needs_drop::<T>() {
412412
let mut start = self.start();
413-
for _ in range(0, len) {
413+
for _ in 0..len {
414414
ptr::read(start as *const T); // run the destructor on the pointer
415415
start = start.offset(mem::size_of::<T>() as int)
416416
}
@@ -530,7 +530,7 @@ mod tests {
530530
#[test]
531531
pub fn test_copy() {
532532
let arena = TypedArena::new();
533-
for _ in range(0u, 100000) {
533+
for _ in 0u..100000 {
534534
arena.alloc(Point {
535535
x: 1,
536536
y: 2,
@@ -585,7 +585,7 @@ mod tests {
585585
#[test]
586586
pub fn test_noncopy() {
587587
let arena = TypedArena::new();
588-
for _ in range(0u, 100000) {
588+
for _ in 0u..100000 {
589589
arena.alloc(Noncopy {
590590
string: "hello world".to_string(),
591591
array: vec!( 1, 2, 3, 4, 5 ),

src/libcollections/bench.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn insert_rand_n<M, I, R>(n: uint,
2424
// setup
2525
let mut rng = rand::weak_rng();
2626

27-
for _ in range(0, n) {
27+
for _ in 0..n {
2828
insert(map, rng.gen::<uint>() % n);
2929
}
3030

@@ -46,7 +46,7 @@ pub fn insert_seq_n<M, I, R>(n: uint,
4646
R: FnMut(&mut M, uint),
4747
{
4848
// setup
49-
for i in range(0u, n) {
49+
for i in 0u..n {
5050
insert(map, i * 2);
5151
}
5252

@@ -70,7 +70,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
7070
{
7171
// setup
7272
let mut rng = rand::weak_rng();
73-
let mut keys = range(0, n).map(|_| rng.gen::<uint>() % n)
73+
let mut keys = (0..n).map(|_| rng.gen::<uint>() % n)
7474
.collect::<Vec<_>>();
7575

7676
for k in keys.iter() {
@@ -97,7 +97,7 @@ pub fn find_seq_n<M, T, I, F>(n: uint,
9797
F: FnMut(&M, uint) -> T,
9898
{
9999
// setup
100-
for i in range(0u, n) {
100+
for i in 0u..n {
101101
insert(map, i);
102102
}
103103

src/libcollections/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
//! // for a simpler implementation.
6868
//! fn shortest_path(adj_list: &Vec<Vec<Edge>>, start: uint, goal: uint) -> uint {
6969
//! // dist[node] = current shortest distance from `start` to `node`
70-
//! let mut dist: Vec<_> = range(0, adj_list.len()).map(|_| uint::MAX).collect();
70+
//! let mut dist: Vec<_> = (0..adj_list.len()).map(|_| uint::MAX).collect();
7171
//!
7272
//! let mut heap = BinaryHeap::new();
7373
//!

src/libcollections/bit.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
//! };
6767
//!
6868
//! // Simple primality tests below our max bound
69-
//! let print_primes = 20;
69+
//! let print_primes = 20u;
7070
//! print!("The primes below {} are: ", print_primes);
71-
//! for x in range(0, print_primes) {
71+
//! for x in 0..print_primes {
7272
//! if primes.contains(&x) {
7373
//! print!("{} ", x);
7474
//! }
@@ -104,7 +104,7 @@ type MatchWords<'a> = Chain<Enumerate<Blocks<'a>>, Skip<Take<Enumerate<Repeat<u3
104104

105105
fn reverse_bits(byte: u8) -> u8 {
106106
let mut result = 0;
107-
for i in range(0, u8::BITS) {
107+
for i in 0..u8::BITS {
108108
result |= ((byte >> i) & 1) << (u8::BITS - 1 - i);
109109
}
110110
result
@@ -320,7 +320,7 @@ impl Bitv {
320320

321321
bitv.nbits = len;
322322

323-
for i in range(0, complete_words) {
323+
for i in 0..complete_words {
324324
bitv.storage.push(
325325
((reverse_bits(bytes[i * 4 + 0]) as u32) << 0) |
326326
((reverse_bits(bytes[i * 4 + 1]) as u32) << 8) |
@@ -353,7 +353,7 @@ impl Bitv {
353353
/// ```
354354
pub fn from_fn<F>(len: uint, mut f: F) -> Bitv where F: FnMut(uint) -> bool {
355355
let mut bitv = Bitv::from_elem(len, false);
356-
for i in range(0u, len) {
356+
for i in 0u..len {
357357
bitv.set(i, f(i));
358358
}
359359
bitv
@@ -660,7 +660,7 @@ impl Bitv {
660660

661661
let len = self.nbits/8 +
662662
if self.nbits % 8 == 0 { 0 } else { 1 };
663-
range(0, len).map(|i|
663+
(0..len).map(|i|
664664
bit(self, i, 0) |
665665
bit(self, i, 1) |
666666
bit(self, i, 2) |
@@ -830,7 +830,7 @@ impl Bitv {
830830

831831
// Fill in words after the old tail word
832832
let stop_idx = cmp::min(self.storage.len(), new_nblocks);
833-
for idx in range(old_last_word + 1, stop_idx) {
833+
for idx in old_last_word + 1..stop_idx {
834834
self.storage[idx] = full_value;
835835
}
836836

@@ -2232,12 +2232,12 @@ mod tests {
22322232
#[test]
22332233
fn test_equal_sneaky_big() {
22342234
let mut a = Bitv::from_elem(100, false);
2235-
for i in range(0u, 100) {
2235+
for i in 0u..100 {
22362236
a.set(i, true);
22372237
}
22382238

22392239
let mut b = Bitv::from_elem(100, true);
2240-
for i in range(0u, 100) {
2240+
for i in 0u..100 {
22412241
b.set(i, true);
22422242
}
22432243

@@ -2283,7 +2283,7 @@ mod tests {
22832283

22842284
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools);
22852285

2286-
let long = range(0, 10000).map(|i| i % 2 == 0).collect::<Vec<_>>();
2286+
let long = (0i32..10000).map(|i| i % 2 == 0).collect::<Vec<_>>();
22872287
let bitv: Bitv = long.iter().map(|n| *n).collect();
22882288
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
22892289
}
@@ -2526,7 +2526,7 @@ mod bitv_bench {
25262526
let mut r = rng();
25272527
let mut bitv = 0 as uint;
25282528
b.iter(|| {
2529-
for _ in range(0u, 100) {
2529+
for _ in 0u..100 {
25302530
bitv |= 1 << ((r.next_u32() as uint) % u32::BITS);
25312531
}
25322532
black_box(&bitv);
@@ -2538,7 +2538,7 @@ mod bitv_bench {
25382538
let mut r = rng();
25392539
let mut bitv = Bitv::from_elem(BENCH_BITS, false);
25402540
b.iter(|| {
2541-
for _ in range(0u, 100) {
2541+
for _ in 0u..100 {
25422542
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
25432543
}
25442544
black_box(&bitv);
@@ -2550,7 +2550,7 @@ mod bitv_bench {
25502550
let mut r = rng();
25512551
let mut bitv = Bitv::from_elem(BENCH_BITS, false);
25522552
b.iter(|| {
2553-
for _ in range(0u, 100) {
2553+
for _ in 0u..100 {
25542554
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
25552555
}
25562556
black_box(&bitv);
@@ -2562,7 +2562,7 @@ mod bitv_bench {
25622562
let mut r = rng();
25632563
let mut bitv = Bitv::from_elem(u32::BITS, false);
25642564
b.iter(|| {
2565-
for _ in range(0u, 100) {
2565+
for _ in 0u..100 {
25662566
bitv.set((r.next_u32() as uint) % u32::BITS, true);
25672567
}
25682568
black_box(&bitv);
@@ -2583,7 +2583,7 @@ mod bitv_bench {
25832583
let bitv = Bitv::from_elem(u32::BITS, false);
25842584
b.iter(|| {
25852585
let mut sum = 0u;
2586-
for _ in range(0u, 10) {
2586+
for _ in 0u..10 {
25872587
for pres in bitv.iter() {
25882588
sum += pres as uint;
25892589
}
@@ -2647,7 +2647,7 @@ mod bitv_set_test {
26472647
let idxs: Vec<uint> = bitv.iter().collect();
26482648
assert_eq!(idxs, vec![0, 2, 3]);
26492649

2650-
let long: BitvSet = range(0u, 10000).filter(|&n| n % 2 == 0).collect();
2650+
let long: BitvSet = (0u..10000).filter(|&n| n % 2 == 0).collect();
26512651
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
26522652

26532653
let idxs: Vec<uint> = long.iter().collect();
@@ -3021,7 +3021,7 @@ mod bitv_set_bench {
30213021
let mut r = rng();
30223022
let mut bitv = BitvSet::new();
30233023
b.iter(|| {
3024-
for _ in range(0u, 100) {
3024+
for _ in 0u..100 {
30253025
bitv.insert((r.next_u32() as uint) % u32::BITS);
30263026
}
30273027
black_box(&bitv);
@@ -3033,7 +3033,7 @@ mod bitv_set_bench {
30333033
let mut r = rng();
30343034
let mut bitv = BitvSet::new();
30353035
b.iter(|| {
3036-
for _ in range(0u, 100) {
3036+
for _ in 0u..100 {
30373037
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
30383038
}
30393039
black_box(&bitv);

0 commit comments

Comments
 (0)