about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-07 06:17:11 +0000
committerbors <bors@rust-lang.org>2014-10-07 06:17:11 +0000
commite62ef37cfae680e60584731635a89e955121a5bb (patch)
tree768fd0552e75e5380b1122ac56448f0465df8fb3 /src/libcore
parent8d702167ba6af50c64683685bae4956cb094a23a (diff)
parenteb2fdc8b065218476744ed428097c859616c62f0 (diff)
downloadrust-e62ef37cfae680e60584731635a89e955121a5bb.tar.gz
rust-e62ef37cfae680e60584731635a89e955121a5bb.zip
auto merge of #17807 : nick29581/rust/slice6, r=aturon
r? @aturon
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/fmt/float.rs8
-rw-r--r--src/libcore/fmt/mod.rs10
-rw-r--r--src/libcore/fmt/num.rs4
-rw-r--r--src/libcore/lib.rs3
-rw-r--r--src/libcore/ops.rs52
-rw-r--r--src/libcore/option.rs4
-rw-r--r--src/libcore/prelude.rs4
-rw-r--r--src/libcore/result.rs4
-rw-r--r--src/libcore/slice.rs142
-rw-r--r--src/libcore/str.rs39
10 files changed, 188 insertions, 82 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs
index 92ef0c281f2..343ab7cfd28 100644
--- a/src/libcore/fmt/float.rs
+++ b/src/libcore/fmt/float.rs
@@ -17,7 +17,7 @@ use iter::{range, DoubleEndedIterator};
 use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};
 use num::{Zero, One, cast};
 use result::Ok;
-use slice::{ImmutableSlice, MutableSlice};
+use slice::MutableSlice;
 use slice;
 use str::StrSlice;
 
@@ -173,7 +173,7 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
         _ => ()
     }
 
-    buf.slice_to_mut(end).reverse();
+    buf[mut ..end].reverse();
 
     // Remember start of the fractional digits.
     // Points one beyond end of buf if none get generated,
@@ -310,7 +310,7 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
 
             impl<'a> fmt::FormatWriter for Filler<'a> {
                 fn write(&mut self, bytes: &[u8]) -> fmt::Result {
-                    slice::bytes::copy_memory(self.buf.slice_from_mut(*self.end),
+                    slice::bytes::copy_memory(self.buf[mut *self.end..],
                                               bytes);
                     *self.end += bytes.len();
                     Ok(())
@@ -328,5 +328,5 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
         }
     }
 
-    f(buf.slice_to(end))
+    f(buf[..end])
 }
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 7bab59960b0..093f5896aad 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -22,7 +22,7 @@ use option::{Option, Some, None};
 use ops::Deref;
 use result::{Ok, Err};
 use result;
-use slice::{Slice, ImmutableSlice};
+use slice::{AsSlice, ImmutableSlice};
 use slice;
 use str::StrSlice;
 use str;
@@ -423,7 +423,7 @@ impl<'a> Formatter<'a> {
             for c in sign.into_iter() {
                 let mut b = [0, ..4];
                 let n = c.encode_utf8(b).unwrap_or(0);
-                try!(f.buf.write(b.slice_to(n)));
+                try!(f.buf.write(b[..n]));
             }
             if prefixed { f.buf.write(prefix.as_bytes()) }
             else { Ok(()) }
@@ -530,13 +530,13 @@ impl<'a> Formatter<'a> {
         let len = self.fill.encode_utf8(fill).unwrap_or(0);
 
         for _ in range(0, pre_pad) {
-            try!(self.buf.write(fill.slice_to(len)));
+            try!(self.buf.write(fill[..len]));
         }
 
         try!(f(self));
 
         for _ in range(0, post_pad) {
-            try!(self.buf.write(fill.slice_to(len)));
+            try!(self.buf.write(fill[..len]));
         }
 
         Ok(())
@@ -611,7 +611,7 @@ impl Char for char {
 
         let mut utf8 = [0u8, ..4];
         let amt = self.encode_utf8(utf8).unwrap_or(0);
-        let s: &str = unsafe { mem::transmute(utf8.slice_to(amt)) };
+        let s: &str = unsafe { mem::transmute(utf8[..amt]) };
         secret_string(&s, f)
     }
 }
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs
index afcd0d1d645..e57c4999483 100644
--- a/src/libcore/fmt/num.rs
+++ b/src/libcore/fmt/num.rs
@@ -18,7 +18,7 @@ use collections::Collection;
 use fmt;
 use iter::DoubleEndedIterator;
 use num::{Int, cast, zero};
-use slice::{ImmutableSlice, MutableSlice};
+use slice::{MutableSlice};
 
 /// A type that represents a specific radix
 #[doc(hidden)]
@@ -60,7 +60,7 @@ trait GenericRadix {
                 if x == zero() { break; }                 // No more digits left to accumulate.
             }
         }
-        f.pad_integral(is_positive, self.prefix(), buf.slice_from(curr))
+        f.pad_integral(is_positive, self.prefix(), buf[curr..])
     }
 }
 
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 93c6f5bed85..584d09c75c8 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -57,8 +57,9 @@
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![no_std]
+#![allow(unknown_features)]
 #![feature(globs, intrinsics, lang_items, macro_rules, phase)]
-#![feature(simd, unsafe_destructor)]
+#![feature(simd, unsafe_destructor, slicing_syntax)]
 #![deny(missing_doc)]
 
 mod macros;
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index ad0f128a02e..b08432c773e 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -684,7 +684,7 @@ pub trait IndexMut<Index, Result> {
  * A trivial implementation of `Slice`. When `Foo[..Foo]` happens, it ends up
  * calling `slice_to`, and therefore, `main` prints `Slicing!`.
  *
- * ```
+ * ```ignore
  * struct Foo;
  *
  * impl ::core::ops::Slice<Foo, Foo> for Foo {
@@ -692,15 +692,15 @@ pub trait IndexMut<Index, Result> {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_from_<'a>(&'a self, from: &Foo) -> &'a Foo {
+ *     fn slice_from_or_fail<'a>(&'a self, from: &Foo) -> &'a Foo {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_to_<'a>(&'a self, to: &Foo) -> &'a Foo {
+ *     fn slice_to_or_fail<'a>(&'a self, to: &Foo) -> &'a Foo {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_<'a>(&'a self, from: &Foo, to: &Foo) -> &'a Foo {
+ *     fn slice_or_fail<'a>(&'a self, from: &Foo, to: &Foo) -> &'a Foo {
  *         println!("Slicing!");
  *         self
  *     }
@@ -711,7 +711,22 @@ pub trait IndexMut<Index, Result> {
  * }
  * ```
  */
-// FIXME(#17273) remove the postscript _s
+#[cfg(not(stage0))]
+#[lang="slice"]
+pub trait Slice<Idx, Sized? Result> for Sized? {
+    /// The method for the slicing operation foo[]
+    fn as_slice_<'a>(&'a self) -> &'a Result;
+    /// The method for the slicing operation foo[from..]
+    fn slice_from_or_fail<'a>(&'a self, from: &Idx) -> &'a Result;
+    /// The method for the slicing operation foo[..to]
+    fn slice_to_or_fail<'a>(&'a self, to: &Idx) -> &'a Result;
+    /// The method for the slicing operation foo[from..to]
+    fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
+}
+#[cfg(stage0)]
+/**
+ *
+ */
 #[lang="slice"]
 pub trait Slice<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[]
@@ -734,7 +749,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
  * A trivial implementation of `SliceMut`. When `Foo[Foo..]` happens, it ends up
  * calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
  *
- * ```
+ * ```ignore
  * struct Foo;
  *
  * impl ::core::ops::SliceMut<Foo, Foo> for Foo {
@@ -742,26 +757,41 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_from_mut_<'a>(&'a mut self, from: &Foo) -> &'a mut Foo {
+ *     fn slice_from_or_fail_mut<'a>(&'a mut self, from: &Foo) -> &'a mut Foo {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_to_mut_<'a>(&'a mut self, to: &Foo) -> &'a mut Foo {
+ *     fn slice_to_or_fail_mut<'a>(&'a mut self, to: &Foo) -> &'a mut Foo {
  *         println!("Slicing!");
  *         self
  *     }
- *     fn slice_mut_<'a>(&'a mut self, from: &Foo, to: &Foo) -> &'a mut Foo {
+ *     fn slice_or_fail_mut<'a>(&'a mut self, from: &Foo, to: &Foo) -> &'a mut Foo {
  *         println!("Slicing!");
  *         self
  *     }
  * }
  *
- * fn main() {
+ * pub fn main() {
  *     Foo[mut Foo..];
  * }
  * ```
  */
-// FIXME(#17273) remove the postscript _s
+#[cfg(not(stage0))]
+#[lang="slice_mut"]
+pub trait SliceMut<Idx, Sized? Result> for Sized? {
+    /// The method for the slicing operation foo[]
+    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
+    /// The method for the slicing operation foo[from..]
+    fn slice_from_or_fail_mut<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
+    /// The method for the slicing operation foo[..to]
+    fn slice_to_or_fail_mut<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
+    /// The method for the slicing operation foo[from..to]
+    fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
+}
+#[cfg(stage0)]
+/**
+ *
+ */
 #[lang="slice_mut"]
 pub trait SliceMut<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[mut]
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 1e353708730..9b66f900d9c 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -149,7 +149,7 @@ use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
 use mem;
 use result::{Result, Ok, Err};
 use slice;
-use slice::Slice;
+use slice::AsSlice;
 
 // Note that this is not a lang item per se, but it has a hidden dependency on
 // `Iterator`, which is one. The compiler assumes that the `next` method of
@@ -846,7 +846,7 @@ impl<T: Default> Option<T> {
 // Trait implementations
 /////////////////////////////////////////////////////////////////////////////
 
-impl<T> Slice<T> for Option<T> {
+impl<T> AsSlice<T> for Option<T> {
     /// Convert from `Option<T>` to `&[T]` (without copying)
     #[inline]
     #[stable]
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index ead48092c4d..680f91945d1 100644
--- a/src/libcore/prelude.rs
+++ b/src/libcore/prelude.rs
@@ -35,6 +35,7 @@ pub use ops::{BitAnd, BitOr, BitXor};
 pub use ops::{Drop, Deref, DerefMut};
 pub use ops::{Shl, Shr};
 pub use ops::{Index, IndexMut};
+pub use ops::{Slice, SliceMut};
 pub use ops::{Fn, FnMut, FnOnce};
 pub use option::{Option, Some, None};
 pub use result::{Result, Ok, Err};
@@ -62,5 +63,4 @@ pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
 pub use slice::{ImmutablePartialEqSlice, ImmutableOrdSlice};
-pub use slice::{MutableSlice};
-pub use slice::{Slice, ImmutableSlice};
+pub use slice::{AsSlice, ImmutableSlice, MutableSlice};
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 9f347aacedc..caede952e2f 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -280,7 +280,7 @@ use clone::Clone;
 use cmp::PartialEq;
 use std::fmt::Show;
 use slice;
-use slice::Slice;
+use slice::AsSlice;
 use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
 use option::{None, Option, Some};
 
@@ -844,7 +844,7 @@ impl<T: Show, E> Result<T, E> {
 // Trait implementations
 /////////////////////////////////////////////////////////////////////////////
 
-impl<T, E> Slice<T> for Result<T, E> {
+impl<T, E> AsSlice<T> for Result<T, E> {
     /// Convert from `Result<T, E>` to `&[T]` (without copying)
     #[inline]
     #[stable]
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index c7ffd8f5617..7246fc367f8 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -67,7 +67,7 @@ pub trait ImmutableSlice<'a, T> {
     /// original slice (i.e. when `end > self.len()`) or when `start > end`.
     ///
     /// Slicing with `start` equal to `end` yields an empty slice.
-    #[unstable = "waiting on final error conventions"]
+    #[unstable = "waiting on final error conventions/slicing syntax"]
     fn slice(&self, start: uint, end: uint) -> &'a [T];
 
     /// Returns a subslice from `start` to the end of the slice.
@@ -75,7 +75,7 @@ pub trait ImmutableSlice<'a, T> {
     /// Fails when `start` is strictly greater than the length of the original slice.
     ///
     /// Slicing from `self.len()` yields an empty slice.
-    #[unstable = "waiting on final error conventions"]
+    #[unstable = "waiting on final error conventions/slicing syntax"]
     fn slice_from(&self, start: uint) -> &'a [T];
 
     /// Returns a subslice from the start of the slice to `end`.
@@ -83,7 +83,7 @@ pub trait ImmutableSlice<'a, T> {
     /// Fails when `end` is strictly greater than the length of the original slice.
     ///
     /// Slicing to `0` yields an empty slice.
-    #[unstable = "waiting on final error conventions"]
+    #[unstable = "waiting on final error conventions/slicing syntax"]
     fn slice_to(&self, end: uint) -> &'a [T];
 
     /// Divides one slice into two at an index.
@@ -262,7 +262,7 @@ pub trait ImmutableSlice<'a, T> {
      * ```ignore
      *     if self.len() == 0 { return None }
      *     let head = &self[0];
-     *     *self = self.slice_from(1);
+     *     *self = self[1..];
      *     Some(head)
      * ```
      *
@@ -281,7 +281,7 @@ pub trait ImmutableSlice<'a, T> {
      * ```ignore
      *     if self.len() == 0 { return None; }
      *     let tail = &self[self.len() - 1];
-     *     *self = self.slice_to(self.len() - 1);
+     *     *self = self[..self.len() - 1];
      *     Some(tail)
      * ```
      *
@@ -299,9 +299,9 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
         assert!(end <= self.len());
         unsafe {
             transmute(RawSlice {
-                    data: self.as_ptr().offset(start as int),
-                    len: (end - start)
-                })
+                data: self.as_ptr().offset(start as int),
+                len: (end - start)
+            })
         }
     }
 
@@ -317,7 +317,7 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
 
     #[inline]
     fn split_at(&self, mid: uint) -> (&'a [T], &'a [T]) {
-        (self.slice(0, mid), self.slice(mid, self.len()))
+        ((*self)[..mid], (*self)[mid..])
     }
 
     #[inline]
@@ -386,21 +386,21 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
     }
 
     #[inline]
-    fn tail(&self) -> &'a [T] { self.slice(1, self.len()) }
+    fn tail(&self) -> &'a [T] { (*self)[1..] }
 
     #[inline]
     #[deprecated = "use slice_from"]
-    fn tailn(&self, n: uint) -> &'a [T] { self.slice(n, self.len()) }
+    fn tailn(&self, n: uint) -> &'a [T] { (*self)[n..] }
 
     #[inline]
     fn init(&self) -> &'a [T] {
-        self.slice(0, self.len() - 1)
+        (*self)[..self.len() - 1]
     }
 
     #[inline]
     #[deprecated = "use slice_to but note the arguments are different"]
     fn initn(&self, n: uint) -> &'a [T] {
-        self.slice(0, self.len() - n)
+        (*self)[..self.len() - n]
     }
 
     #[inline]
@@ -486,6 +486,37 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
     }
 }
 
+
+
+#[cfg(not(stage0))]
+impl<T> ops::Slice<uint, [T]> for [T] {
+    #[inline]
+    fn as_slice_<'a>(&'a self) -> &'a [T] {
+        self
+    }
+
+    #[inline]
+    fn slice_from_or_fail<'a>(&'a self, start: &uint) -> &'a [T] {
+        self.slice_or_fail(start, &self.len())
+    }
+
+    #[inline]
+    fn slice_to_or_fail<'a>(&'a self, end: &uint) -> &'a [T] {
+        self.slice_or_fail(&0, end)
+    }
+    #[inline]
+    fn slice_or_fail<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
+        assert!(*start <= *end);
+        assert!(*end <= self.len());
+        unsafe {
+            transmute(RawSlice {
+                    data: self.as_ptr().offset(*start as int),
+                    len: (*end - *start)
+                })
+        }
+    }
+}
+#[cfg(stage0)]
 impl<T> ops::Slice<uint, [T]> for [T] {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -514,6 +545,36 @@ impl<T> ops::Slice<uint, [T]> for [T] {
     }
 }
 
+#[cfg(not(stage0))]
+impl<T> ops::SliceMut<uint, [T]> for [T] {
+    #[inline]
+    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
+        self
+    }
+
+    #[inline]
+    fn slice_from_or_fail_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
+        let len = &self.len();
+        self.slice_or_fail_mut(start, len)
+    }
+
+    #[inline]
+    fn slice_to_or_fail_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
+        self.slice_or_fail_mut(&0, end)
+    }
+    #[inline]
+    fn slice_or_fail_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
+        assert!(*start <= *end);
+        assert!(*end <= self.len());
+        unsafe {
+            transmute(RawSlice {
+                    data: self.as_ptr().offset(*start as int),
+                    len: (*end - *start)
+                })
+        }
+    }
+}
+#[cfg(stage0)]
 impl<T> ops::SliceMut<uint, [T]> for [T] {
     #[inline]
     fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
@@ -681,7 +742,7 @@ pub trait MutableSlice<'a, T> {
      * ```ignore
      *     if self.len() == 0 { return None; }
      *     let head = &mut self[0];
-     *     *self = self.slice_from_mut(1);
+     *     *self = self[mut 1..];
      *     Some(head)
      * ```
      *
@@ -700,7 +761,7 @@ pub trait MutableSlice<'a, T> {
      * ```ignore
      *     if self.len() == 0 { return None; }
      *     let tail = &mut self[self.len() - 1];
-     *     *self = self.slice_to_mut(self.len() - 1);
+     *     *self = self[mut ..self.len() - 1];
      *     Some(tail)
      * ```
      *
@@ -826,33 +887,24 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] {
     fn as_mut_slice(self) -> &'a mut [T] { self }
 
     fn slice_mut(self, start: uint, end: uint) -> &'a mut [T] {
-        assert!(start <= end);
-        assert!(end <= self.len());
-        unsafe {
-            transmute(RawSlice {
-                    data: self.as_mut_ptr().offset(start as int) as *const T,
-                    len: (end - start)
-                })
-        }
+        self[mut start..end]
     }
 
     #[inline]
     fn slice_from_mut(self, start: uint) -> &'a mut [T] {
-        let len = self.len();
-        self.slice_mut(start, len)
+        self[mut start..]
     }
 
     #[inline]
     fn slice_to_mut(self, end: uint) -> &'a mut [T] {
-        self.slice_mut(0, end)
+        self[mut ..end]
     }
 
     #[inline]
     fn split_at_mut(self, mid: uint) -> (&'a mut [T], &'a mut [T]) {
         unsafe {
-            let len = self.len();
             let self2: &'a mut [T] = mem::transmute_copy(&self);
-            (self.slice_mut(0, mid), self2.slice_mut(mid, len))
+            (self[mut ..mid], self2[mut mid..])
         }
     }
 
@@ -889,13 +941,13 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] {
     #[inline]
     fn tail_mut(self) -> &'a mut [T] {
         let len = self.len();
-        self.slice_mut(1, len)
+        self[mut 1..len]
     }
 
     #[inline]
     fn init_mut(self) -> &'a mut [T] {
         let len = self.len();
-        self.slice_mut(0, len - 1)
+        self[mut 0..len - 1]
     }
 
     #[inline]
@@ -1042,13 +1094,13 @@ impl<'a,T:PartialEq> ImmutablePartialEqSlice<T> for &'a [T] {
     #[inline]
     fn starts_with(&self, needle: &[T]) -> bool {
         let n = needle.len();
-        self.len() >= n && needle == self.slice_to(n)
+        self.len() >= n && needle == (*self)[..n]
     }
 
     #[inline]
     fn ends_with(&self, needle: &[T]) -> bool {
         let (m, n) = (self.len(), needle.len());
-        m >= n && needle == self.slice_from(m - n)
+        m >= n && needle == (*self)[m-n..]
     }
 }
 
@@ -1152,13 +1204,13 @@ impl<'a, T:Clone> MutableCloneableSlice<T> for &'a mut [T] {
 
 /// Data that is viewable as a slice.
 #[unstable = "may merge with other traits"]
-pub trait Slice<T> {
+pub trait AsSlice<T> {
     /// Work with `self` as a slice.
     fn as_slice<'a>(&'a self) -> &'a [T];
 }
 
 #[unstable = "trait is unstable"]
-impl<'a,T> Slice<T> for &'a [T] {
+impl<'a,T> AsSlice<T> for &'a [T] {
     #[inline(always)]
     fn as_slice<'a>(&'a self) -> &'a [T] { *self }
 }
@@ -1339,8 +1391,8 @@ impl<'a, T> Iterator<&'a [T]> for Splits<'a, T> {
         match self.v.iter().position(|x| (self.pred)(x)) {
             None => self.finish(),
             Some(idx) => {
-                let ret = Some(self.v.slice(0, idx));
-                self.v = self.v.slice(idx + 1, self.v.len());
+                let ret = Some(self.v[..idx]);
+                self.v = self.v[idx + 1..];
                 ret
             }
         }
@@ -1365,8 +1417,8 @@ impl<'a, T> DoubleEndedIterator<&'a [T]> for Splits<'a, T> {
         match self.v.iter().rposition(|x| (self.pred)(x)) {
             None => self.finish(),
             Some(idx) => {
-                let ret = Some(self.v.slice(idx + 1, self.v.len()));
-                self.v = self.v.slice(0, idx);
+                let ret = Some(self.v[idx + 1..]);
+                self.v = self.v[..idx];
                 ret
             }
         }
@@ -1416,7 +1468,7 @@ impl<'a, T> Iterator<&'a mut [T]> for MutSplits<'a, T> {
             Some(idx) => {
                 let tmp = mem::replace(&mut self.v, &mut []);
                 let (head, tail) = tmp.split_at_mut(idx);
-                self.v = tail.slice_from_mut(1);
+                self.v = tail[mut 1..];
                 Some(head)
             }
         }
@@ -1450,7 +1502,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T> {
                 let tmp = mem::replace(&mut self.v, &mut []);
                 let (head, tail) = tmp.split_at_mut(idx);
                 self.v = head;
-                Some(tail.slice_from_mut(1))
+                Some(tail[mut 1..])
             }
         }
     }
@@ -1498,8 +1550,8 @@ impl<'a, T> Iterator<&'a [T]> for Windows<'a, T> {
         if self.size > self.v.len() {
             None
         } else {
-            let ret = Some(self.v.slice(0, self.size));
-            self.v = self.v.slice(1, self.v.len());
+            let ret = Some(self.v[..self.size]);
+            self.v = self.v[1..];
             ret
         }
     }
@@ -1583,7 +1635,7 @@ impl<'a, T> RandomAccessIterator<&'a [T]> for Chunks<'a, T> {
             let mut hi = lo + self.size;
             if hi < lo || hi > self.v.len() { hi = self.v.len(); }
 
-            Some(self.v.slice(lo, hi))
+            Some(self.v[lo..hi])
         } else {
             None
         }
@@ -1837,7 +1889,7 @@ impl<'a,T:PartialEq> PartialEq for &'a [T] {
 impl<'a,T:Eq> Eq for &'a [T] {}
 
 #[unstable = "waiting for DST"]
-impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a [T] {
+impl<'a,T:PartialEq, V: AsSlice<T>> Equiv<V> for &'a [T] {
     #[inline]
     fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
 }
@@ -1858,7 +1910,7 @@ impl<'a,T:PartialEq> PartialEq for &'a mut [T] {
 impl<'a,T:Eq> Eq for &'a mut [T] {}
 
 #[unstable = "waiting for DST"]
-impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a mut [T] {
+impl<'a,T:PartialEq, V: AsSlice<T>> Equiv<V> for &'a mut [T] {
     #[inline]
     fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
 }
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index fd7c63a6b32..6099af0e78f 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -30,7 +30,7 @@ use iter::range;
 use num::{CheckedMul, Saturating};
 use option::{Option, None, Some};
 use raw::Repr;
-use slice::{ImmutableSlice, MutableSlice};
+use slice::ImmutableSlice;
 use slice;
 use uint;
 
@@ -393,7 +393,7 @@ impl NaiveSearcher {
 
     fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
         while self.position + needle.len() <= haystack.len() {
-            if haystack.slice(self.position, self.position + needle.len()) == needle {
+            if haystack[self.position .. self.position + needle.len()] == needle {
                 let match_pos = self.position;
                 self.position += needle.len(); // add 1 for all matches
                 return Some((match_pos, match_pos + needle.len()));
@@ -514,10 +514,10 @@ impl TwoWaySearcher {
         //
         // What's going on is we have some critical factorization (u, v) of the
         // needle, and we want to determine whether u is a suffix of
-        // v.slice_to(period). If it is, we use "Algorithm CP1". Otherwise we use
+        // v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
         // "Algorithm CP2", which is optimized for when the period of the needle
         // is large.
-        if needle.slice_to(crit_pos) == needle.slice(period, period + crit_pos) {
+        if needle[..crit_pos] == needle[period.. period + crit_pos] {
             TwoWaySearcher {
                 crit_pos: crit_pos,
                 period: period,
@@ -741,7 +741,7 @@ impl<'a> Iterator<u16> for Utf16CodeUnits<'a> {
 
         let mut buf = [0u16, ..2];
         self.chars.next().map(|ch| {
-            let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
+            let n = ch.encode_utf16(buf[mut]).unwrap_or(0);
             if n == 2 { self.extra = buf[1]; }
             buf[0]
         })
@@ -1007,7 +1007,7 @@ pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a> {
 pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
     match v.iter().position(|c| *c == 0) {
         // don't include the 0
-        Some(i) => v.slice_to(i),
+        Some(i) => v[..i],
         None => v
     }
 }
@@ -1164,6 +1164,7 @@ pub mod traits {
         fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
     }
 
+    #[cfg(stage0)]
     impl ops::Slice<uint, str> for str {
         #[inline]
         fn as_slice_<'a>(&'a self) -> &'a str {
@@ -1185,6 +1186,28 @@ pub mod traits {
             self.slice(*from, *to)
         }
     }
+    #[cfg(not(stage0))]
+    impl ops::Slice<uint, str> for str {
+        #[inline]
+        fn as_slice_<'a>(&'a self) -> &'a str {
+            self
+        }
+
+        #[inline]
+        fn slice_from_or_fail<'a>(&'a self, from: &uint) -> &'a str {
+            self.slice_from(*from)
+        }
+
+        #[inline]
+        fn slice_to_or_fail<'a>(&'a self, to: &uint) -> &'a str {
+            self.slice_to(*to)
+        }
+
+        #[inline]
+        fn slice_or_fail<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
+            self.slice(*from, *to)
+        }
+    }
 }
 
 /// Any string that can be represented as a slice
@@ -1994,13 +2017,13 @@ impl<'a> StrSlice<'a> for &'a str {
     #[inline]
     fn starts_with<'a>(&self, needle: &'a str) -> bool {
         let n = needle.len();
-        self.len() >= n && needle.as_bytes() == self.as_bytes().slice_to(n)
+        self.len() >= n && needle.as_bytes() == self.as_bytes()[..n]
     }
 
     #[inline]
     fn ends_with(&self, needle: &str) -> bool {
         let (m, n) = (self.len(), needle.len());
-        m >= n && needle.as_bytes() == self.as_bytes().slice_from(m - n)
+        m >= n && needle.as_bytes() == self.as_bytes()[m-n..]
     }
 
     #[inline]