diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-17 14:49:49 -0700 | 
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-21 11:37:34 -0700 | 
| commit | 69ded69d630e9f908aa0cf65dba124a9eb9d6eb7 (patch) | |
| tree | f955152df5b416fa729208186a26b503f43417ef /src | |
| parent | 7397bdc9c516f3f714ad4974ecdd27f567d03d05 (diff) | |
| download | rust-69ded69d630e9f908aa0cf65dba124a9eb9d6eb7.tar.gz rust-69ded69d630e9f908aa0cf65dba124a9eb9d6eb7.zip | |
std: Remove deprecated AsOsStr/Str/AsSlice traits
Cleaning out more deprecated items
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/slice.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/string.rs | 9 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 12 | ||||
| -rw-r--r-- | src/libcore/prelude.rs | 3 | ||||
| -rw-r--r-- | src/libcore/result.rs | 26 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 31 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 24 | ||||
| -rw-r--r-- | src/libstd/ffi/mod.rs | 8 | ||||
| -rw-r--r-- | src/libstd/ffi/os_str.rs | 49 | 
10 files changed, 2 insertions, 164 deletions
| diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 5be9739cb32..6622d8a9c40 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -98,7 +98,7 @@ use self::Direction::*; use borrow::{Borrow, BorrowMut, ToOwned}; use vec::Vec; -pub use core::slice::{Chunks, AsSlice, Windows}; +pub use core::slice::{Chunks, Windows}; pub use core::slice::{Iter, IterMut}; pub use core::slice::{IntSliceExt, SplitMut, ChunksMut, Split}; pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut}; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 266cda9a237..c62bde482b7 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -67,7 +67,7 @@ use rustc_unicode; use vec::Vec; use slice::SliceConcatExt; -pub use core::str::{FromStr, Utf8Error, Str}; +pub use core::str::{FromStr, Utf8Error}; pub use core::str::{Lines, LinesAny, CharRange}; pub use core::str::{Split, RSplit}; pub use core::str::{SplitN, RSplitN}; diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 85f8a9caaaa..384c049d386 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -837,15 +837,6 @@ impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str { fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&self[..], &other[..]) } } -#[unstable(feature = "collections", reason = "waiting on Str stabilization")] -#[allow(deprecated)] -impl Str for String { - #[inline] - fn as_slice(&self) -> &str { - unsafe { mem::transmute(&*self.vec) } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl Default for String { #[inline] diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 4fa91a6a16a..813f88c4728 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1598,18 +1598,6 @@ impl<T: Ord> Ord for Vec<T> { } #[unstable(feature = "collections", - reason = "will be replaced by slice syntax")] -#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")] -#[allow(deprecated)] -impl<T> AsSlice<T> for Vec<T> { - /// Deprecated: use `&mut s[..]` instead. - #[inline] - fn as_slice(&self) -> &[T] { - self - } -} - -#[unstable(feature = "collections", reason = "recent addition, needs more experience")] impl<'a, T: Clone> Add<&'a [T]> for Vec<T> { type Output = Vec<T>; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index e60bc494081..12f01f2651c 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -42,6 +42,3 @@ pub use option::Option::{self, Some, None}; pub use result::Result::{self, Ok, Err}; pub use slice::SliceExt; pub use str::StrExt; - -#[allow(deprecated)] pub use slice::AsSlice; -#[allow(deprecated)] pub use str::Str; diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 03894926293..96f575cc548 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -234,8 +234,6 @@ use fmt; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator}; use ops::{FnMut, FnOnce}; use option::Option::{self, None, Some}; -#[allow(deprecated)] -use slice::AsSlice; use slice; /// `Result` is a type that represents either success (`Ok`) or failure (`Err`). @@ -784,30 +782,6 @@ impl<T: fmt::Debug, E> Result<T, E> { } ///////////////////////////////////////////////////////////////////////////// -// Trait implementations -///////////////////////////////////////////////////////////////////////////// - -#[unstable(feature = "core", - reason = "waiting on the stability of the trait itself")] -#[deprecated(since = "1.0.0", - reason = "use inherent method instead")] -#[allow(deprecated)] -impl<T, E> AsSlice<T> for Result<T, E> { - /// Converts from `Result<T, E>` to `&[T]` (without copying) - #[inline] - fn as_slice<'a>(&'a self) -> &'a [T] { - match *self { - Ok(ref x) => slice::ref_slice(x), - Err(_) => { - // work around lack of implicit coercion from fixed-size array to slice - let emp: &[_] = &[]; - emp - } - } - } -} - -///////////////////////////////////////////////////////////////////////////// // The Result Iterators ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 4b1742a4348..102a46a6bc8 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -595,37 +595,6 @@ impl<T> ops::IndexMut<RangeFull> for [T] { // Common traits //////////////////////////////////////////////////////////////////////////////// -/// Data that is viewable as a slice. -#[unstable(feature = "core", - reason = "will be replaced by slice syntax")] -#[deprecated(since = "1.0.0", - reason = "use std::convert::AsRef<[T]> instead")] -pub trait AsSlice<T> { - /// Work with `self` as a slice. - fn as_slice<'a>(&'a self) -> &'a [T]; -} - -#[unstable(feature = "core", reason = "trait is experimental")] -#[allow(deprecated)] -impl<T> AsSlice<T> for [T] { - #[inline(always)] - fn as_slice<'a>(&'a self) -> &'a [T] { self } -} - -#[unstable(feature = "core", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a U { - #[inline(always)] - fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) } -} - -#[unstable(feature = "core", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U { - #[inline(always)] - fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) } -} - #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Default for &'a [T] { #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 9c3ab001187..06ea52fd9d6 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1463,30 +1463,6 @@ mod traits { } } -/// Any string that can be represented as a slice -#[unstable(feature = "core", - reason = "Instead of taking this bound generically, this trait will be \ - replaced with one of slicing syntax (&foo[..]), deref coercions, or \ - a more generic conversion trait")] -#[deprecated(since = "1.0.0", - reason = "use std::convert::AsRef<str> instead")] -pub trait Str { - /// Work with `self` as a slice. - fn as_slice<'a>(&'a self) -> &'a str; -} - -#[allow(deprecated)] -impl Str for str { - #[inline] - fn as_slice<'a>(&'a self) -> &'a str { self } -} - -#[allow(deprecated)] -impl<'a, S: ?Sized> Str for &'a S where S: Str { - #[inline] - fn as_slice(&self) -> &str { Str::as_slice(*self) } -} - /// Methods for string slices #[allow(missing_docs)] #[doc(hidden)] diff --git a/src/libstd/ffi/mod.rs b/src/libstd/ffi/mod.rs index 99becb67a5a..dfe706e0773 100644 --- a/src/libstd/ffi/mod.rs +++ b/src/libstd/ffi/mod.rs @@ -20,11 +20,3 @@ pub use self::os_str::{OsString, OsStr}; mod c_str; mod os_str; - -// FIXME (#21670): these should be defined in the os_str module -/// Freely convertible to an `&OsStr` slice. -#[unstable(feature = "std_misc")] -pub trait AsOsStr { - /// Converts to an `&OsStr` slice. - fn as_os_str(&self) -> &OsStr; -} diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 08b41915d91..97bf33335b0 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -46,7 +46,6 @@ use vec::Vec; use sys::os_str::{Buf, Slice}; use sys_common::{AsInner, IntoInner, FromInner}; -use super::AsOsStr; /// Owned, mutable OS strings. #[derive(Clone)] @@ -226,14 +225,6 @@ impl OsStr { s.as_ref() } - /// Coerces directly from a `&str` slice to a `&OsStr` slice. - #[stable(feature = "rust1", since = "1.0.0")] - #[deprecated(since = "1.0.0", - reason = "use `OsStr::new` instead")] - pub fn from_str(s: &str) -> &OsStr { - unsafe { mem::transmute(Slice::from_str(s)) } - } - /// Yields a `&str` slice if the `OsStr` is valid unicode. /// /// This conversion may entail doing a check for UTF-8 validity. @@ -379,46 +370,6 @@ impl ToOwned for OsStr { } #[stable(feature = "rust1", since = "1.0.0")] -#[deprecated(since = "1.0.0", reason = "trait is deprecated")] -impl<'a, T: AsOsStr + ?Sized> AsOsStr for &'a T { - fn as_os_str(&self) -> &OsStr { - (*self).as_os_str() - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[deprecated(since = "1.0.0", reason = "trait is deprecated")] -impl AsOsStr for OsStr { - fn as_os_str(&self) -> &OsStr { - self - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[deprecated(since = "1.0.0", reason = "trait is deprecated")] -impl AsOsStr for OsString { - fn as_os_str(&self) -> &OsStr { - &self[..] - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[deprecated(since = "1.0.0", reason = "trait is deprecated")] -impl AsOsStr for str { - fn as_os_str(&self) -> &OsStr { - unsafe { mem::transmute(Slice::from_str(self)) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[deprecated(since = "1.0.0", reason = "trait is deprecated")] -impl AsOsStr for String { - fn as_os_str(&self) -> &OsStr { - unsafe { mem::transmute(Slice::from_str(self)) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] impl AsRef<OsStr> for OsStr { fn as_ref(&self) -> &OsStr { self | 
