Skip to content

Commit a40f309

Browse files
committed
std: Clean out #[deprecated] APIs
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
1 parent 80bf31d commit a40f309

File tree

166 files changed

+601
-4013
lines changed

Some content is hidden

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

166 files changed

+601
-4013
lines changed

src/doc/reference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,17 +977,13 @@ An example of `use` declarations:
977977

978978
```
979979
# #![feature(core)]
980-
use std::iter::range_step;
981980
use std::option::Option::{Some, None};
982981
use std::collections::hash_map::{self, HashMap};
983982
984983
fn foo<T>(_: T){}
985984
fn bar(map1: HashMap<String, usize>, map2: hash_map::HashMap<String, usize>){}
986985
987986
fn main() {
988-
// Equivalent to 'std::iter::range_step(0, 10, 2);'
989-
range_step(0, 10, 2);
990-
991987
// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
992988
// std::option::Option::None]);'
993989
foo(vec![Some(1.0f64), None]);

src/doc/trpl/iterators.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,12 @@ for num in nums.iter() {
243243
```
244244

245245
These two basic iterators should serve you well. There are some more
246-
advanced iterators, including ones that are infinite. Like `count`:
246+
advanced iterators, including ones that are infinite. Like using range syntax
247+
and `step_by`:
247248

248249
```rust
249-
# #![feature(core)]
250-
std::iter::count(1, 5);
250+
# #![feature(step_by)]
251+
(1..).step_by(5);
251252
```
252253

253254
This iterator counts up from one, adding five each time. It will give
@@ -292,11 +293,11 @@ just use `for` instead.
292293
There are tons of interesting iterator adapters. `take(n)` will return an
293294
iterator over the next `n` elements of the original iterator, note that this
294295
has no side effect on the original iterator. Let's try it out with our infinite
295-
iterator from before, `count()`:
296+
iterator from before:
296297

297298
```rust
298-
# #![feature(core)]
299-
for i in std::iter::count(1, 5).take(5) {
299+
# #![feature(step_by)]
300+
for i in (1..).step_by(5).take(5) {
300301
println!("{}", i);
301302
}
302303
```

src/libcollections/bit.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
3939
//!
4040
//! ```
41-
//! # #![feature(collections, core)]
41+
//! # #![feature(collections, core, step_by)]
4242
//! use std::collections::{BitSet, BitVec};
4343
//! use std::num::Float;
4444
//! use std::iter;
@@ -60,7 +60,7 @@
6060
//! if bv[i] {
6161
//! // Mark all multiples of i as non-prime (any multiples below i * i
6262
//! // will have been marked as non-prime previously)
63-
//! for j in iter::range_step(i * i, max_prime, i) { bv.set(j, false) }
63+
//! for j in (i * i..max_prime).step_by(i) { bv.set(j, false) }
6464
//! }
6565
//! }
6666
//! BitSet::from_bit_vec(bv)
@@ -1264,14 +1264,6 @@ impl BitSet {
12641264
BitSet { bit_vec: bit_vec }
12651265
}
12661266

1267-
/// Deprecated: use `from_bit_vec`.
1268-
#[inline]
1269-
#[deprecated(since = "1.0.0", reason = "renamed to from_bit_vec")]
1270-
#[unstable(feature = "collections")]
1271-
pub fn from_bitv(bit_vec: BitVec) -> BitSet {
1272-
BitSet { bit_vec: bit_vec }
1273-
}
1274-
12751267
/// Returns the capacity in bits for this bit vector. Inserting any
12761268
/// element less than this amount will not trigger a resizing.
12771269
///

src/libcollections/borrow.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,26 +192,6 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
192192
Owned(owned) => owned
193193
}
194194
}
195-
196-
/// Returns true if this `Cow` wraps a borrowed value
197-
#[deprecated(since = "1.0.0", reason = "match on the enum instead")]
198-
#[unstable(feature = "std_misc")]
199-
pub fn is_borrowed(&self) -> bool {
200-
match *self {
201-
Borrowed(_) => true,
202-
_ => false,
203-
}
204-
}
205-
206-
/// Returns true if this `Cow` wraps an owned value
207-
#[deprecated(since = "1.0.0", reason = "match on the enum instead")]
208-
#[unstable(feature = "std_misc")]
209-
pub fn is_owned(&self) -> bool {
210-
match *self {
211-
Owned(_) => true,
212-
_ => false,
213-
}
214-
}
215195
}
216196

217197
#[stable(feature = "rust1", since = "1.0.0")]

src/libcollections/lib.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,6 @@ pub use string::String;
6868
pub use vec::Vec;
6969
pub use vec_map::VecMap;
7070

71-
#[deprecated(since = "1.0.0", reason = "renamed to vec_deque")]
72-
#[unstable(feature = "collections")]
73-
pub use vec_deque as ring_buf;
74-
75-
#[deprecated(since = "1.0.0", reason = "renamed to linked_list")]
76-
#[unstable(feature = "collections")]
77-
pub use linked_list as dlist;
78-
79-
#[deprecated(since = "1.0.0", reason = "renamed to bit_vec")]
80-
#[unstable(feature = "collections")]
81-
pub use bit_vec as bitv;
82-
83-
#[deprecated(since = "1.0.0", reason = "renamed to bit_set")]
84-
#[unstable(feature = "collections")]
85-
pub use bit_set as bitv_set;
86-
8771
// Needed for the vec! macro
8872
pub use alloc::boxed;
8973

@@ -108,21 +92,13 @@ pub mod vec_map;
10892
reason = "RFC 509")]
10993
pub mod bit_vec {
11094
pub use bit::{BitVec, Iter};
111-
112-
#[deprecated(since = "1.0.0", reason = "renamed to BitVec")]
113-
#[unstable(feature = "collections")]
114-
pub use bit::BitVec as Bitv;
11595
}
11696

11797
#[unstable(feature = "collections",
11898
reason = "RFC 509")]
11999
pub mod bit_set {
120100
pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference};
121101
pub use bit::SetIter as Iter;
122-
123-
#[deprecated(since = "1.0.0", reason = "renamed to BitSet")]
124-
#[unstable(feature = "collections")]
125-
pub use bit::BitSet as BitvSet;
126102
}
127103

128104
#[stable(feature = "rust1", since = "1.0.0")]

src/libcollections/linked_list.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ use core::iter::{self, FromIterator, IntoIterator};
3232
use core::mem;
3333
use core::ptr;
3434

35-
#[deprecated(since = "1.0.0", reason = "renamed to LinkedList")]
36-
#[unstable(feature = "collections")]
37-
pub use LinkedList as DList;
38-
3935
/// A doubly-linked list.
4036
#[stable(feature = "rust1", since = "1.0.0")]
4137
pub struct LinkedList<T> {
@@ -844,7 +840,7 @@ impl<A> ExactSizeIterator for IntoIter<A> {}
844840
#[stable(feature = "rust1", since = "1.0.0")]
845841
impl<A> FromIterator<A> for LinkedList<A> {
846842
fn from_iter<T: IntoIterator<Item=A>>(iter: T) -> LinkedList<A> {
847-
let mut ret = DList::new();
843+
let mut ret = LinkedList::new();
848844
ret.extend(iter);
849845
ret
850846
}

src/libcollections/slice.rs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ pub use core::slice::{IntSliceExt, SplitMut, ChunksMut, Split};
107107
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
108108
pub use core::slice::{bytes, mut_ref_slice, ref_slice};
109109
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
110-
pub use core::slice::{from_raw_buf, from_raw_mut_buf};
111110

112111
////////////////////////////////////////////////////////////////////////////////
113112
// Basic slice extension methods
@@ -281,33 +280,6 @@ impl<T> [T] {
281280
cmp::min(self.len(), end-start)
282281
}
283282

284-
/// Deprecated: use `&s[start .. end]` notation instead.
285-
#[unstable(feature = "collections",
286-
reason = "will be replaced by slice syntax")]
287-
#[deprecated(since = "1.0.0", reason = "use &s[start .. end] instead")]
288-
#[inline]
289-
pub fn slice(&self, start: usize, end: usize) -> &[T] {
290-
&self[start .. end]
291-
}
292-
293-
/// Deprecated: use `&s[start..]` notation instead.
294-
#[unstable(feature = "collections",
295-
reason = "will be replaced by slice syntax")]
296-
#[deprecated(since = "1.0.0", reason = "use &s[start..] instead")]
297-
#[inline]
298-
pub fn slice_from(&self, start: usize) -> &[T] {
299-
&self[start ..]
300-
}
301-
302-
/// Deprecated: use `&s[..end]` notation instead.
303-
#[unstable(feature = "collections",
304-
reason = "will be replaced by slice syntax")]
305-
#[deprecated(since = "1.0.0", reason = "use &s[..end] instead")]
306-
#[inline]
307-
pub fn slice_to(&self, end: usize) -> &[T] {
308-
&self[.. end]
309-
}
310-
311283
/// Divides one slice into two at an index.
312284
///
313285
/// The first will contain all indices from `[0, mid)` (excluding
@@ -611,42 +583,6 @@ impl<T> [T] {
611583
core_slice::SliceExt::get_mut(self, index)
612584
}
613585

614-
/// Deprecated: use `&mut s[..]` instead.
615-
#[unstable(feature = "collections",
616-
reason = "will be replaced by slice syntax")]
617-
#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")]
618-
#[allow(deprecated)]
619-
pub fn as_mut_slice(&mut self) -> &mut [T] {
620-
core_slice::SliceExt::as_mut_slice(self)
621-
}
622-
623-
/// Deprecated: use `&mut s[start .. end]` instead.
624-
#[unstable(feature = "collections",
625-
reason = "will be replaced by slice syntax")]
626-
#[deprecated(since = "1.0.0", reason = "use &mut s[start .. end] instead")]
627-
#[inline]
628-
pub fn slice_mut(&mut self, start: usize, end: usize) -> &mut [T] {
629-
&mut self[start .. end]
630-
}
631-
632-
/// Deprecated: use `&mut s[start ..]` instead.
633-
#[unstable(feature = "collections",
634-
reason = "will be replaced by slice syntax")]
635-
#[deprecated(since = "1.0.0", reason = "use &mut s[start ..] instead")]
636-
#[inline]
637-
pub fn slice_from_mut(&mut self, start: usize) -> &mut [T] {
638-
&mut self[start ..]
639-
}
640-
641-
/// Deprecated: use `&mut s[.. end]` instead.
642-
#[unstable(feature = "collections",
643-
reason = "will be replaced by slice syntax")]
644-
#[deprecated(since = "1.0.0", reason = "use &mut s[.. end] instead")]
645-
#[inline]
646-
pub fn slice_to_mut(&mut self, end: usize) -> &mut [T] {
647-
&mut self[.. end]
648-
}
649-
650586
/// Returns an iterator that allows modifying each value
651587
#[stable(feature = "rust1", since = "1.0.0")]
652588
#[inline]
@@ -937,13 +873,6 @@ impl<T> [T] {
937873
core_slice::SliceExt::binary_search(self, x)
938874
}
939875

940-
/// Deprecated: use `binary_search` instead.
941-
#[unstable(feature = "collections")]
942-
#[deprecated(since = "1.0.0", reason = "use binary_search instead")]
943-
pub fn binary_search_elem(&self, x: &T) -> Result<usize, usize> where T: Ord {
944-
self.binary_search(x)
945-
}
946-
947876
/// Mutates the slice to the next lexicographic permutation.
948877
///
949878
/// Returns `true` if successful and `false` if the slice is at the

src/libcollections/str.rs

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ use vec::Vec;
7070
use slice::SliceConcatExt;
7171

7272
pub use core::str::{FromStr, Utf8Error, Str};
73-
pub use core::str::{Lines, LinesAny, MatchIndices, SplitStr, CharRange};
73+
pub use core::str::{Lines, LinesAny, MatchIndices, CharRange};
7474
pub use core::str::{Split, SplitTerminator, SplitN};
7575
pub use core::str::{RSplit, RSplitN};
76-
pub use core::str::{from_utf8, CharEq, Chars, CharIndices, Bytes};
77-
pub use core::str::{from_utf8_unchecked, from_c_str, ParseBoolError};
76+
pub use core::str::{from_utf8, Chars, CharIndices, Bytes};
77+
pub use core::str::{from_utf8_unchecked, ParseBoolError};
7878
pub use unicode::str::{Words, Graphemes, GraphemeIndices};
7979
pub use core::str::Pattern;
8080
pub use core::str::{Searcher, ReverseSearcher, DoubleEndedSearcher, SearchStep};
@@ -536,22 +536,6 @@ impl str {
536536
core_str::StrExt::contains(&self[..], pat)
537537
}
538538

539-
/// Returns `true` if `self` contains a `char`.
540-
///
541-
/// # Examples
542-
///
543-
/// ```
544-
/// # #![feature(collections)]
545-
/// assert!("hello".contains_char('e'));
546-
///
547-
/// assert!(!"hello".contains_char('z'));
548-
/// ```
549-
#[unstable(feature = "collections")]
550-
#[deprecated(since = "1.0.0", reason = "use `contains()` with a char")]
551-
pub fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
552-
core_str::StrExt::contains_char(&self[..], pat)
553-
}
554-
555539
/// An iterator over the codepoints of `self`.
556540
///
557541
/// # Examples
@@ -778,25 +762,6 @@ impl str {
778762
core_str::StrExt::match_indices(&self[..], pat)
779763
}
780764

781-
/// An iterator over the substrings of `self` separated by a `&str`.
782-
///
783-
/// # Examples
784-
///
785-
/// ```
786-
/// # #![feature(collections)]
787-
/// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect();
788-
/// assert_eq!(v, ["", "XXX", "YYY", ""]);
789-
///
790-
/// let v: Vec<&str> = "1abcabc2".split_str("abc").collect();
791-
/// assert_eq!(v, ["1", "", "2"]);
792-
/// ```
793-
#[unstable(feature = "collections")]
794-
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
795-
#[allow(deprecated) /* for SplitStr */]
796-
pub fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
797-
core_str::StrExt::split_str(&self[..], pat)
798-
}
799-
800765
/// An iterator over the lines of a string, separated by `\n`.
801766
///
802767
/// This does not include the empty string after a trailing `\n`.
@@ -848,31 +813,6 @@ impl str {
848813
pub fn lines_any(&self) -> LinesAny {
849814
core_str::StrExt::lines_any(&self[..])
850815
}
851-
852-
/// Deprecated: use `s[a .. b]` instead.
853-
#[unstable(feature = "collections",
854-
reason = "use slice notation [a..b] instead")]
855-
#[deprecated(since = "1.0.0", reason = "use slice notation [a..b] instead")]
856-
pub fn slice(&self, begin: usize, end: usize) -> &str {
857-
&self[begin..end]
858-
}
859-
860-
/// Deprecated: use `s[a..]` instead.
861-
#[unstable(feature = "collections",
862-
reason = "use slice notation [a..b] instead")]
863-
#[deprecated(since = "1.0.0", reason = "use slice notation [a..] instead")]
864-
pub fn slice_from(&self, begin: usize) -> &str {
865-
&self[begin..]
866-
}
867-
868-
/// Deprecated: use `s[..a]` instead.
869-
#[unstable(feature = "collections",
870-
reason = "use slice notation [a..b] instead")]
871-
#[deprecated(since = "1.0.0", reason = "use slice notation [..a] instead")]
872-
pub fn slice_to(&self, end: usize) -> &str {
873-
&self[..end]
874-
}
875-
876816
/// Returns a slice of the string from the character range [`begin`..`end`).
877817
///
878818
/// That is, start at the `begin`-th code point of the string and continue
@@ -1306,27 +1246,6 @@ impl str {
13061246
core_str::StrExt::rfind(&self[..], pat)
13071247
}
13081248

1309-
/// Returns the byte index of the first matching substring if it exists.
1310-
///
1311-
/// Returns `None` if it doesn't exist.
1312-
///
1313-
/// The pattern can be a simple `&str`, or a closure that determines the split.
1314-
///
1315-
/// # Examples
1316-
///
1317-
/// ```
1318-
/// # #![feature(collections)]
1319-
/// let s = "Löwe 老虎 Léopard";
1320-
///
1321-
/// assert_eq!(s.find_str("老虎 L"), Some(6));
1322-
/// assert_eq!(s.find_str("muffin man"), None);
1323-
/// ```
1324-
#[unstable(feature = "collections")]
1325-
#[deprecated(since = "1.0.0", reason = "use `find()` with a `&str`")]
1326-
pub fn find_str<'a, P: Pattern<'a>>(&'a self, needle: P) -> Option<usize> {
1327-
core_str::StrExt::find_str(&self[..], needle)
1328-
}
1329-
13301249
/// Retrieves the first character from a `&str` and returns it.
13311250
///
13321251
/// This does not allocate a new string; instead, it returns a slice that points one character

0 commit comments

Comments
 (0)