diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-08-11 17:27:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-08-12 14:55:17 -0700 |
| commit | 8d90d3f36871a00023cc1f313f91e351c287ca15 (patch) | |
| tree | 2d9b616a2468117aa3afe1f6b1f910ff3116776b /src/libcore | |
| parent | d07d465cf60033e35eba16b9e431471d54c712f4 (diff) | |
| download | rust-8d90d3f36871a00023cc1f313f91e351c287ca15.tar.gz rust-8d90d3f36871a00023cc1f313f91e351c287ca15.zip | |
Remove all unstable deprecated functionality
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 28 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 74 | ||||
| -rw-r--r-- | src/libcore/hash/mod.rs | 39 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 545 | ||||
| -rw-r--r-- | src/libcore/marker.rs | 13 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 30 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 6 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 6 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/wrapping.rs | 1 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 21 | ||||
| -rw-r--r-- | src/libcore/result.rs | 34 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 140 |
13 files changed, 20 insertions, 921 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index c443270d5f4..8062e77d397 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -546,20 +546,6 @@ impl<'b, T: ?Sized> Deref for Ref<'b, T> { } } -/// Copies a `Ref`. -/// -/// The `RefCell` is already immutably borrowed, so this cannot fail. -/// -/// A `Clone` implementation would interfere with the widespread -/// use of `r.borrow().clone()` to clone the contents of a `RefCell`. -#[deprecated(since = "1.2.0", reason = "moved to a `Ref::clone` associated function")] -#[unstable(feature = "core", - reason = "likely to be moved to a method, pending language changes")] -#[inline] -pub fn clone_ref<'b, T:Clone>(orig: &Ref<'b, T>) -> Ref<'b, T> { - Ref::clone(orig) -} - impl<'b, T: ?Sized> Ref<'b, T> { /// Copies a `Ref`. /// @@ -799,14 +785,7 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { #[lang = "unsafe_cell"] #[stable(feature = "rust1", since = "1.0.0")] pub struct UnsafeCell<T: ?Sized> { - /// Wrapped value - /// - /// This field should not be accessed directly, it is made public for static - /// initializers. - #[deprecated(since = "1.2.0", reason = "use `get` to access the wrapped \ - value or `new` to initialize `UnsafeCell` in statics")] - #[unstable(feature = "core")] - pub value: T, + value: T, } impl<T: ?Sized> !Sync for UnsafeCell<T> {} @@ -828,7 +807,6 @@ impl<T> UnsafeCell<T> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub const fn new(value: T) -> UnsafeCell<T> { - #![allow(deprecated)] UnsafeCell { value: value } } @@ -851,7 +829,6 @@ impl<T> UnsafeCell<T> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn into_inner(self) -> T { - #![allow(deprecated)] self.value } } @@ -871,9 +848,6 @@ impl<T: ?Sized> UnsafeCell<T> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn get(&self) -> *mut T { - // FIXME(#23542) Replace with type ascription. - #![allow(trivial_casts)] - #![allow(deprecated)] &self.value as *const T as *mut T } } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index da4bb41fd9c..aea5feb4be1 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -21,7 +21,7 @@ use self::Ordering::*; use mem; use marker::Sized; -use option::Option::{self, Some, None}; +use option::Option::{self, Some}; /// Trait for equality comparisons which are [partial equivalence /// relations](http://en.wikipedia.org/wiki/Partial_equivalence_relation). @@ -381,78 +381,6 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T { if v2 >= v1 { v2 } else { v1 } } -/// Compare and return the minimum of two values if there is one. -/// -/// Returns the first argument if the comparison determines them to be equal. -/// -/// # Examples -/// -/// ``` -/// #![feature(cmp_partial)] -/// -/// use std::cmp; -/// -/// assert_eq!(Some(1), cmp::partial_min(1, 2)); -/// assert_eq!(Some(2), cmp::partial_min(2, 2)); -/// ``` -/// -/// When comparison is impossible: -/// -/// ``` -/// #![feature(cmp_partial)] -/// -/// use std::cmp; -/// -/// let result = cmp::partial_min(std::f64::NAN, 1.0); -/// assert_eq!(result, None); -/// ``` -#[inline] -#[unstable(feature = "cmp_partial")] -#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")] -pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> { - match v1.partial_cmp(&v2) { - Some(Less) | Some(Equal) => Some(v1), - Some(Greater) => Some(v2), - None => None - } -} - -/// Compare and return the maximum of two values if there is one. -/// -/// Returns the second argument if the comparison determines them to be equal. -/// -/// # Examples -/// -/// ``` -/// #![feature(cmp_partial)] -/// -/// use std::cmp; -/// -/// assert_eq!(Some(2), cmp::partial_max(1, 2)); -/// assert_eq!(Some(2), cmp::partial_max(2, 2)); -/// ``` -/// -/// When comparison is impossible: -/// -/// ``` -/// #![feature(cmp_partial)] -/// -/// use std::cmp; -/// -/// let result = cmp::partial_max(std::f64::NAN, 1.0); -/// assert_eq!(result, None); -/// ``` -#[inline] -#[unstable(feature = "cmp_partial")] -#[deprecated(since = "1.3.0", reason = "has not proven itself worthwhile")] -pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> { - match v1.partial_cmp(&v2) { - Some(Equal) | Some(Less) => Some(v2), - Some(Greater) => Some(v1), - None => None - } -} - // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types mod impls { use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering}; diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 34bc3b835a1..361c6d700de 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -16,9 +16,7 @@ //! # Examples //! //! ```rust -//! #![feature(hash_default)] -//! -//! use std::hash::{hash, Hash, SipHasher}; +//! use std::hash::{Hash, SipHasher, Hasher}; //! //! #[derive(Hash)] //! struct Person { @@ -30,16 +28,20 @@ //! let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 }; //! let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 }; //! -//! assert!(hash::<_, SipHasher>(&person1) != hash::<_, SipHasher>(&person2)); +//! assert!(hash(&person1) != hash(&person2)); +//! +//! fn hash<T: Hash>(t: &T) -> u64 { +//! let mut s = SipHasher::new(); +//! t.hash(&mut s); +//! s.finish() +//! } //! ``` //! //! If you need more control over how a value is hashed, you need to implement //! the trait `Hash`: //! //! ```rust -//! #![feature(hash_default)] -//! -//! use std::hash::{hash, Hash, Hasher, SipHasher}; +//! use std::hash::{Hash, Hasher, SipHasher}; //! //! struct Person { //! id: u32, @@ -57,7 +59,13 @@ //! let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 }; //! let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 }; //! -//! assert_eq!(hash::<_, SipHasher>(&person1), hash::<_, SipHasher>(&person2)); +//! assert_eq!(hash(&person1), hash(&person2)); +//! +//! fn hash<T: Hash>(t: &T) -> u64 { +//! let mut s = SipHasher::new(); +//! t.hash(&mut s); +//! s.finish() +//! } //! ``` #![stable(feature = "rust1", since = "1.0.0")] @@ -165,21 +173,6 @@ pub trait Hasher { fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) } } -/// Hash a value with the default SipHasher algorithm (two initial keys of 0). -/// -/// The specified value will be hashed with this hasher and then the resulting -/// hash will be returned. -#[unstable(feature = "hash_default", - reason = "not the most ergonomic interface unless `H` is defaulted \ - to SipHasher, but perhaps not ready to commit to that")] -#[deprecated(since = "1.3.0", - reason = "has yet to prove itself useful")] -pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 { - let mut h: H = Default::default(); - value.hash(&mut h); - h.finish() -} - ////////////////////////////////////////////////////////////////////////////// mod impls { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 3382095b456..79e4a5b4286 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -56,9 +56,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] -use self::MinMaxResult::*; - use clone::Clone; use cmp; use cmp::{Ord, PartialOrd, PartialEq}; @@ -445,7 +442,6 @@ pub trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[allow(deprecated)] fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>, { @@ -806,89 +802,6 @@ pub trait Iterator { .map(|(_, x)| x) } - /// `min_max` finds the minimum and maximum elements in the iterator. - /// - /// The return type `MinMaxResult` is an enum of three variants: - /// - /// - `NoElements` if the iterator is empty. - /// - `OneElement(x)` if the iterator has exactly one element. - /// - `MinMax(x, y)` is returned otherwise, where `x <= y`. Two - /// values are equal if and only if there is more than one - /// element in the iterator and all elements are equal. - /// - /// On an iterator of length `n`, `min_max` does `1.5 * n` comparisons, - /// and so is faster than calling `min` and `max` separately which does `2 * - /// n` comparisons. - /// - /// # Examples - /// - /// ``` - /// #![feature(iter_min_max)] - /// - /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; - /// - /// let a: [i32; 0] = []; - /// assert_eq!(a.iter().min_max(), NoElements); - /// - /// let a = [1]; - /// assert_eq!(a.iter().min_max(), OneElement(&1)); - /// - /// let a = [1, 2, 3, 4, 5]; - /// assert_eq!(a.iter().min_max(), MinMax(&1, &5)); - /// - /// let a = [1, 1, 1, 1]; - /// assert_eq!(a.iter().min_max(), MinMax(&1, &1)); - /// ``` - #[unstable(feature = "iter_min_max", - reason = "return type may change or may wish to have a closure \ - based version as well")] - #[deprecated(since = "1.3.0", reason = "has not proven itself")] - #[allow(deprecated)] - fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord - { - let (mut min, mut max) = match self.next() { - None => return NoElements, - Some(x) => { - match self.next() { - None => return OneElement(x), - Some(y) => if x <= y {(x, y)} else {(y, x)} - } - } - }; - - loop { - // `first` and `second` are the two next elements we want to look - // at. We first compare `first` and `second` (#1). The smaller one - // is then compared to current minimum (#2). The larger one is - // compared to current maximum (#3). This way we do 3 comparisons - // for 2 elements. - let first = match self.next() { - None => break, - Some(x) => x - }; - let second = match self.next() { - None => { - if first < min { - min = first; - } else if first >= max { - max = first; - } - break; - } - Some(x) => x - }; - if first <= second { - if first < min { min = first } - if second >= max { max = second } - } else { - if second < min { min = second } - if first >= max { max = first } - } - } - - MinMax(min, max) - } - /// Returns the element that gives the maximum value from the /// specified function. /// @@ -1046,22 +959,6 @@ pub trait Iterator { Cycle{orig: self.clone(), iter: self} } - /// Use an iterator to reverse a container in place. - #[unstable(feature = "core", - reason = "uncertain about placement or widespread use")] - #[deprecated(since = "1.2.0", - reason = "not performant enough to justify inclusion")] - fn reverse_in_place<'a, T: 'a>(&mut self) where - Self: Sized + Iterator<Item=&'a mut T> + DoubleEndedIterator - { - loop { - match (self.next(), self.next_back()) { - (Some(x), Some(y)) => mem::swap(x, y), - _ => break - } - } - } - /// Iterates over the entire iterator, summing up all the elements /// /// # Examples @@ -1229,29 +1126,6 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I { fn next_back(&mut self) -> Option<I::Item> { (**self).next_back() } } -/// An object implementing random access indexing by `usize` -/// -/// A `RandomAccessIterator` should be either infinite or a -/// `DoubleEndedIterator`. Calling `next()` or `next_back()` on a -/// `RandomAccessIterator` reduces the indexable range accordingly. That is, -/// `it.idx(1)` will become `it.idx(0)` after `it.next()` is called. -#[unstable(feature = "iter_idx", - reason = "not widely used, may be better decomposed into Index \ - and ExactSizeIterator")] -#[deprecated(since = "1.2.0", - reason = "trait has not proven itself as a widely useful \ - abstraction for iterators, and more time may be needed \ - for iteration on the design")] -#[allow(deprecated)] -pub trait RandomAccessIterator: Iterator { - /// Returns the number of indexable elements. At most `std::usize::MAX` - /// elements are indexable, even if the iterator represents a longer range. - fn indexable(&self) -> usize; - - /// Returns an element at an index, or `None` if the index is out of bounds - fn idx(&mut self, index: usize) -> Option<Self::Item>; -} - /// An iterator that knows its exact length /// /// This trait is a helper for iterators like the vector iterator, so that @@ -1321,78 +1195,6 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator { fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Rev<I> - where I: DoubleEndedIterator + RandomAccessIterator -{ - #[inline] - fn indexable(&self) -> usize { self.iter.indexable() } - #[inline] - fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> { - let amt = self.indexable(); - if amt > index { - self.iter.idx(amt - index - 1) - } else { - None - } - } -} - -/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for -/// more detail. -#[derive(Clone, PartialEq, Debug)] -#[unstable(feature = "iter_min_max", - reason = "unclear whether such a fine-grained result is widely useful")] -#[deprecated(since = "1.3.0", reason = "has not proven itself")] -#[allow(deprecated)] -pub enum MinMaxResult<T> { - /// Empty iterator - NoElements, - - /// Iterator with one element, so the minimum and maximum are the same - OneElement(T), - - /// More than one element in the iterator, the first element is not larger - /// than the second - MinMax(T, T) -} - -#[unstable(feature = "iter_min_max", reason = "type is unstable")] -#[deprecated(since = "1.3.0", reason = "has not proven itself")] -#[allow(deprecated)] -impl<T: Clone> MinMaxResult<T> { - /// `into_option` creates an `Option` of type `(T,T)`. The returned `Option` - /// has variant `None` if and only if the `MinMaxResult` has variant - /// `NoElements`. Otherwise variant `Some(x,y)` is returned where `x <= y`. - /// If `MinMaxResult` has variant `OneElement(x)`, performing this operation - /// will make one clone of `x`. - /// - /// # Examples - /// - /// ``` - /// #![feature(iter_min_max)] - /// - /// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax}; - /// - /// let r: MinMaxResult<i32> = NoElements; - /// assert_eq!(r.into_option(), None); - /// - /// let r = OneElement(1); - /// assert_eq!(r.into_option(), Some((1, 1))); - /// - /// let r = MinMax(1, 2); - /// assert_eq!(r.into_option(), Some((1, 2))); - /// ``` - pub fn into_option(self) -> Option<(T,T)> { - match self { - NoElements => None, - OneElement(x) => Some((x.clone(), x)), - MinMax(x, y) => Some((x, y)) - } - } -} - /// An iterator that clones the elements of an underlying iterator #[stable(feature = "iter_cloned", since = "1.1.0")] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] @@ -1430,22 +1232,6 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I> where I: ExactSizeIterator<Item=&'a T>, T: Clone {} -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, I, T: 'a> RandomAccessIterator for Cloned<I> - where I: RandomAccessIterator<Item=&'a T>, T: Clone -{ - #[inline] - fn indexable(&self) -> usize { - self.it.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<T> { - self.it.idx(index).cloned() - } -} - /// An iterator that repeats endlessly #[derive(Clone)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] @@ -1478,34 +1264,6 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator { } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Cycle<I> where - I: Clone + RandomAccessIterator, -{ - #[inline] - fn indexable(&self) -> usize { - if self.orig.indexable() > 0 { - usize::MAX - } else { - 0 - } - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> { - let liter = self.iter.indexable(); - let lorig = self.orig.indexable(); - if lorig == 0 { - None - } else if index < liter { - self.iter.idx(index) - } else { - self.orig.idx((index - liter) % lorig) - } - } -} - /// An iterator that strings two iterators together #[derive(Clone)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] @@ -1593,29 +1351,6 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<A, B> RandomAccessIterator for Chain<A, B> where - A: RandomAccessIterator, - B: RandomAccessIterator<Item = A::Item>, -{ - #[inline] - fn indexable(&self) -> usize { - let (a, b) = (self.a.indexable(), self.b.indexable()); - a.saturating_add(b) - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<A::Item> { - let len = self.a.indexable(); - if index < len { - self.a.idx(index) - } else { - self.b.idx(index - len) - } - } -} - /// An iterator that iterates two other iterators simultaneously #[derive(Clone)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] @@ -1682,27 +1417,6 @@ impl<A, B> DoubleEndedIterator for Zip<A, B> where } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<A, B> RandomAccessIterator for Zip<A, B> where - A: RandomAccessIterator, - B: RandomAccessIterator -{ - #[inline] - fn indexable(&self) -> usize { - cmp::min(self.a.indexable(), self.b.indexable()) - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<(A::Item, B::Item)> { - self.a.idx(index).and_then(|x| { - self.b.idx(index).and_then(|y| { - Some((x, y)) - }) - }) - } -} - /// An iterator that maps the values of `iter` with `f` #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] @@ -1737,22 +1451,6 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<B, I: RandomAccessIterator, F> RandomAccessIterator for Map<I, F> where - F: FnMut(I::Item) -> B, -{ - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<B> { - self.iter.idx(index).map(|a| (self.f)(a)) - } -} - /// An iterator that filters the elements of `iter` with `predicate` #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] @@ -1912,23 +1610,6 @@ impl<I> DoubleEndedIterator for Enumerate<I> where } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator { - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<(usize, <I as Iterator>::Item)> { - // Can safely add, `ExactSizeIterator` (ancestor of - // `RandomAccessIterator`) promises that the number of elements fits - // into a `usize`. - self.iter.idx(index).map(|a| (self.count + index, a)) - } -} - /// An iterator with a `peek()` that returns an optional reference to the next element. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] @@ -2163,24 +1844,6 @@ impl<I> Iterator for Skip<I> where I: Iterator { } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Skip<I> where I: RandomAccessIterator{ - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable().saturating_sub(self.n) - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> { - if index >= self.indexable() { - None - } else { - self.iter.idx(index + self.n) - } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl<I> ExactSizeIterator for Skip<I> where I: ExactSizeIterator {} @@ -2236,24 +1899,6 @@ impl<I> Iterator for Take<I> where I: Iterator{ } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Take<I> where I: RandomAccessIterator{ - #[inline] - fn indexable(&self) -> usize { - cmp::min(self.iter.indexable(), self.n) - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> { - if index >= self.n { - None - } else { - self.iter.idx(index) - } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {} @@ -2262,16 +1907,10 @@ impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {} #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] #[derive(Clone)] -#[allow(deprecated)] pub struct Scan<I, St, F> { iter: I, f: F, - - /// The current internal state to be passed to the closure next. - #[unstable(feature = "scan_state", - reason = "public fields are otherwise rare in the stdlib")] - #[deprecated(since = "1.3.0", reason = "unclear whether this is necessary")] - pub state: St, + state: St, } #[stable(feature = "rust1", since = "1.0.0")] @@ -2282,7 +1921,6 @@ impl<B, I, St, F> Iterator for Scan<I, St, F> where type Item = B; #[inline] - #[allow(deprecated)] fn next(&mut self) -> Option<B> { self.iter.next().and_then(|a| (self.f)(&mut self.state, a)) } @@ -2440,37 +2078,9 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator { } } -// Allow RandomAccessIterators to be fused without affecting random-access behavior -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I> RandomAccessIterator for Fuse<I> where I: RandomAccessIterator { - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> { - self.iter.idx(index) - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {} -impl<I> Fuse<I> { - /// Resets the `Fuse` such that the next call to `.next()` or - /// `.next_back()` will call the underlying iterator again even if it - /// previously returned `None`. - #[inline] - #[unstable(feature = "iter_reset_fuse", reason = "seems marginal")] - #[deprecated(since = "1.3.0", - reason = "unusual for adaptors to have one-off methods")] - pub fn reset_fuse(&mut self) { - self.done = false - } -} - /// An iterator that calls a function with a reference to each /// element before yielding it. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] @@ -2519,104 +2129,6 @@ impl<I: DoubleEndedIterator, F> DoubleEndedIterator for Inspect<I, F> } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F> - where F: FnMut(&I::Item), -{ - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<I::Item> { - let element = self.iter.idx(index); - self.do_inspect(element) - } -} - -/// An iterator that passes mutable state to a closure and yields the result. -/// -/// # Examples -/// -/// An iterator that yields sequential Fibonacci numbers, and stops on overflow. -/// -/// ``` -/// #![feature(iter_unfold)] -/// use std::iter::Unfold; -/// -/// // This iterator will yield up to the last Fibonacci number before the max -/// // value of `u32`. You can simply change `u32` to `u64` in this line if -/// // you want higher values than that. -/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), -/// |&mut (ref mut x2, ref mut x1)| { -/// // Attempt to get the next Fibonacci number -/// // `x1` will be `None` if previously overflowed. -/// let next = match (*x2, *x1) { -/// (Some(x2), Some(x1)) => x2.checked_add(x1), -/// _ => None, -/// }; -/// -/// // Shift left: ret <- x2 <- x1 <- next -/// let ret = *x2; -/// *x2 = *x1; -/// *x1 = next; -/// -/// ret -/// }); -/// -/// for i in fibonacci { -/// println!("{}", i); -/// } -/// ``` -#[unstable(feature = "iter_unfold")] -#[derive(Clone)] -#[deprecated(since = "1.2.0", - reason = "has not gained enough traction to retain its position \ - in the standard library")] -#[allow(deprecated)] -pub struct Unfold<St, F> { - f: F, - /// Internal state that will be passed to the closure on the next iteration - #[unstable(feature = "iter_unfold")] - pub state: St, -} - -#[unstable(feature = "iter_unfold")] -#[deprecated(since = "1.2.0", - reason = "has not gained enough traction to retain its position \ - in the standard library")] -#[allow(deprecated)] -impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> { - /// Creates a new iterator with the specified closure as the "iterator - /// function" and an initial state to eventually pass to the closure - #[inline] - pub fn new(initial_state: St, f: F) -> Unfold<St, F> { - Unfold { - f: f, - state: initial_state - } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] -impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> { - type Item = A; - - #[inline] - fn next(&mut self) -> Option<A> { - (self.f)(&mut self.state) - } - - #[inline] - fn size_hint(&self) -> (usize, Option<usize>) { - // no possible known bounds at this point - (0, None) - } -} - /// Objects that can be stepped over in both directions. /// /// The `steps_between` function provides a way to efficiently compare @@ -2759,7 +2271,6 @@ impl<A: Step> RangeFrom<A> { } } -#[allow(deprecated)] impl<A: Step> ops::Range<A> { /// Creates an iterator with the same range, but stepping by the /// given amount at each iteration. @@ -2892,7 +2403,6 @@ impl<A> DoubleEndedIterator for RangeInclusive<A> where } #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] impl<A: Step + Zero + Clone> Iterator for StepBy<A, ops::Range<A>> { type Item = A; @@ -2937,7 +2447,6 @@ macro_rules! range_exact_iter_impl { } #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] impl<A: Step + One> Iterator for ops::Range<A> where for<'a> &'a A: Add<&'a A, Output = A> { @@ -2968,7 +2477,6 @@ impl<A: Step + One> Iterator for ops::Range<A> where range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32); #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] impl<A: Step + One + Clone> DoubleEndedIterator for ops::Range<A> where for<'a> &'a A: Add<&'a A, Output = A>, for<'a> &'a A: Sub<&'a A, Output = A> @@ -2985,7 +2493,6 @@ impl<A: Step + One + Clone> DoubleEndedIterator for ops::Range<A> where } #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] impl<A: Step + One> Iterator for ops::RangeFrom<A> where for<'a> &'a A: Add<&'a A, Output = A> { @@ -3022,56 +2529,6 @@ impl<A: Clone> DoubleEndedIterator for Repeat<A> { fn next_back(&mut self) -> Option<A> { Some(self.element.clone()) } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<A: Clone> RandomAccessIterator for Repeat<A> { - #[inline] - fn indexable(&self) -> usize { usize::MAX } - #[inline] - fn idx(&mut self, _: usize) -> Option<A> { Some(self.element.clone()) } -} - -type IterateState<T, F> = (F, Option<T>, bool); - -/// An iterator that repeatedly applies a given function, starting -/// from a given seed value. -#[unstable(feature = "iter_iterate")] -#[deprecated(since = "1.2.0", - reason = "has not gained enough traction to retain its position \ - in the standard library")] -#[allow(deprecated)] -pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>; - -/// Creates a new iterator that produces an infinite sequence of -/// repeated applications of the given function `f`. -#[unstable(feature = "iter_iterate")] -#[deprecated(since = "1.2.0", - reason = "has not gained enough traction to retain its position \ - in the standard library")] -#[allow(deprecated)] -pub fn iterate<T, F>(seed: T, f: F) -> Iterate<T, F> where - T: Clone, - F: FnMut(T) -> T, -{ - fn next<T, F>(st: &mut IterateState<T, F>) -> Option<T> where - T: Clone, - F: FnMut(T) -> T, - { - let &mut (ref mut f, ref mut val, ref mut first) = st; - if *first { - *first = false; - } else if let Some(x) = val.take() { - *val = Some((*f)(x)) - } - val.clone() - } - - // coerce to a fn pointer - let next: fn(&mut IterateState<T,F>) -> Option<T> = next; - - Unfold::new((f, Some(seed), true), next) -} - /// Creates a new iterator that endlessly repeats the element `elt`. #[inline] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index c0956753c98..e0c6bb52781 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -218,18 +218,6 @@ unsafe impl Sync for .. { } impl<T> !Sync for *const T { } impl<T> !Sync for *mut T { } -/// A type which is considered "not POD", meaning that it is not -/// implicitly copyable. This is typically embedded in other types to -/// ensure that they are never copied, even if they lack a destructor. -#[unstable(feature = "core", - reason = "likely to change with new variance strategy")] -#[deprecated(since = "1.2.0", - reason = "structs are by default not copyable")] -#[lang = "no_copy_bound"] -#[allow(deprecated)] -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] -pub struct NoCopy; - macro_rules! impls{ ($t: ident) => ( impl<T:?Sized> Hash for $t<T> { @@ -419,7 +407,6 @@ mod impls { #[rustc_reflect_like] #[unstable(feature = "reflect_marker", reason = "requires RFC and more experience")] -#[allow(deprecated)] #[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \ ensure all type parameters are bounded by `Any`"] pub trait Reflect {} diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 86b331d220a..c7652390d9e 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -558,33 +558,3 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U { #![allow(trivial_casts)] ptr::read(src as *const T as *const U) } - -/// Transforms lifetime of the second pointer to match the first. -#[inline] -#[unstable(feature = "copy_lifetime", - reason = "this function may be removed in the future due to its \ - questionable utility")] -#[deprecated(since = "1.2.0", - reason = "unclear that this function buys more safety and \ - lifetimes are generally not handled as such in unsafe \ - code today")] -pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, - ptr: &T) -> &'a T { - transmute(ptr) -} - -/// Transforms lifetime of the second mutable pointer to match the first. -#[inline] -#[unstable(feature = "copy_lifetime", - reason = "this function may be removed in the future due to its \ - questionable utility")] -#[deprecated(since = "1.2.0", - reason = "unclear that this function buys more safety and \ - lifetimes are generally not handled as such in unsafe \ - code today")] -pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, - ptr: &mut T) - -> &'a mut T -{ - transmute(ptr) -} diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index d0e6d4fa49c..6ce037f17ae 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -80,12 +80,6 @@ pub mod consts { #[stable(feature = "rust1", since = "1.0.0")] pub const PI: f32 = 3.14159265358979323846264338327950288_f32; - /// pi * 2.0 - #[unstable(feature = "float_consts", - reason = "unclear naming convention/usefulness")] - #[deprecated(since = "1.2.0", reason = "unclear on usefulness")] - pub const PI_2: f32 = 6.28318530717958647692528676655900576_f32; - /// pi/2.0 #[stable(feature = "rust1", since = "1.0.0")] pub const FRAC_PI_2: f32 = 1.57079632679489661923132169163975144_f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index bf7da04f995..b9dbc046799 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -80,12 +80,6 @@ pub mod consts { #[stable(feature = "rust1", since = "1.0.0")] pub const PI: f64 = 3.14159265358979323846264338327950288_f64; - /// pi * 2.0 - #[unstable(feature = "float_consts", - reason = "unclear naming convention/usefulness")] - #[deprecated(since = "1.2.0", reason = "unclear on usefulness")] - pub const PI_2: f64 = 6.28318530717958647692528676655900576_f64; - /// pi/2.0 #[stable(feature = "rust1", since = "1.0.0")] pub const FRAC_PI_2: f64 = 1.57079632679489661923132169163975144_f64; diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index ad891bf8fa6..ea8a1daf926 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -136,7 +136,6 @@ macro_rules! int_impl { /// assert_eq!(u32::from_str_radix("A", 16), Ok(10)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[allow(deprecated)] pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError> { from_str_radix(src, radix) } @@ -691,7 +690,6 @@ macro_rules! uint_impl { /// `Err(ParseIntError)` if the string did not represent a valid number. /// Otherwise, `Ok(n)` where `n` is the integer represented by `src`. #[stable(feature = "rust1", since = "1.0.0")] - #[allow(deprecated)] pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError> { from_str_radix(src, radix) } @@ -1395,7 +1393,6 @@ macro_rules! from_str_float_impl { /// number. Otherwise, `Ok(n)` where `n` is the floating-point /// number represented by `src`. #[inline] - #[allow(deprecated)] fn from_str(src: &str) -> Result<Self, ParseFloatError> { Self::from_str_radix(src, 10) } @@ -1408,7 +1405,6 @@ from_str_float_impl!(f64); macro_rules! from_str_radix_int_impl { ($($t:ty)*) => {$( #[stable(feature = "rust1", since = "1.0.0")] - #[allow(deprecated)] impl FromStr for $t { type Err = ParseIntError; fn from_str(src: &str) -> Result<Self, ParseIntError> { diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 2e3b34af513..8e6ecf3c71e 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(missing_docs)] -#![allow(deprecated)] #![unstable(feature = "wrapping", reason = "may be removed or relocated")] use super::Wrapping; diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 64727242b9c..ba1fe6f48cd 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -123,27 +123,6 @@ pub unsafe fn read<T>(src: *const T) -> T { tmp } -/// Reads the value from `src` and nulls it out without dropping it. -/// -/// # Safety -/// -/// This is unsafe for the same reasons that `read` is unsafe. -#[inline(always)] -#[unstable(feature = "read_and_zero", - reason = "may play a larger role in std::ptr future extensions")] -#[deprecated(since = "1.3.0", - reason = "a \"zero value\" will soon not actually exist for all \ - types once dynamic drop has been implemented")] -pub unsafe fn read_and_zero<T>(dest: *mut T) -> T { - // Copy the data out from `dest`: - let tmp = read(&*dest); - - // Now zero out `dest`: - write_bytes(dest, 0, 1); - - tmp -} - /// Variant of read_and_zero that writes the specific drop-flag byte /// (which may be more appropriate than zero). #[inline(always)] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 100cf0779b7..7ddb0883bf2 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -234,7 +234,7 @@ use self::Result::{Ok, Err}; use clone::Clone; use fmt; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator}; -use ops::{FnMut, FnOnce}; +use ops::FnOnce; use option::Option::{self, None, Some}; use slice; @@ -957,35 +957,3 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> { } } } - -///////////////////////////////////////////////////////////////////////////// -// FromIterator -///////////////////////////////////////////////////////////////////////////// - -/// Performs a fold operation over the result values from an iterator. -/// -/// If an `Err` is encountered, it is immediately returned. -/// Otherwise, the folded value is returned. -#[inline] -#[unstable(feature = "result_fold", - reason = "unclear if this function should exist")] -#[deprecated(since = "1.2.0", - reason = "has not seen enough usage to justify its position in \ - the standard library")] -pub fn fold<T, - V, - E, - F: FnMut(V, T) -> V, - Iter: Iterator<Item=Result<T, E>>>( - iterator: Iter, - mut init: V, - mut f: F) - -> Result<V, E> { - for t in iterator { - match t { - Ok(v) => init = f(init, v), - Err(u) => return Err(u) - } - } - Ok(init) -} diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index aa34b651157..b350bcc4a3d 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -826,27 +826,6 @@ impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } } -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, T> RandomAccessIterator for Iter<'a, T> { - #[inline] - fn indexable(&self) -> usize { - let (exact, _) = self.size_hint(); - exact - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<&'a T> { - unsafe { - if index < self.indexable() { - Some(slice_ref!(self.ptr.offset(index as isize))) - } else { - None - } - } - } -} - /// Mutable slice iterator. #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, T: 'a> { @@ -1199,24 +1178,6 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> ExactSizeIterator for Windows<'a, T> {} -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, T> RandomAccessIterator for Windows<'a, T> { - #[inline] - fn indexable(&self) -> usize { - self.size_hint().0 - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<&'a [T]> { - if index + self.size > self.v.len() { - None - } else { - Some(&self.v[index .. index+self.size]) - } - } -} - /// An iterator over a slice in (non-overlapping) chunks (`size` elements at a /// time). /// @@ -1287,28 +1248,6 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} -#[unstable(feature = "iter_idx", reason = "trait is experimental")] -#[allow(deprecated)] -impl<'a, T> RandomAccessIterator for Chunks<'a, T> { - #[inline] - fn indexable(&self) -> usize { - self.v.len()/self.size + if self.v.len() % self.size != 0 { 1 } else { 0 } - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<&'a [T]> { - if index < self.indexable() { - let lo = index * self.size; - let mut hi = lo + self.size; - if hi < lo || hi > self.v.len() { hi = self.v.len(); } - - Some(&self.v[lo..hi]) - } else { - None - } - } -} - /// An iterator over a slice in (non-overlapping) mutable chunks (`size` /// elements at a time). When the slice len is not evenly divided by the chunk /// size, the last slice of the iteration will be the remainder. @@ -1439,37 +1378,6 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { mem::transmute(RawSlice { data: p, len: len }) } -#[inline] -fn check_types<T,U>() { - assert!(mem::size_of::<T>() == mem::size_of::<U>()); - assert!(mem::align_of::<T>() % mem::align_of::<U>() == 0) -} - -/// Reinterprets a slice of one type as a slice of another type. -/// -/// Both types have to have the same size and the type that is converted to -/// must have equal or less restrictive alignment. -/// -/// # Panics -/// -/// This functions panics if the above preconditions about the types are not -/// met. -#[inline] -unsafe fn transmute<T,U>(slice: &[T]) -> &[U] { - check_types::<T,U>(); - from_raw_parts(slice.as_ptr() as *const U, slice.len()) -} - -/// Reinterprets a mutable slice of one type as a mutable slice of another -/// type. -/// -/// Equivalent of `slice::transmute` for mutable slices. -#[inline] -unsafe fn transmute_mut<T,U>(slice: &mut [T]) -> &mut [U] { - check_types::<T,U>(); - from_raw_parts_mut(slice.as_mut_ptr() as *mut U, slice.len()) -} - // // Submodules // @@ -1579,51 +1487,3 @@ impl<T: PartialOrd> PartialOrd for [T] { order::gt(self.iter(), other.iter()) } } - -/// Extension methods for slices containing integers. -#[unstable(feature = "int_slice")] -#[deprecated(since = "1.2.0", - reason = "has not seen much usage and may want to live in the \ - standard library now that most slice methods are \ - on an inherent implementation block")] -pub trait IntSliceExt<U, S> { - /// Converts the slice to an immutable slice of unsigned integers with the same width. - fn as_unsigned<'a>(&'a self) -> &'a [U]; - /// Converts the slice to an immutable slice of signed integers with the same width. - fn as_signed<'a>(&'a self) -> &'a [S]; - - /// Converts the slice to a mutable slice of unsigned integers with the same width. - fn as_unsigned_mut<'a>(&'a mut self) -> &'a mut [U]; - /// Converts the slice to a mutable slice of signed integers with the same width. - fn as_signed_mut<'a>(&'a mut self) -> &'a mut [S]; -} - -macro_rules! impl_int_slice { - ($u:ty, $s:ty, $t:ty) => { - #[unstable(feature = "int_slice")] - #[allow(deprecated)] - impl IntSliceExt<$u, $s> for [$t] { - #[inline] - fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } } - #[inline] - fn as_signed(&self) -> &[$s] { unsafe { transmute(self) } } - #[inline] - fn as_unsigned_mut(&mut self) -> &mut [$u] { unsafe { transmute_mut(self) } } - #[inline] - fn as_signed_mut(&mut self) -> &mut [$s] { unsafe { transmute_mut(self) } } - } - } -} - -macro_rules! impl_int_slices { - ($u:ty, $s:ty) => { - impl_int_slice! { $u, $s, $u } - impl_int_slice! { $u, $s, $s } - } -} - -impl_int_slices! { u8, i8 } -impl_int_slices! { u16, i16 } -impl_int_slices! { u32, i32 } -impl_int_slices! { u64, i64 } -impl_int_slices! { usize, isize } |
