Skip to content

Commit

Permalink
std: Stabilize library APIs for 1.5
Browse files Browse the repository at this point in the history
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:

Stabilized APIs:

* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
   is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
  but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`

Deprecated APIs

* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`

Closes rust-lang#27706
Closes rust-lang#27725
cc rust-lang#27726 (align not stabilized yet)
Closes rust-lang#27734
Closes rust-lang#27737
Closes rust-lang#27742
Closes rust-lang#27743
Closes rust-lang#27772
Closes rust-lang#27774
Closes rust-lang#27777
Closes rust-lang#27781
cc rust-lang#27788 (a few remaining methods though)
Closes rust-lang#27790
Closes rust-lang#27793
Closes rust-lang#27796
Closes rust-lang#27810
cc rust-lang#28147 (not all parts stabilized)
  • Loading branch information
alexcrichton committed Oct 25, 2015
1 parent 9a85566 commit ff49733
Show file tree
Hide file tree
Showing 60 changed files with 274 additions and 195 deletions.
2 changes: 0 additions & 2 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#![feature(box_syntax)]
#![feature(dynamic_lib)]
#![feature(libc)]
#![feature(path_ext)]
#![feature(rustc_private)]
#![feature(slice_splits)]
#![feature(str_char)]
#![feature(test)]
#![feature(vec_push_all)]
Expand Down
2 changes: 2 additions & 0 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(deprecated)]

use std::dynamic_lib::DynamicLibrary;
use std::io::prelude::*;
use std::path::PathBuf;
Expand Down
61 changes: 31 additions & 30 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,9 @@ impl<T: Ord> BinaryHeap<T> {
#[unstable(feature = "binary_heap_extras",
reason = "needs to be audited",
issue = "28147")]
#[deprecated(since = "1.5.0", reason = "use BinaryHeap::from instead")]
pub fn from_vec(vec: Vec<T>) -> BinaryHeap<T> {
let mut heap = BinaryHeap { data: vec };
let mut n = heap.len() / 2;
while n > 0 {
n -= 1;
heap.sift_down(n);
}
heap
BinaryHeap::from(vec)
}

/// Returns an iterator visiting all values in the underlying vector, in
Expand All @@ -256,10 +251,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// #![feature(binary_heap_extras)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
///
/// // Print 1, 2, 3, 4 in arbitrary order
/// for x in heap.iter() {
Expand Down Expand Up @@ -362,10 +355,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// #![feature(binary_heap_extras)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
/// let mut heap = BinaryHeap::from(vec![1, 3]);
///
/// assert_eq!(heap.pop(), Some(3));
/// assert_eq!(heap.pop(), Some(1));
Expand Down Expand Up @@ -475,42 +466,36 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// #![feature(binary_heap_extras)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
/// let vec = heap.into_vec();
///
/// // Will print in some order
/// for x in vec {
/// println!("{}", x);
/// }
/// ```
#[unstable(feature = "binary_heap_extras",
reason = "needs to be audited",
issue = "28147")]
pub fn into_vec(self) -> Vec<T> { self.data }
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
pub fn into_vec(self) -> Vec<T> {
self.into()
}

/// Consumes the `BinaryHeap` and returns a vector in sorted
/// (ascending) order.
///
/// # Examples
///
/// ```
/// #![feature(binary_heap_extras)]
///
/// use std::collections::BinaryHeap;
///
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);
/// let mut heap = BinaryHeap::from(vec![1, 2, 4, 5, 7]);
/// heap.push(6);
/// heap.push(3);
///
/// let vec = heap.into_sorted_vec();
/// assert_eq!(vec, [1, 2, 3, 4, 5, 6, 7]);
/// ```
#[unstable(feature = "binary_heap_extras",
reason = "needs to be audited",
issue = "28147")]
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
pub fn into_sorted_vec(mut self) -> Vec<T> {
let mut end = self.len();
while end > 1 {
Expand Down Expand Up @@ -744,10 +729,28 @@ impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {}

impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
fn from(vec: Vec<T>) -> BinaryHeap<T> {
let mut heap = BinaryHeap { data: vec };
let mut n = heap.len() / 2;
while n > 0 {
n -= 1;
heap.sift_down(n);
}
heap
}
}

impl<T> From<BinaryHeap<T>> for Vec<T> {
fn from(heap: BinaryHeap<T>) -> Vec<T> {
heap.data
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> BinaryHeap<T> {
BinaryHeap::from_vec(iter.into_iter().collect())
BinaryHeap::from(iter.into_iter().collect::<Vec<_>>())
}
}

Expand All @@ -763,10 +766,8 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
/// # Examples
///
/// ```
/// #![feature(binary_heap_extras)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
///
/// // Print 1, 2, 3, 4 in arbitrary order
/// for x in heap.into_iter() {
Expand Down
3 changes: 0 additions & 3 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#![feature(fmt_internals)]
#![feature(fmt_radix)]
#![feature(heap_api)]
#![feature(iter_order)]
#![feature(iter_arith)]
#![feature(iter_arith)]
#![feature(lang_items)]
Expand All @@ -60,14 +59,12 @@
#![feature(staged_api)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(str_match_indices)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unique)]
#![feature(dropck_parametricity)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(decode_utf16)]
#![feature(utf8_error)]
#![cfg_attr(test, feature(clone_from_slice, rand, test))]

#![feature(no_std)]
Expand Down
9 changes: 5 additions & 4 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub use core::slice::{Chunks, Windows};
pub use core::slice::{Iter, IterMut};
pub use core::slice::{SplitMut, ChunksMut, Split};
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
#[allow(deprecated)]
pub use core::slice::{bytes, mut_ref_slice, ref_slice};
pub use core::slice::{from_raw_parts, from_raw_parts_mut};

Expand Down Expand Up @@ -214,29 +215,29 @@ impl<T> [T] {
}

/// Returns the first and all the rest of the elements of a slice.
#[unstable(feature = "slice_splits", reason = "new API", issue = "27742")]
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_first(&self) -> Option<(&T, &[T])> {
core_slice::SliceExt::split_first(self)
}

/// Returns the first and all the rest of the elements of a slice.
#[unstable(feature = "slice_splits", reason = "new API", issue = "27742")]
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])> {
core_slice::SliceExt::split_first_mut(self)
}

/// Returns the last and all the rest of the elements of a slice.
#[unstable(feature = "slice_splits", reason = "new API", issue = "27742")]
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_last(&self) -> Option<(&T, &[T])> {
core_slice::SliceExt::split_last(self)

}

/// Returns the last and all the rest of the elements of a slice.
#[unstable(feature = "slice_splits", reason = "new API", issue = "27742")]
#[stable(feature = "slice_splits", since = "1.5.0")]
#[inline]
pub fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])> {
core_slice::SliceExt::split_last_mut(self)
Expand Down
11 changes: 3 additions & 8 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ impl str {
/// Takes a bytewise mutable slice from a string.
///
/// Same as `slice_unchecked`, but works with `&mut str` instead of `&str`.
#[unstable(feature = "str_slice_mut", reason = "recently added",
issue = "27793")]
#[stable(feature = "str_slice_mut", since = "1.5.0")]
#[inline]
pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str {
core_str::StrExt::slice_mut_unchecked(self, begin, end)
Expand Down Expand Up @@ -1192,9 +1191,7 @@ impl str {
/// let v: Vec<_> = "ababa".match_indices("aba").collect();
/// assert_eq!(v, [(0, "aba")]); // only the first `aba`
/// ```
#[unstable(feature = "str_match_indices",
reason = "might have its iterator type changed",
issue = "27743")]
#[stable(feature = "str_match_indices", since = "1.5.0")]
pub fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P> {
core_str::StrExt::match_indices(self, pat)
}
Expand Down Expand Up @@ -1231,9 +1228,7 @@ impl str {
/// let v: Vec<_> = "ababa".rmatch_indices("aba").collect();
/// assert_eq!(v, [(2, "aba")]); // only the last `aba`
/// ```
#[unstable(feature = "str_match_indices",
reason = "might have its iterator type changed",
issue = "27743")]
#[stable(feature = "str_match_indices", since = "1.5.0")]
pub fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P>
where P::Searcher: ReverseSearcher<'a>
{
Expand Down
4 changes: 1 addition & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,7 @@ impl ops::DerefMut for String {
}

/// Error returned from `String::from`
#[unstable(feature = "str_parse_error", reason = "may want to be replaced with \
Void if it ever exists",
issue = "27734")]
#[stable(feature = "str_parse_error", since = "1.5.0")]
#[derive(Copy)]
pub enum ParseError {}

Expand Down
6 changes: 1 addition & 5 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,6 @@ impl<T: Clone> Vec<T> {
/// # Examples
///
/// ```
/// #![feature(vec_resize)]
///
/// let mut vec = vec!["hello"];
/// vec.resize(3, "world");
/// assert_eq!(vec, ["hello", "world", "world"]);
Expand All @@ -875,9 +873,7 @@ impl<T: Clone> Vec<T> {
/// vec.resize(2, 0);
/// assert_eq!(vec, [1, 2]);
/// ```
#[unstable(feature = "vec_resize",
reason = "matches collection reform specification; waiting for dust to settle",
issue = "27790")]
#[stable(feature = "vec_resize", since = "1.5.0")]
pub fn resize(&mut self, new_len: usize, value: T) {
let len = self.len();

Expand Down
Loading

0 comments on commit ff49733

Please sign in to comment.