Skip to content

Commit 5357d7f

Browse files
committed
Tests
1 parent aab9c95 commit 5357d7f

17 files changed

+52
-51
lines changed

src/test/bench/shootout-fasta-redux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
130130
copy_memory(buf.as_mut_slice(), alu);
131131
let buf_len = buf.len();
132132
copy_memory(buf.slice_mut(alu_len, buf_len),
133-
alu.index(&(0..LINE_LEN)));
133+
&alu[0..LINE_LEN]);
134134

135135
let mut pos = 0;
136136
let mut bytes;
@@ -206,7 +206,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
206206
for i in range(0u, chars_left) {
207207
buf[i] = self.nextc();
208208
}
209-
self.out.write(buf.index(&(0..chars_left)))
209+
self.out.write(&buf[0..chars_left])
210210
}
211211
}
212212

src/test/bench/shootout-k-nucleotide.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ fn generate_frequencies(mut input: &[u8], frame: uint) -> Table {
247247
// Pull first frame.
248248
for _ in range(0, frame) {
249249
code = code.push_char(input[0]);
250-
input = input.index(&(1..));
250+
input = &input[1..];
251251
}
252252
frequencies.lookup(code, BumpCallback);
253253

254254
while input.len() != 0 && input[0] != ('>' as u8) {
255255
code = code.rotate(input[0], frame);
256256
frequencies.lookup(code, BumpCallback);
257-
input = input.index(&(1..));
257+
input = &input[1..];
258258
}
259259
frequencies
260260
}

src/test/compile-fail/borrowck-array-double-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn f() {
1212
let mut a = [box 0i, box 1i];
1313
drop(a[0]);
1414
a[1] = box 2i;
15-
drop(a[0]); //~ ERROR use of moved value: `a.index(&(..))`
15+
drop(a[0]); //~ ERROR use of moved value: `a[..]`
1616
}
1717

1818
fn main() {

src/test/compile-fail/borrowck-vec-pattern-move-tail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ fn main() {
1414
[1, 2, tail..] => tail,
1515
_ => unreachable!()
1616
};
17-
a[0] = 0; //~ ERROR cannot assign to `a.index(&(..))` because it is borrowed
17+
a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed
1818
t[0];
1919
}

src/test/compile-fail/packed-struct-generic-transmute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ fn main() {
3434
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
3535
unsafe {
3636
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
37-
println!("{} {}", oof.rab.index(&FullRange), oof.zab);
37+
println!("{} {}", &oof.rab[], oof.zab);
3838
}
3939
}

src/test/compile-fail/slice-1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Test slicing expr.index(&(..)) is an error and gives a helpful error message.
11+
// Test slicing expr[..] is an error and gives a helpful error message.
1212

1313
struct Foo;
1414

1515
fn main() {
1616
let x = Foo;
17-
x.index(&(..)); //~ ERROR incorrect slicing expression: `[..]`
18-
//~^ NOTE use `expr.index(&FullRange)` to construct a slice of the whole of expr
17+
&x[..]; //~ ERROR incorrect slicing expression: `[..]`
18+
//~^ NOTE use `&expr[]` to construct a slice of the whole of expr
1919
}

src/test/compile-fail/slice-2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct Foo;
1616

1717
fn main() {
1818
let x = Foo;
19-
x.index(&FullRange); //~ ERROR cannot take a slice of a value with type `Foo`
20-
x.index(&(Foo..)); //~ ERROR cannot take a slice of a value with type `Foo`
21-
x.index(&(0..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
22-
x.index(&(Foo..Foo)); //~ ERROR cannot take a slice of a value with type `Foo`
19+
&x[]; //~ ERROR cannot take a slice of a value with type `Foo`
20+
&x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo`
21+
&x[0..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
22+
&x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
2323
}

src/test/compile-fail/slice-borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn main() {
1616
let y;
1717
{
1818
let x: &[int] = &[1, 2, 3, 4, 5]; //~ ERROR borrowed value does not live long enough
19-
y = x.index(&(1..));
19+
y = &x[1..];
2020
}
2121
}

src/test/compile-fail/slice-mut-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ fn main() {
1616
let x: &[int] = &[1, 2, 3, 4, 5];
1717
// Can't mutably slice an immutable slice
1818
let slice: &mut [int] = &mut [0, 1];
19-
x.index(&(2..4)) = slice; //~ ERROR cannot borrow
19+
&mut x[2..4] = slice; //~ ERROR cannot borrow
2020
}

src/test/compile-fail/slice-mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
fn main() {
1616
let x: &[int] = &[1, 2, 3, 4, 5];
1717
// Immutable slices are not mutable.
18-
let y: &mut[_] = x.index(&(2..4)); //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
18+
let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
1919
}

0 commit comments

Comments
 (0)