Skip to content

Commit 69ded69

Browse files
committed
std: Remove deprecated AsOsStr/Str/AsSlice traits
Cleaning out more deprecated items
1 parent 7397bdc commit 69ded69

File tree

10 files changed

+2
-164
lines changed

10 files changed

+2
-164
lines changed

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use self::Direction::*;
9898
use borrow::{Borrow, BorrowMut, ToOwned};
9999
use vec::Vec;
100100

101-
pub use core::slice::{Chunks, AsSlice, Windows};
101+
pub use core::slice::{Chunks, Windows};
102102
pub use core::slice::{Iter, IterMut};
103103
pub use core::slice::{IntSliceExt, SplitMut, ChunksMut, Split};
104104
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};

src/libcollections/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use rustc_unicode;
6767
use vec::Vec;
6868
use slice::SliceConcatExt;
6969

70-
pub use core::str::{FromStr, Utf8Error, Str};
70+
pub use core::str::{FromStr, Utf8Error};
7171
pub use core::str::{Lines, LinesAny, CharRange};
7272
pub use core::str::{Split, RSplit};
7373
pub use core::str::{SplitN, RSplitN};

src/libcollections/string.rs

-9
Original file line numberDiff line numberDiff line change
@@ -837,15 +837,6 @@ impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str {
837837
fn ne(&self, other: &Cow<'a, str>) -> bool { PartialEq::ne(&self[..], &other[..]) }
838838
}
839839

840-
#[unstable(feature = "collections", reason = "waiting on Str stabilization")]
841-
#[allow(deprecated)]
842-
impl Str for String {
843-
#[inline]
844-
fn as_slice(&self) -> &str {
845-
unsafe { mem::transmute(&*self.vec) }
846-
}
847-
}
848-
849840
#[stable(feature = "rust1", since = "1.0.0")]
850841
impl Default for String {
851842
#[inline]

src/libcollections/vec.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1597,18 +1597,6 @@ impl<T: Ord> Ord for Vec<T> {
15971597
}
15981598
}
15991599

1600-
#[unstable(feature = "collections",
1601-
reason = "will be replaced by slice syntax")]
1602-
#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")]
1603-
#[allow(deprecated)]
1604-
impl<T> AsSlice<T> for Vec<T> {
1605-
/// Deprecated: use `&mut s[..]` instead.
1606-
#[inline]
1607-
fn as_slice(&self) -> &[T] {
1608-
self
1609-
}
1610-
}
1611-
16121600
#[unstable(feature = "collections",
16131601
reason = "recent addition, needs more experience")]
16141602
impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {

src/libcore/prelude.rs

-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,3 @@ pub use option::Option::{self, Some, None};
4242
pub use result::Result::{self, Ok, Err};
4343
pub use slice::SliceExt;
4444
pub use str::StrExt;
45-
46-
#[allow(deprecated)] pub use slice::AsSlice;
47-
#[allow(deprecated)] pub use str::Str;

src/libcore/result.rs

-26
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ use fmt;
234234
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator};
235235
use ops::{FnMut, FnOnce};
236236
use option::Option::{self, None, Some};
237-
#[allow(deprecated)]
238-
use slice::AsSlice;
239237
use slice;
240238

241239
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
@@ -783,30 +781,6 @@ impl<T: fmt::Debug, E> Result<T, E> {
783781
}
784782
}
785783

786-
/////////////////////////////////////////////////////////////////////////////
787-
// Trait implementations
788-
/////////////////////////////////////////////////////////////////////////////
789-
790-
#[unstable(feature = "core",
791-
reason = "waiting on the stability of the trait itself")]
792-
#[deprecated(since = "1.0.0",
793-
reason = "use inherent method instead")]
794-
#[allow(deprecated)]
795-
impl<T, E> AsSlice<T> for Result<T, E> {
796-
/// Converts from `Result<T, E>` to `&[T]` (without copying)
797-
#[inline]
798-
fn as_slice<'a>(&'a self) -> &'a [T] {
799-
match *self {
800-
Ok(ref x) => slice::ref_slice(x),
801-
Err(_) => {
802-
// work around lack of implicit coercion from fixed-size array to slice
803-
let emp: &[_] = &[];
804-
emp
805-
}
806-
}
807-
}
808-
}
809-
810784
/////////////////////////////////////////////////////////////////////////////
811785
// The Result Iterators
812786
/////////////////////////////////////////////////////////////////////////////

src/libcore/slice.rs

-31
Original file line numberDiff line numberDiff line change
@@ -595,37 +595,6 @@ impl<T> ops::IndexMut<RangeFull> for [T] {
595595
// Common traits
596596
////////////////////////////////////////////////////////////////////////////////
597597

598-
/// Data that is viewable as a slice.
599-
#[unstable(feature = "core",
600-
reason = "will be replaced by slice syntax")]
601-
#[deprecated(since = "1.0.0",
602-
reason = "use std::convert::AsRef<[T]> instead")]
603-
pub trait AsSlice<T> {
604-
/// Work with `self` as a slice.
605-
fn as_slice<'a>(&'a self) -> &'a [T];
606-
}
607-
608-
#[unstable(feature = "core", reason = "trait is experimental")]
609-
#[allow(deprecated)]
610-
impl<T> AsSlice<T> for [T] {
611-
#[inline(always)]
612-
fn as_slice<'a>(&'a self) -> &'a [T] { self }
613-
}
614-
615-
#[unstable(feature = "core", reason = "trait is experimental")]
616-
#[allow(deprecated)]
617-
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a U {
618-
#[inline(always)]
619-
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
620-
}
621-
622-
#[unstable(feature = "core", reason = "trait is experimental")]
623-
#[allow(deprecated)]
624-
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U {
625-
#[inline(always)]
626-
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
627-
}
628-
629598
#[stable(feature = "rust1", since = "1.0.0")]
630599
impl<'a, T> Default for &'a [T] {
631600
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/str/mod.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1463,30 +1463,6 @@ mod traits {
14631463
}
14641464
}
14651465

1466-
/// Any string that can be represented as a slice
1467-
#[unstable(feature = "core",
1468-
reason = "Instead of taking this bound generically, this trait will be \
1469-
replaced with one of slicing syntax (&foo[..]), deref coercions, or \
1470-
a more generic conversion trait")]
1471-
#[deprecated(since = "1.0.0",
1472-
reason = "use std::convert::AsRef<str> instead")]
1473-
pub trait Str {
1474-
/// Work with `self` as a slice.
1475-
fn as_slice<'a>(&'a self) -> &'a str;
1476-
}
1477-
1478-
#[allow(deprecated)]
1479-
impl Str for str {
1480-
#[inline]
1481-
fn as_slice<'a>(&'a self) -> &'a str { self }
1482-
}
1483-
1484-
#[allow(deprecated)]
1485-
impl<'a, S: ?Sized> Str for &'a S where S: Str {
1486-
#[inline]
1487-
fn as_slice(&self) -> &str { Str::as_slice(*self) }
1488-
}
1489-
14901466
/// Methods for string slices
14911467
#[allow(missing_docs)]
14921468
#[doc(hidden)]

src/libstd/ffi/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,3 @@ pub use self::os_str::{OsString, OsStr};
2020

2121
mod c_str;
2222
mod os_str;
23-
24-
// FIXME (#21670): these should be defined in the os_str module
25-
/// Freely convertible to an `&OsStr` slice.
26-
#[unstable(feature = "std_misc")]
27-
pub trait AsOsStr {
28-
/// Converts to an `&OsStr` slice.
29-
fn as_os_str(&self) -> &OsStr;
30-
}

src/libstd/ffi/os_str.rs

-49
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use vec::Vec;
4646

4747
use sys::os_str::{Buf, Slice};
4848
use sys_common::{AsInner, IntoInner, FromInner};
49-
use super::AsOsStr;
5049

5150
/// Owned, mutable OS strings.
5251
#[derive(Clone)]
@@ -226,14 +225,6 @@ impl OsStr {
226225
s.as_ref()
227226
}
228227

229-
/// Coerces directly from a `&str` slice to a `&OsStr` slice.
230-
#[stable(feature = "rust1", since = "1.0.0")]
231-
#[deprecated(since = "1.0.0",
232-
reason = "use `OsStr::new` instead")]
233-
pub fn from_str(s: &str) -> &OsStr {
234-
unsafe { mem::transmute(Slice::from_str(s)) }
235-
}
236-
237228
/// Yields a `&str` slice if the `OsStr` is valid unicode.
238229
///
239230
/// This conversion may entail doing a check for UTF-8 validity.
@@ -378,46 +369,6 @@ impl ToOwned for OsStr {
378369
fn to_owned(&self) -> OsString { self.to_os_string() }
379370
}
380371

381-
#[stable(feature = "rust1", since = "1.0.0")]
382-
#[deprecated(since = "1.0.0", reason = "trait is deprecated")]
383-
impl<'a, T: AsOsStr + ?Sized> AsOsStr for &'a T {
384-
fn as_os_str(&self) -> &OsStr {
385-
(*self).as_os_str()
386-
}
387-
}
388-
389-
#[stable(feature = "rust1", since = "1.0.0")]
390-
#[deprecated(since = "1.0.0", reason = "trait is deprecated")]
391-
impl AsOsStr for OsStr {
392-
fn as_os_str(&self) -> &OsStr {
393-
self
394-
}
395-
}
396-
397-
#[stable(feature = "rust1", since = "1.0.0")]
398-
#[deprecated(since = "1.0.0", reason = "trait is deprecated")]
399-
impl AsOsStr for OsString {
400-
fn as_os_str(&self) -> &OsStr {
401-
&self[..]
402-
}
403-
}
404-
405-
#[stable(feature = "rust1", since = "1.0.0")]
406-
#[deprecated(since = "1.0.0", reason = "trait is deprecated")]
407-
impl AsOsStr for str {
408-
fn as_os_str(&self) -> &OsStr {
409-
unsafe { mem::transmute(Slice::from_str(self)) }
410-
}
411-
}
412-
413-
#[stable(feature = "rust1", since = "1.0.0")]
414-
#[deprecated(since = "1.0.0", reason = "trait is deprecated")]
415-
impl AsOsStr for String {
416-
fn as_os_str(&self) -> &OsStr {
417-
unsafe { mem::transmute(Slice::from_str(self)) }
418-
}
419-
}
420-
421372
#[stable(feature = "rust1", since = "1.0.0")]
422373
impl AsRef<OsStr> for OsStr {
423374
fn as_ref(&self) -> &OsStr {

0 commit comments

Comments
 (0)