diff options
| author | bors <bors@rust-lang.org> | 2014-12-30 00:42:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-30 00:42:13 +0000 |
| commit | fea5aa656ff4349f4d3e1fea1447d26986762ae1 (patch) | |
| tree | 3736614e84499fcde1623619b6e1336f2b2221d6 /src/test | |
| parent | 71123902e17ad339649f33423995eac78da40e3c (diff) | |
| parent | 113f8aa86b64c0be1981a69d110e42d22460b33c (diff) | |
| download | rust-fea5aa656ff4349f4d3e1fea1447d26986762ae1.tar.gz rust-fea5aa656ff4349f4d3e1fea1447d26986762ae1.zip | |
auto merge of #20160 : nick29581/rust/ranges2, r=nikomatsakis
The first six commits are from an earlier PR (#19858) and have already been reviewed. This PR makes an awful hack in the compiler to accommodate slices both natively and in the index a range form. After a snapshot we can hopefully add the new Index impls and then we can remove these awful hacks. r? @nikomatsakis (or anyone who knows the compiler, really)
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/bench/shootout-fannkuch-redux.rs | 4 | ||||
| -rw-r--r-- | src/test/bench/shootout-fasta-redux.rs | 2 | ||||
| -rw-r--r-- | src/test/bench/shootout-reverse-complement.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/range-1.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/range-2.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/slice-2.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/slice-mut-2.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/slice-mut.rs | 5 | ||||
| -rw-r--r-- | src/test/run-pass/range.rs | 2 |
9 files changed, 10 insertions, 14 deletions
diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 723b2b722d7..ef38f5ef743 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -52,7 +52,7 @@ fn rotate(x: &mut [i32]) { fn next_permutation(perm: &mut [i32], count: &mut [i32]) { for i in range(1, perm.len()) { - rotate(perm[mut ..i + 1]); + rotate(perm.slice_to_mut(i + 1)); let count_i = &mut count[i]; if *count_i >= i as i32 { *count_i = 0; @@ -131,7 +131,7 @@ impl Perm { fn reverse(tperm: &mut [i32], mut k: uint) { - tperm[mut ..k].reverse() + tperm.slice_to_mut(k).reverse() } fn work(mut perm: Perm, n: uint, max: uint) -> (i32, i32) { diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index eb18cfdaed3..178d6777939 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -128,7 +128,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { copy_memory(buf.as_mut_slice(), alu); let buf_len = buf.len(); - copy_memory(buf[mut alu_len..buf_len], + copy_memory(buf.slice_mut(alu_len, buf_len), alu[..LINE_LEN]); let mut pos = 0; diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 66965110f73..6ee2233f168 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -254,6 +254,6 @@ fn parallel<'a, I, T, F>(mut iter: I, f: F) fn main() { let mut data = read_to_end(&mut stdin_raw()).unwrap(); let tables = &Tables::new(); - parallel(mut_dna_seqs(data[mut]), |&: seq| reverse_complement(seq, tables)); + parallel(mut_dna_seqs(data.as_mut_slice()), |&: seq| reverse_complement(seq, tables)); stdout_raw().write(data.as_mut_slice()).unwrap(); } diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs index ca7401dc26c..4af748661fd 100644 --- a/src/test/compile-fail/range-1.rs +++ b/src/test/compile-fail/range-1.rs @@ -9,6 +9,7 @@ // except according to those terms. // Test range syntax - type errors. +#![feature(slicing_syntax)] pub fn main() { // Mixed types. diff --git a/src/test/compile-fail/range-2.rs b/src/test/compile-fail/range-2.rs index 40690bd844b..74c304884a0 100644 --- a/src/test/compile-fail/range-2.rs +++ b/src/test/compile-fail/range-2.rs @@ -9,6 +9,7 @@ // except according to those terms. // Test range syntax - borrow errors. +#![feature(slicing_syntax)] pub fn main() { let r = { diff --git a/src/test/compile-fail/slice-2.rs b/src/test/compile-fail/slice-2.rs index 63f79c808ae..24f710d2ae3 100644 --- a/src/test/compile-fail/slice-2.rs +++ b/src/test/compile-fail/slice-2.rs @@ -20,8 +20,4 @@ fn main() { 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[mut]; //~ ERROR cannot take a mutable slice of a value with type `Foo` - x[mut Foo..]; //~ ERROR cannot take a mutable slice of a value with type `Foo` - x[mut ..Foo]; //~ ERROR cannot take a mutable slice of a value with type `Foo` - x[mut Foo..Foo]; //~ ERROR cannot take a mutable slice of a value with type `Foo` } diff --git a/src/test/compile-fail/slice-mut-2.rs b/src/test/compile-fail/slice-mut-2.rs index 6778ed88ff7..8970bcfd153 100644 --- a/src/test/compile-fail/slice-mut-2.rs +++ b/src/test/compile-fail/slice-mut-2.rs @@ -15,5 +15,6 @@ fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; // Can't mutably slice an immutable slice - let y = x[mut 2..4]; //~ ERROR cannot borrow + let slice: &mut [int] = &mut [0, 1]; + x[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 cbfa3ed85fd..ad6b384d747 100644 --- a/src/test/compile-fail/slice-mut.rs +++ b/src/test/compile-fail/slice-mut.rs @@ -16,9 +16,4 @@ 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 x: &mut [int] = &mut [1, 2, 3, 4, 5]; - // Can't borrow mutably twice - let y = x[mut 1..2]; - let y = x[mut 4..5]; //~ERROR cannot borrow } diff --git a/src/test/run-pass/range.rs b/src/test/run-pass/range.rs index 027121dd422..864cee03f24 100644 --- a/src/test/run-pass/range.rs +++ b/src/test/run-pass/range.rs @@ -10,6 +10,8 @@ // Test range syntax. +#![feature(slicing_syntax)] + fn foo() -> int { 42 } pub fn main() { |
