diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-01-02 13:56:28 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-01-07 10:46:33 +1300 |
| commit | f7ff37e4c52a1d6562635fcd5bab6309cf75ea08 (patch) | |
| tree | 9c69736bf3830f9048f61d45943bf0fa6326782d /src/test | |
| parent | 918255ef8c3c21b2009204c3019239f8dc9f46bf (diff) | |
| download | rust-f7ff37e4c52a1d6562635fcd5bab6309cf75ea08.tar.gz rust-f7ff37e4c52a1d6562635fcd5bab6309cf75ea08.zip | |
Replace full slice notation with index calls
Diffstat (limited to 'src/test')
23 files changed, 47 insertions, 47 deletions
diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index bbbfb0051f9..7109dc7948e 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -130,7 +130,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { copy_memory(buf.as_mut_slice(), alu); let buf_len = buf.len(); copy_memory(buf.slice_mut(alu_len, buf_len), - alu[..LINE_LEN]); + alu.index(&(0..LINE_LEN))); let mut pos = 0; let mut bytes; @@ -206,7 +206,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> { for i in range(0u, chars_left) { buf[i] = self.nextc(); } - self.out.write(buf[..chars_left]) + self.out.write(buf.index(&(0..chars_left))) } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 28d7488c9bf..65127868b87 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -247,14 +247,14 @@ fn generate_frequencies(mut input: &[u8], frame: uint) -> Table { // Pull first frame. for _ in range(0, frame) { code = code.push_char(input[0]); - input = input[1..]; + input = input.index(&(1..)); } frequencies.lookup(code, BumpCallback); while input.len() != 0 && input[0] != ('>' as u8) { code = code.rotate(input[0], frame); frequencies.lookup(code, BumpCallback); - input = input[1..]; + input = input.index(&(1..)); } frequencies } diff --git a/src/test/compile-fail/borrowck-array-double-move.rs b/src/test/compile-fail/borrowck-array-double-move.rs index c872d0dc4b9..79a6dd005a7 100644 --- a/src/test/compile-fail/borrowck-array-double-move.rs +++ b/src/test/compile-fail/borrowck-array-double-move.rs @@ -12,7 +12,7 @@ fn f() { let mut a = [box 0i, box 1i]; drop(a[0]); a[1] = box 2i; - drop(a[0]); //~ ERROR use of moved value: `a[..]` + drop(a[0]); //~ ERROR use of moved value: `a.index(&(..))` } fn main() { diff --git a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs index cb8762f44fb..b328ea722a0 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs @@ -14,6 +14,6 @@ fn main() { [1, 2, tail..] => tail, _ => unreachable!() }; - a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed + a[0] = 0; //~ ERROR cannot assign to `a.index(&(..))` because it is borrowed t[0]; } diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs index 5c0aba42b96..0d8631788a9 100644 --- a/src/test/compile-fail/packed-struct-generic-transmute.rs +++ b/src/test/compile-fail/packed-struct-generic-transmute.rs @@ -34,6 +34,6 @@ fn main() { let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 }; unsafe { let oof: Oof<[u8; 5], i32> = mem::transmute(foo); - println!("{} {}", oof.rab[], oof.zab); + println!("{} {}", oof.rab.index(&FullRange), oof.zab); } } diff --git a/src/test/compile-fail/slice-1.rs b/src/test/compile-fail/slice-1.rs index d0339745c9e..26281c2e907 100644 --- a/src/test/compile-fail/slice-1.rs +++ b/src/test/compile-fail/slice-1.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test slicing expr[..] is an error and gives a helpful error message. +// Test slicing expr.index(&(..)) is an error and gives a helpful error message. struct Foo; fn main() { let x = Foo; - x[..]; //~ ERROR incorrect slicing expression: `[..]` - //~^ NOTE use `expr[]` to construct a slice of the whole of expr + x.index(&(..)); //~ ERROR incorrect slicing expression: `[..]` + //~^ NOTE use `expr.index(&FullRange)` to construct a slice of the whole of expr } diff --git a/src/test/compile-fail/slice-2.rs b/src/test/compile-fail/slice-2.rs index 24f710d2ae3..1e850d6307e 100644 --- a/src/test/compile-fail/slice-2.rs +++ b/src/test/compile-fail/slice-2.rs @@ -16,8 +16,8 @@ struct Foo; fn main() { let x = Foo; - x[]; //~ ERROR cannot take a slice of a value with type `Foo` - x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo` - x[..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` - x[Foo..Foo]; //~ ERROR cannot take a slice of a value with type `Foo` + x.index(&FullRange); //~ ERROR cannot take a slice of a value with type `Foo` + x.index(&(Foo..)); //~ ERROR cannot take a slice of a value with type `Foo` + x.index(&(0..Foo)); //~ ERROR cannot take a slice of a value with type `Foo` + x.index(&(Foo..Foo)); //~ ERROR cannot take a slice of a value with type `Foo` } diff --git a/src/test/compile-fail/slice-borrow.rs b/src/test/compile-fail/slice-borrow.rs index 00783b71ea1..7839013ee22 100644 --- a/src/test/compile-fail/slice-borrow.rs +++ b/src/test/compile-fail/slice-borrow.rs @@ -16,6 +16,6 @@ fn main() { let y; { let x: &[int] = &[1, 2, 3, 4, 5]; //~ ERROR borrowed value does not live long enough - y = x[1..]; + y = x.index(&(1..)); } } diff --git a/src/test/compile-fail/slice-mut-2.rs b/src/test/compile-fail/slice-mut-2.rs index 8970bcfd153..b7d7ea67f06 100644 --- a/src/test/compile-fail/slice-mut-2.rs +++ b/src/test/compile-fail/slice-mut-2.rs @@ -16,5 +16,5 @@ fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; // Can't mutably slice an immutable slice let slice: &mut [int] = &mut [0, 1]; - x[2..4] = slice; //~ ERROR cannot borrow + x.index(&(2..4)) = slice; //~ ERROR cannot borrow } diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs index ad6b384d747..3d621580f5d 100644 --- a/src/test/compile-fail/slice-mut.rs +++ b/src/test/compile-fail/slice-mut.rs @@ -15,5 +15,5 @@ fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; // Immutable slices are not mutable. - let y: &mut[_] = x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl + let y: &mut[_] = x.index(&(2..4)); //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl } diff --git a/src/test/debuginfo/vec-slices.rs b/src/test/debuginfo/vec-slices.rs index 70211d74d88..f2cb5f82a6c 100644 --- a/src/test/debuginfo/vec-slices.rs +++ b/src/test/debuginfo/vec-slices.rs @@ -93,7 +93,7 @@ fn main() { let empty: &[i64] = &[]; let singleton: &[i64] = &[1]; let multiple: &[i64] = &[2, 3, 4, 5]; - let slice_of_slice = multiple[1..3]; + let slice_of_slice = multiple.index(&(1..3)); let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)]; diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 24df95ffd3c..6eb4bc352d1 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A: let mut rbml_w = EBwriter::Encoder::new(&mut wr); a1.encode(&mut rbml_w); - let d: serialize::rbml::Doc<'a> = EBDoc::new(wr[]); + let d: serialize::rbml::Doc<'a> = EBDoc::new(wr.index(&FullRange)); let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d); let a2: A = Decodable::decode(&mut decoder); assert!(*a1 == a2); diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs index 2466d0adf7b..459060d349c 100644 --- a/src/test/run-pass/deriving-encodable-decodable.rs +++ b/src/test/run-pass/deriving-encodable-decodable.rs @@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> + let mut w = Vec::new(); let mut e = Encoder::new(&mut w); obj.encode(&mut e); - let doc = rbml::Doc::new(@w[]); + let doc = rbml::Doc::new(@w.index(&FullRange)); let mut dec = Decoder::new(doc); let obj2 = Decodable::decode(&mut dec); assert!(obj == obj2); diff --git a/src/test/run-pass/issue-15730.rs b/src/test/run-pass/issue-15730.rs index a1a5922e150..4e1aa454a88 100644 --- a/src/test/run-pass/issue-15730.rs +++ b/src/test/run-pass/issue-15730.rs @@ -12,5 +12,5 @@ fn main() { let mut array = [1, 2, 3]; - let pie_slice = array[1..2]; + let pie_slice = &array[1..2]; } diff --git a/src/test/run-pass/issue-17503.rs b/src/test/run-pass/issue-17503.rs index 986879e8e46..9d1a51ad79c 100644 --- a/src/test/run-pass/issue-17503.rs +++ b/src/test/run-pass/issue-17503.rs @@ -15,7 +15,7 @@ fn main() { let ss: &&[int] = &s; let sss: &&&[int] = &ss; - println!("{}", s[..3]); - println!("{}", ss[3..]); - println!("{}", sss[2..4]); + println!("{}", s.index(&(0..3))); + println!("{}", ss.index(&(3..))); + println!("{}", sss.index(&(2..4))); } diff --git a/src/test/run-pass/issue-3888-2.rs b/src/test/run-pass/issue-3888-2.rs index 10add853ee7..115a96d5289 100644 --- a/src/test/run-pass/issue-3888-2.rs +++ b/src/test/run-pass/issue-3888-2.rs @@ -11,7 +11,7 @@ #![feature(slicing_syntax)] fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] { - v[1..5] + v.index(&(1..5)) } pub fn main() {} diff --git a/src/test/run-pass/issue-4464.rs b/src/test/run-pass/issue-4464.rs index f2c1a715b51..fa75b5d2583 100644 --- a/src/test/run-pass/issue-4464.rs +++ b/src/test/run-pass/issue-4464.rs @@ -10,6 +10,6 @@ #![feature(slicing_syntax)] -fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v[i..j] } +fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v.index(&(i..j)) } pub fn main() {} diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index 305f984f98e..706f640c18d 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -18,11 +18,11 @@ pub fn main() { let abc = [1i, 2, 3]; let tf = [true, false]; let x = [(), ()]; - let slice = x[0..1]; + let slice = x.index(&(0..1)); - assert_repr_eq(abc[], "[1, 2, 3]".to_string()); - assert_repr_eq(tf[], "[true, false]".to_string()); - assert_repr_eq(x[], "[(), ()]".to_string()); + assert_repr_eq(abc.index(&FullRange), "[1, 2, 3]".to_string()); + assert_repr_eq(tf.index(&FullRange), "[true, false]".to_string()); + assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string()); assert_repr_eq(slice, "[()]".to_string()); - assert_repr_eq(x[], "[(), ()]".to_string()); + assert_repr_eq(x.index(&FullRange), "[(), ()]".to_string()); } diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index 0781822cb74..e5a61763463 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -19,5 +19,5 @@ pub fn main() { print!("{}, ", (*xi)[]); } println!("]"); - println!("{}", y[]); + println!("{}", y.index(&FullRange)); } diff --git a/src/test/run-pass/slice-2.rs b/src/test/run-pass/slice-2.rs index f03b4609637..7be05b9d71e 100644 --- a/src/test/run-pass/slice-2.rs +++ b/src/test/run-pass/slice-2.rs @@ -15,23 +15,23 @@ fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; let cmp: &[int] = &[1, 2, 3, 4, 5]; - assert!(x[] == cmp); + assert!(x.index(&FullRange) == cmp); let cmp: &[int] = &[3, 4, 5]; - assert!(x[2..] == cmp); + assert!(x.index(&(2..)) == cmp); let cmp: &[int] = &[1, 2, 3]; - assert!(x[..3] == cmp); + assert!(x.index(&(0..3)) == cmp); let cmp: &[int] = &[2, 3, 4]; - assert!(x[1..4] == cmp); + assert!(x.index(&(1..4)) == cmp); let x: Vec<int> = vec![1, 2, 3, 4, 5]; let cmp: &[int] = &[1, 2, 3, 4, 5]; - assert!(x[] == cmp); + assert!(x.index(&FullRange) == cmp); let cmp: &[int] = &[3, 4, 5]; - assert!(x[2..] == cmp); + assert!(x.index(&(2..)) == cmp); let cmp: &[int] = &[1, 2, 3]; - assert!(x[..3] == cmp); + assert!(x.index(&(0..3)) == cmp); let cmp: &[int] = &[2, 3, 4]; - assert!(x[1..4] == cmp); + assert!(x.index(&(1..4)) == cmp); let x: &mut [int] = &mut [1, 2, 3, 4, 5]; { diff --git a/src/test/run-pass/slice-panic-1.rs b/src/test/run-pass/slice-panic-1.rs index 13f2971871b..87de4246f3e 100644 --- a/src/test/run-pass/slice-panic-1.rs +++ b/src/test/run-pass/slice-panic-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that is a slicing expr[..] fails, the correct cleanups happen. +// Test that is a slicing expr.index(&(..)) fails, the correct cleanups happen. #![feature(slicing_syntax)] @@ -24,7 +24,7 @@ impl Drop for Foo { fn foo() { let x: &[_] = &[Foo, Foo]; - x[3..4]; + x.index(&(3..4)); } fn main() { diff --git a/src/test/run-pass/slice-panic-2.rs b/src/test/run-pass/slice-panic-2.rs index ccbb33d7768..afffaba64de 100644 --- a/src/test/run-pass/slice-panic-2.rs +++ b/src/test/run-pass/slice-panic-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that is a slicing expr[..] fails, the correct cleanups happen. +// Test that is a slicing expr.index(&(..)) fails, the correct cleanups happen. #![feature(slicing_syntax)] diff --git a/src/test/run-pass/slice.rs b/src/test/run-pass/slice.rs index f863c4d330f..c6dfc8dfd23 100644 --- a/src/test/run-pass/slice.rs +++ b/src/test/run-pass/slice.rs @@ -58,10 +58,10 @@ impl SliceMut<Foo, Foo> for Foo { } fn main() { let mut x = Foo; - x[]; - x[Foo..]; - x[..Foo]; - x[Foo..Foo]; + x.index(&FullRange); + x.index(&(Foo..)); + x.index(&(0..Foo)); + x.index(&(Foo..Foo)); x[mut]; x[mut Foo..]; x[mut ..Foo]; |
