Skip to content

Commit

Permalink
Remove a large amount of deprecated functionality
Browse files Browse the repository at this point in the history
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.

This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.

[breaking-change]
  • Loading branch information
alexcrichton committed Oct 17, 2014
1 parent 284ab80 commit afe376d
Show file tree
Hide file tree
Showing 337 changed files with 1,330 additions and 4,248 deletions.
15 changes: 2 additions & 13 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,6 @@ impl<T> DList<T> {
Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
}

/// Deprecated: use `iter_mut`.
#[deprecated = "use iter_mut"]
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
self.iter_mut()
}

/// Provides a forward iterator with mutable references.
#[inline]
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
Expand All @@ -496,12 +490,6 @@ impl<T> DList<T> {
}
}

/// Deprecated: use `into_iter`.
#[deprecated = "use into_iter"]
pub fn move_iter(self) -> MoveItems<T> {
self.into_iter()
}

/// Consumes the list into an iterator yielding elements by value.
#[inline]
pub fn into_iter(self) -> MoveItems<T> {
Expand Down Expand Up @@ -870,7 +858,8 @@ mod tests {
let mut m = list_from(v.as_slice());
m.append(list_from(u.as_slice()));
check_links(&m);
let sum = v.append(u.as_slice());
let mut sum = v;
sum.push_all(u.as_slice());
assert_eq!(sum.len(), m.len());
for elt in sum.into_iter() {
assert_eq!(m.pop_front(), Some(elt))
Expand Down
34 changes: 0 additions & 34 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,40 +502,6 @@ pub trait Deque<T> : MutableSeq<T> {
/// ```
fn push_front(&mut self, elt: T);

/// Inserts an element last in the sequence.
///
/// # Example
///
/// ```ignore
/// use std::collections::{DList, Deque};
///
/// let mut d = DList::new();
/// d.push_back(1i);
/// d.push_back(2i);
/// assert_eq!(d.front(), Some(&1i));
/// ```
#[deprecated = "use the `push` method"]
fn push_back(&mut self, elt: T) { self.push(elt) }

/// Removes the last element and returns it, or `None` if the sequence is
/// empty.
///
/// # Example
///
/// ```ignore
/// use std::collections::{RingBuf, Deque};
///
/// let mut d = RingBuf::new();
/// d.push_back(1i);
/// d.push_back(2i);
///
/// assert_eq!(d.pop_back(), Some(2i));
/// assert_eq!(d.pop_back(), Some(1i));
/// assert_eq!(d.pop_back(), None);
/// ```
#[deprecated = "use the `pop` method"]
fn pop_back(&mut self) -> Option<T> { self.pop() }

/// Removes the first element and returns it, or `None` if the sequence is
/// empty.
///
Expand Down
14 changes: 0 additions & 14 deletions src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ impl<T: Ord> PriorityQueue<T> {
if self.is_empty() { None } else { Some(&self.data[0]) }
}

#[deprecated="renamed to `top`"]
pub fn maybe_top<'a>(&'a self) -> Option<&'a T> { self.top() }

/// Returns the number of elements the queue can hold without reallocating.
///
/// # Example
Expand Down Expand Up @@ -341,9 +338,6 @@ impl<T: Ord> PriorityQueue<T> {
}
}

#[deprecated="renamed to `pop`"]
pub fn maybe_pop(&mut self) -> Option<T> { self.pop() }

/// Pushes an item onto the queue.
///
/// # Example
Expand Down Expand Up @@ -417,14 +411,6 @@ impl<T: Ord> PriorityQueue<T> {
}
}

#[allow(dead_code)]
#[deprecated="renamed to `into_vec`"]
fn to_vec(self) -> Vec<T> { self.into_vec() }

#[allow(dead_code)]
#[deprecated="renamed to `into_sorted_vec`"]
fn to_sorted_vec(self) -> Vec<T> { self.into_sorted_vec() }

/// Consumes the `PriorityQueue` and returns the underlying vector
/// in arbitrary order.
///
Expand Down
108 changes: 42 additions & 66 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use core::cmp;
use core::default::Default;
use core::fmt;
use core::iter;
use core::slice;
use std::hash::{Writer, Hash};

use {Deque, Mutable, MutableSeq};
Expand Down Expand Up @@ -132,32 +133,6 @@ impl<T> RingBuf<T> {
elts: Vec::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)}
}

/// Retrieve an element in the `RingBuf` by index.
///
/// Fails if there is no element with the given index.
///
/// # Example
///
/// ```rust
/// #![allow(deprecated)]
///
/// use std::collections::RingBuf;
///
/// let mut buf = RingBuf::new();
/// buf.push(3i);
/// buf.push(4);
/// buf.push(5);
/// assert_eq!(buf.get(1), &4);
/// ```
#[deprecated = "prefer using indexing, e.g., ringbuf[0]"]
pub fn get<'a>(&'a self, i: uint) -> &'a T {
let idx = self.raw_index(i);
match self.elts[idx] {
None => fail!(),
Some(ref v) => v
}
}

/// Retrieves an element in the `RingBuf` by index.
///
/// Fails if there is no element with the given index.
Expand Down Expand Up @@ -250,12 +225,6 @@ impl<T> RingBuf<T> {
Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()}
}

/// Deprecated: use `iter_mut`
#[deprecated = "use iter_mut"]
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
self.iter_mut()
}

/// Returns a front-to-back iterator which returns mutable references.
///
/// # Example
Expand Down Expand Up @@ -285,16 +254,20 @@ impl<T> RingBuf<T> {
// 0 to end_index
let (temp, remaining1) = self.elts.split_at_mut(start_index);
let (remaining2, _) = temp.split_at_mut(end_index);
MutItems { remaining1: remaining1,
remaining2: remaining2,
nelts: self.nelts }
MutItems {
remaining1: remaining1.iter_mut(),
remaining2: remaining2.iter_mut(),
nelts: self.nelts,
}
} else {
// Items to iterate goes from start_index to end_index:
let (empty, elts) = self.elts.split_at_mut(0);
let remaining1 = elts[mut start_index..end_index];
MutItems { remaining1: remaining1,
remaining2: empty,
nelts: self.nelts }
MutItems {
remaining1: remaining1.iter_mut(),
remaining2: empty.iter_mut(),
nelts: self.nelts,
}
}
}
}
Expand Down Expand Up @@ -356,26 +329,26 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {

/// `RingBuf` mutable iterator.
pub struct MutItems<'a, T:'a> {
remaining1: &'a mut [Option<T>],
remaining2: &'a mut [Option<T>],
remaining1: slice::MutItems<'a, Option<T>>,
remaining2: slice::MutItems<'a, Option<T>>,
nelts: uint,
}

impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {
#[inline]
#[allow(deprecated)] // mut_shift_ref
fn next(&mut self) -> Option<&'a mut T> {
if self.nelts == 0 {
return None;
}
let r = if self.remaining1.len() > 0 {
&mut self.remaining1
} else {
assert!(self.remaining2.len() > 0);
&mut self.remaining2
};
self.nelts -= 1;
Some(r.mut_shift_ref().unwrap().get_mut_ref())
match self.remaining1.next() {
Some(ptr) => return Some(ptr.as_mut().unwrap()),
None => {}
}
match self.remaining2.next() {
Some(ptr) => return Some(ptr.as_mut().unwrap()),
None => unreachable!(),
}
}

#[inline]
Expand All @@ -386,19 +359,19 @@ impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {

impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> {
#[inline]
#[allow(deprecated)] // mut_shift_ref
fn next_back(&mut self) -> Option<&'a mut T> {
if self.nelts == 0 {
return None;
}
let r = if self.remaining2.len() > 0 {
&mut self.remaining2
} else {
assert!(self.remaining1.len() > 0);
&mut self.remaining1
};
self.nelts -= 1;
Some(r.mut_pop_ref().unwrap().get_mut_ref())
match self.remaining2.next_back() {
Some(ptr) => return Some(ptr.as_mut().unwrap()),
None => {}
}
match self.remaining1.next_back() {
Some(ptr) => return Some(ptr.as_mut().unwrap()),
None => unreachable!(),
}
}
}

Expand Down Expand Up @@ -484,9 +457,12 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {

impl<A> Index<uint, A> for RingBuf<A> {
#[inline]
#[allow(deprecated)]
fn index<'a>(&'a self, i: &uint) -> &'a A {
self.get(*i)
let idx = self.raw_index(*i);
match self.elts[idx] {
None => fail!(),
Some(ref v) => v,
}
}
}

Expand Down Expand Up @@ -576,14 +552,14 @@ mod tests {
assert_eq!(d.len(), 3u);
d.push_front(1);
assert_eq!(d.len(), 4u);
debug!("{}", d.get(0));
debug!("{}", d.get(1));
debug!("{}", d.get(2));
debug!("{}", d.get(3));
assert_eq!(*d.get(0), 1);
assert_eq!(*d.get(1), 2);
assert_eq!(*d.get(2), 3);
assert_eq!(*d.get(3), 4);
debug!("{}", d[0]);
debug!("{}", d[1]);
debug!("{}", d[2]);
debug!("{}", d[3]);
assert_eq!(d[0], 1);
assert_eq!(d[1], 2);
assert_eq!(d[2], 3);
assert_eq!(d[3], 4);
}

#[cfg(test)]
Expand Down
Loading

4 comments on commit afe376d

@bors
Copy link
Contributor

@bors bors commented on afe376d Oct 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at alexcrichton@afe376d

@bors
Copy link
Contributor

@bors bors commented on afe376d Oct 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/spring-cleaning = afe376d into auto

@bors
Copy link
Contributor

@bors bors commented on afe376d Oct 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/spring-cleaning = afe376d merged ok, testing candidate = 60e6c38

@bors
Copy link
Contributor

@bors bors commented on afe376d Oct 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.