Skip to content

Commit afe376d

Browse files
committed
Remove a large amount of deprecated functionality
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]
1 parent 284ab80 commit afe376d

File tree

337 files changed

+1330
-4248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+1330
-4248
lines changed

src/libcollections/dlist.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,6 @@ impl<T> DList<T> {
475475
Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
476476
}
477477

478-
/// Deprecated: use `iter_mut`.
479-
#[deprecated = "use iter_mut"]
480-
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
481-
self.iter_mut()
482-
}
483-
484478
/// Provides a forward iterator with mutable references.
485479
#[inline]
486480
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
@@ -496,12 +490,6 @@ impl<T> DList<T> {
496490
}
497491
}
498492

499-
/// Deprecated: use `into_iter`.
500-
#[deprecated = "use into_iter"]
501-
pub fn move_iter(self) -> MoveItems<T> {
502-
self.into_iter()
503-
}
504-
505493
/// Consumes the list into an iterator yielding elements by value.
506494
#[inline]
507495
pub fn into_iter(self) -> MoveItems<T> {
@@ -870,7 +858,8 @@ mod tests {
870858
let mut m = list_from(v.as_slice());
871859
m.append(list_from(u.as_slice()));
872860
check_links(&m);
873-
let sum = v.append(u.as_slice());
861+
let mut sum = v;
862+
sum.push_all(u.as_slice());
874863
assert_eq!(sum.len(), m.len());
875864
for elt in sum.into_iter() {
876865
assert_eq!(m.pop_front(), Some(elt))

src/libcollections/lib.rs

-34
Original file line numberDiff line numberDiff line change
@@ -502,40 +502,6 @@ pub trait Deque<T> : MutableSeq<T> {
502502
/// ```
503503
fn push_front(&mut self, elt: T);
504504

505-
/// Inserts an element last in the sequence.
506-
///
507-
/// # Example
508-
///
509-
/// ```ignore
510-
/// use std::collections::{DList, Deque};
511-
///
512-
/// let mut d = DList::new();
513-
/// d.push_back(1i);
514-
/// d.push_back(2i);
515-
/// assert_eq!(d.front(), Some(&1i));
516-
/// ```
517-
#[deprecated = "use the `push` method"]
518-
fn push_back(&mut self, elt: T) { self.push(elt) }
519-
520-
/// Removes the last element and returns it, or `None` if the sequence is
521-
/// empty.
522-
///
523-
/// # Example
524-
///
525-
/// ```ignore
526-
/// use std::collections::{RingBuf, Deque};
527-
///
528-
/// let mut d = RingBuf::new();
529-
/// d.push_back(1i);
530-
/// d.push_back(2i);
531-
///
532-
/// assert_eq!(d.pop_back(), Some(2i));
533-
/// assert_eq!(d.pop_back(), Some(1i));
534-
/// assert_eq!(d.pop_back(), None);
535-
/// ```
536-
#[deprecated = "use the `pop` method"]
537-
fn pop_back(&mut self) -> Option<T> { self.pop() }
538-
539505
/// Removes the first element and returns it, or `None` if the sequence is
540506
/// empty.
541507
///

src/libcollections/priority_queue.rs

-14
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,6 @@ impl<T: Ord> PriorityQueue<T> {
269269
if self.is_empty() { None } else { Some(&self.data[0]) }
270270
}
271271

272-
#[deprecated="renamed to `top`"]
273-
pub fn maybe_top<'a>(&'a self) -> Option<&'a T> { self.top() }
274-
275272
/// Returns the number of elements the queue can hold without reallocating.
276273
///
277274
/// # Example
@@ -341,9 +338,6 @@ impl<T: Ord> PriorityQueue<T> {
341338
}
342339
}
343340

344-
#[deprecated="renamed to `pop`"]
345-
pub fn maybe_pop(&mut self) -> Option<T> { self.pop() }
346-
347341
/// Pushes an item onto the queue.
348342
///
349343
/// # Example
@@ -417,14 +411,6 @@ impl<T: Ord> PriorityQueue<T> {
417411
}
418412
}
419413

420-
#[allow(dead_code)]
421-
#[deprecated="renamed to `into_vec`"]
422-
fn to_vec(self) -> Vec<T> { self.into_vec() }
423-
424-
#[allow(dead_code)]
425-
#[deprecated="renamed to `into_sorted_vec`"]
426-
fn to_sorted_vec(self) -> Vec<T> { self.into_sorted_vec() }
427-
428414
/// Consumes the `PriorityQueue` and returns the underlying vector
429415
/// in arbitrary order.
430416
///

src/libcollections/ringbuf.rs

+42-66
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use core::cmp;
1919
use core::default::Default;
2020
use core::fmt;
2121
use core::iter;
22+
use core::slice;
2223
use std::hash::{Writer, Hash};
2324

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

135-
/// Retrieve an element in the `RingBuf` by index.
136-
///
137-
/// Fails if there is no element with the given index.
138-
///
139-
/// # Example
140-
///
141-
/// ```rust
142-
/// #![allow(deprecated)]
143-
///
144-
/// use std::collections::RingBuf;
145-
///
146-
/// let mut buf = RingBuf::new();
147-
/// buf.push(3i);
148-
/// buf.push(4);
149-
/// buf.push(5);
150-
/// assert_eq!(buf.get(1), &4);
151-
/// ```
152-
#[deprecated = "prefer using indexing, e.g., ringbuf[0]"]
153-
pub fn get<'a>(&'a self, i: uint) -> &'a T {
154-
let idx = self.raw_index(i);
155-
match self.elts[idx] {
156-
None => fail!(),
157-
Some(ref v) => v
158-
}
159-
}
160-
161136
/// Retrieves an element in the `RingBuf` by index.
162137
///
163138
/// Fails if there is no element with the given index.
@@ -250,12 +225,6 @@ impl<T> RingBuf<T> {
250225
Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()}
251226
}
252227

253-
/// Deprecated: use `iter_mut`
254-
#[deprecated = "use iter_mut"]
255-
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
256-
self.iter_mut()
257-
}
258-
259228
/// Returns a front-to-back iterator which returns mutable references.
260229
///
261230
/// # Example
@@ -285,16 +254,20 @@ impl<T> RingBuf<T> {
285254
// 0 to end_index
286255
let (temp, remaining1) = self.elts.split_at_mut(start_index);
287256
let (remaining2, _) = temp.split_at_mut(end_index);
288-
MutItems { remaining1: remaining1,
289-
remaining2: remaining2,
290-
nelts: self.nelts }
257+
MutItems {
258+
remaining1: remaining1.iter_mut(),
259+
remaining2: remaining2.iter_mut(),
260+
nelts: self.nelts,
261+
}
291262
} else {
292263
// Items to iterate goes from start_index to end_index:
293264
let (empty, elts) = self.elts.split_at_mut(0);
294265
let remaining1 = elts[mut start_index..end_index];
295-
MutItems { remaining1: remaining1,
296-
remaining2: empty,
297-
nelts: self.nelts }
266+
MutItems {
267+
remaining1: remaining1.iter_mut(),
268+
remaining2: empty.iter_mut(),
269+
nelts: self.nelts,
270+
}
298271
}
299272
}
300273
}
@@ -356,26 +329,26 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
356329

357330
/// `RingBuf` mutable iterator.
358331
pub struct MutItems<'a, T:'a> {
359-
remaining1: &'a mut [Option<T>],
360-
remaining2: &'a mut [Option<T>],
332+
remaining1: slice::MutItems<'a, Option<T>>,
333+
remaining2: slice::MutItems<'a, Option<T>>,
361334
nelts: uint,
362335
}
363336

364337
impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {
365338
#[inline]
366-
#[allow(deprecated)] // mut_shift_ref
367339
fn next(&mut self) -> Option<&'a mut T> {
368340
if self.nelts == 0 {
369341
return None;
370342
}
371-
let r = if self.remaining1.len() > 0 {
372-
&mut self.remaining1
373-
} else {
374-
assert!(self.remaining2.len() > 0);
375-
&mut self.remaining2
376-
};
377343
self.nelts -= 1;
378-
Some(r.mut_shift_ref().unwrap().get_mut_ref())
344+
match self.remaining1.next() {
345+
Some(ptr) => return Some(ptr.as_mut().unwrap()),
346+
None => {}
347+
}
348+
match self.remaining2.next() {
349+
Some(ptr) => return Some(ptr.as_mut().unwrap()),
350+
None => unreachable!(),
351+
}
379352
}
380353

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

387360
impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> {
388361
#[inline]
389-
#[allow(deprecated)] // mut_shift_ref
390362
fn next_back(&mut self) -> Option<&'a mut T> {
391363
if self.nelts == 0 {
392364
return None;
393365
}
394-
let r = if self.remaining2.len() > 0 {
395-
&mut self.remaining2
396-
} else {
397-
assert!(self.remaining1.len() > 0);
398-
&mut self.remaining1
399-
};
400366
self.nelts -= 1;
401-
Some(r.mut_pop_ref().unwrap().get_mut_ref())
367+
match self.remaining2.next_back() {
368+
Some(ptr) => return Some(ptr.as_mut().unwrap()),
369+
None => {}
370+
}
371+
match self.remaining1.next_back() {
372+
Some(ptr) => return Some(ptr.as_mut().unwrap()),
373+
None => unreachable!(),
374+
}
402375
}
403376
}
404377

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

485458
impl<A> Index<uint, A> for RingBuf<A> {
486459
#[inline]
487-
#[allow(deprecated)]
488460
fn index<'a>(&'a self, i: &uint) -> &'a A {
489-
self.get(*i)
461+
let idx = self.raw_index(*i);
462+
match self.elts[idx] {
463+
None => fail!(),
464+
Some(ref v) => v,
465+
}
490466
}
491467
}
492468

@@ -576,14 +552,14 @@ mod tests {
576552
assert_eq!(d.len(), 3u);
577553
d.push_front(1);
578554
assert_eq!(d.len(), 4u);
579-
debug!("{}", d.get(0));
580-
debug!("{}", d.get(1));
581-
debug!("{}", d.get(2));
582-
debug!("{}", d.get(3));
583-
assert_eq!(*d.get(0), 1);
584-
assert_eq!(*d.get(1), 2);
585-
assert_eq!(*d.get(2), 3);
586-
assert_eq!(*d.get(3), 4);
555+
debug!("{}", d[0]);
556+
debug!("{}", d[1]);
557+
debug!("{}", d[2]);
558+
debug!("{}", d[3]);
559+
assert_eq!(d[0], 1);
560+
assert_eq!(d[1], 2);
561+
assert_eq!(d[2], 3);
562+
assert_eq!(d[3], 4);
587563
}
588564

589565
#[cfg(test)]

0 commit comments

Comments
 (0)