diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-05-24 14:24:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-05-30 20:46:32 -0700 |
| commit | b64c9d56700e2c41207166fe8709711ff02488ff (patch) | |
| tree | 82e982ea6a6840e3f0f4d3d82a4d2ad24771200b /src/libcore | |
| parent | a967611d8ffececb5ed0ecf6a205b464d7a5a31e (diff) | |
| download | rust-b64c9d56700e2c41207166fe8709711ff02488ff.tar.gz rust-b64c9d56700e2c41207166fe8709711ff02488ff.zip | |
std: Clean out old unstable + deprecated APIs
These should all have been deprecated for at least one cycle, so this commit cleans them all out.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 75 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 76 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 130 |
3 files changed, 1 insertions, 280 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 4929088201d..684c90d6ae6 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -692,40 +692,6 @@ impl<'b, T: ?Sized> Ref<'b, T> { borrow: orig.borrow, } } - - /// Make a new `Ref` for an optional component of the borrowed data, e.g. an - /// enum variant. - /// - /// The `RefCell` is already immutably borrowed, so this cannot fail. - /// - /// This is an associated function that needs to be used as - /// `Ref::filter_map(...)`. A method would interfere with methods of the - /// same name on the contents of a `RefCell` used through `Deref`. - /// - /// # Example - /// - /// ``` - /// # #![feature(cell_extras)] - /// use std::cell::{RefCell, Ref}; - /// - /// let c = RefCell::new(Ok(5)); - /// let b1: Ref<Result<u32, ()>> = c.borrow(); - /// let b2: Ref<u32> = Ref::filter_map(b1, |o| o.as_ref().ok()).unwrap(); - /// assert_eq!(*b2, 5) - /// ``` - #[unstable(feature = "cell_extras", reason = "recently added", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", reason = "can be built on `Ref::map`: \ - https://crates.io/crates/ref_filter_map")] - #[inline] - pub fn filter_map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Option<Ref<'b, U>> - where F: FnOnce(&T) -> Option<&U> - { - f(orig.value).map(move |new| Ref { - value: new, - borrow: orig.borrow, - }) - } } #[unstable(feature = "coerce_unsized", issue = "27732")] @@ -765,47 +731,6 @@ impl<'b, T: ?Sized> RefMut<'b, T> { borrow: orig.borrow, } } - - /// Make a new `RefMut` for an optional component of the borrowed data, e.g. - /// an enum variant. - /// - /// The `RefCell` is already mutably borrowed, so this cannot fail. - /// - /// This is an associated function that needs to be used as - /// `RefMut::filter_map(...)`. A method would interfere with methods of the - /// same name on the contents of a `RefCell` used through `Deref`. - /// - /// # Example - /// - /// ``` - /// # #![feature(cell_extras)] - /// use std::cell::{RefCell, RefMut}; - /// - /// let c = RefCell::new(Ok(5)); - /// { - /// let b1: RefMut<Result<u32, ()>> = c.borrow_mut(); - /// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| { - /// o.as_mut().ok() - /// }).unwrap(); - /// assert_eq!(*b2, 5); - /// *b2 = 42; - /// } - /// assert_eq!(*c.borrow(), Ok(42)); - /// ``` - #[unstable(feature = "cell_extras", reason = "recently added", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", reason = "can be built on `RefMut::map`: \ - https://crates.io/crates/ref_filter_map")] - #[inline] - pub fn filter_map<U: ?Sized, F>(orig: RefMut<'b, T>, f: F) -> Option<RefMut<'b, U>> - where F: FnOnce(&mut T) -> Option<&mut U> - { - let RefMut { value, borrow } = orig; - f(value).map(move |new| RefMut { - value: new, - borrow: borrow, - }) - } } struct BorrowRefMut<'b> { diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 19226d81f16..6b2122451db 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -18,63 +18,6 @@ //! //! Their definition should always match the ABI defined in `rustc::back::abi`. -use clone::Clone; -use marker::Copy; -use mem; - -/// The representation of a slice like `&[T]`. -/// -/// This struct is guaranteed to have the layout of types like `&[T]`, -/// `&str`, and `Box<[T]>`, but is not the type of such slices -/// (e.g. the fields are not directly accessible on a `&[T]`) nor does -/// it control that layout (changing the definition will not change -/// the layout of a `&[T]`). It is only designed to be used by unsafe -/// code that needs to manipulate the low-level details. -/// -/// However, it is not recommended to use this type for such code, -/// since there are alternatives which may be safer: -/// -/// - Creating a slice from a data pointer and length can be done with -/// `std::slice::from_raw_parts` or `std::slice::from_raw_parts_mut` -/// instead of `std::mem::transmute`ing a value of type `Slice`. -/// - Extracting the data pointer and length from a slice can be -/// performed with the `as_ptr` (or `as_mut_ptr`) and `len` -/// methods. -/// -/// If one does decide to convert a slice value to a `Slice`, the -/// `Repr` trait in this module provides a method for a safe -/// conversion from `&[T]` (and `&str`) to a `Slice`, more type-safe -/// than a call to `transmute`. -/// -/// # Examples -/// -/// ``` -/// #![feature(raw)] -/// -/// use std::raw::{self, Repr}; -/// -/// let slice: &[u16] = &[1, 2, 3, 4]; -/// -/// let repr: raw::Slice<u16> = slice.repr(); -/// println!("data pointer = {:?}, length = {}", repr.data, repr.len); -/// ``` -#[repr(C)] -#[allow(missing_debug_implementations)] -#[rustc_deprecated(reason = "use raw accessors/constructors in `slice` module", - since = "1.9.0")] -#[unstable(feature = "raw", issue = "27751")] -pub struct Slice<T> { - pub data: *const T, - pub len: usize, -} - -#[allow(deprecated)] -impl<T> Copy for Slice<T> {} -#[allow(deprecated)] -impl<T> Clone for Slice<T> { - fn clone(&self) -> Slice<T> { *self } -} - /// The representation of a trait object like `&SomeTrait`. /// /// This struct has the same layout as types like `&SomeTrait` and @@ -154,22 +97,3 @@ pub struct TraitObject { pub data: *mut (), pub vtable: *mut (), } - -/// This trait is meant to map equivalences between raw structs and their -/// corresponding rust values. -#[rustc_deprecated(reason = "use raw accessors/constructors in `slice` module", - since = "1.9.0")] -#[unstable(feature = "raw", issue = "27751")] -pub unsafe trait Repr<T> { - /// This function "unwraps" a rust value (without consuming it) into its raw - /// struct representation. This can be used to read/write different values - /// for the struct. This is a safe method because by default it does not - /// enable write-access to the fields of the return value in safe code. - #[inline] - fn repr(&self) -> T { unsafe { mem::transmute_copy(&self) } } -} - -#[allow(deprecated)] -unsafe impl<T> Repr<Slice<T>> for [T] {} -#[allow(deprecated)] -unsafe impl Repr<Slice<u8>> for str {} diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2c34caf63b8..0e57068a616 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -17,7 +17,7 @@ use self::pattern::Pattern; use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; -use char::{self, CharExt}; +use char; use clone::Clone; use convert::AsRef; use default::Default; @@ -1663,40 +1663,6 @@ pub trait StrExt { where P::Searcher: ReverseSearcher<'a>; #[stable(feature = "is_char_boundary", since = "1.9.0")] fn is_char_boundary(&self, index: usize) -> bool; - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at() or eventually \ - removed altogether", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8", - since = "1.9.0")] - fn char_range_at(&self, start: usize) -> CharRange; - #[unstable(feature = "str_char", - reason = "often replaced by char_indices, this method may \ - be removed in favor of just char_at_reverse() or \ - eventually removed altogether", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8", - since = "1.9.0")] - fn char_range_at_reverse(&self, start: usize) -> CharRange; - #[unstable(feature = "str_char", - reason = "frequently replaced by the chars() iterator, this \ - method may be removed or possibly renamed in the \ - future; it is normally replaced by chars/char_indices \ - iterators or by getting the first char from a \ - subslice", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars()", - since = "1.9.0")] - fn char_at(&self, i: usize) -> char; - #[unstable(feature = "str_char", - reason = "see char_at for more details, but reverse semantics \ - are also somewhat unclear, especially with which \ - cases generate panics", - issue = "27754")] - #[rustc_deprecated(reason = "use slicing plus chars().rev()", - since = "1.9.0")] - fn char_at_reverse(&self, i: usize) -> char; #[stable(feature = "core", since = "1.6.0")] fn as_bytes(&self) -> &[u8]; #[stable(feature = "core", since = "1.6.0")] @@ -1709,14 +1675,6 @@ pub trait StrExt { fn split_at(&self, mid: usize) -> (&str, &str); #[stable(feature = "core", since = "1.6.0")] fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str); - #[unstable(feature = "str_char", - reason = "awaiting conventions about shifting and slices and \ - may not be warranted with the existence of the chars \ - and/or char_indices iterators", - issue = "27754")] - #[rustc_deprecated(reason = "use chars() plus Chars::as_str", - since = "1.9.0")] - fn slice_shift_char(&self) -> Option<(char, &str)>; #[stable(feature = "core", since = "1.6.0")] fn as_ptr(&self) -> *const u8; #[stable(feature = "core", since = "1.6.0")] @@ -1946,55 +1904,6 @@ impl StrExt for str { } #[inline] - fn char_range_at(&self, i: usize) -> CharRange { - let (c, n) = char_range_at_raw(self.as_bytes(), i); - CharRange { ch: unsafe { char::from_u32_unchecked(c) }, next: n } - } - - #[inline] - fn char_range_at_reverse(&self, start: usize) -> CharRange { - let mut prev = start; - - prev = prev.saturating_sub(1); - if self.as_bytes()[prev] < 128 { - return CharRange{ch: self.as_bytes()[prev] as char, next: prev} - } - - // Multibyte case is a fn to allow char_range_at_reverse to inline cleanly - fn multibyte_char_range_at_reverse(s: &str, mut i: usize) -> CharRange { - // while there is a previous byte == 10...... - while i > 0 && s.as_bytes()[i] & !CONT_MASK == TAG_CONT_U8 { - i -= 1; - } - - let first= s.as_bytes()[i]; - let w = UTF8_CHAR_WIDTH[first as usize]; - assert!(w != 0); - - let mut val = utf8_first_byte(first, w as u32); - val = utf8_acc_cont_byte(val, s.as_bytes()[i + 1]); - if w > 2 { val = utf8_acc_cont_byte(val, s.as_bytes()[i + 2]); } - if w > 3 { val = utf8_acc_cont_byte(val, s.as_bytes()[i + 3]); } - - CharRange {ch: unsafe { char::from_u32_unchecked(val) }, next: i} - } - - multibyte_char_range_at_reverse(self, prev) - } - - #[inline] - #[allow(deprecated)] - fn char_at(&self, i: usize) -> char { - self.char_range_at(i).ch - } - - #[inline] - #[allow(deprecated)] - fn char_at_reverse(&self, i: usize) -> char { - self.char_range_at_reverse(i).ch - } - - #[inline] fn as_bytes(&self) -> &[u8] { unsafe { mem::transmute(self) } } @@ -2041,18 +1950,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] - fn slice_shift_char(&self) -> Option<(char, &str)> { - if self.is_empty() { - None - } else { - let ch = self.char_at(0); - let next_s = unsafe { self.slice_unchecked(ch.len_utf8(), self.len()) }; - Some((ch, next_s)) - } - } - - #[inline] fn as_ptr(&self) -> *const u8 { self as *const str as *const u8 } @@ -2077,31 +1974,6 @@ impl AsRef<[u8]> for str { } } -/// Pluck a code point out of a UTF-8-like byte slice and return the -/// index of the next code point. -#[inline] -fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) { - if bytes[i] < 128 { - return (bytes[i] as u32, i + 1); - } - - // Multibyte case is a fn to allow char_range_at to inline cleanly - fn multibyte_char_range_at(bytes: &[u8], i: usize) -> (u32, usize) { - let first = bytes[i]; - let w = UTF8_CHAR_WIDTH[first as usize]; - assert!(w != 0); - - let mut val = utf8_first_byte(first, w as u32); - val = utf8_acc_cont_byte(val, bytes[i + 1]); - if w > 2 { val = utf8_acc_cont_byte(val, bytes[i + 2]); } - if w > 3 { val = utf8_acc_cont_byte(val, bytes[i + 3]); } - - (val, i + w as usize) - } - - multibyte_char_range_at(bytes, i) -} - #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Default for &'a str { fn default() -> &'a str { "" } |
