Skip to content

Commit

Permalink
std: Stabilize/deprecate features for 1.4
Browse files Browse the repository at this point in the history
The FCP is coming to a close and 1.4 is coming out soon, so this brings in the
libs team decision for all library features this cycle.

Stabilized APIs:

* `<Box<str>>::into_string`
* `Arc::downgrade`
* `Arc::get_mut`
* `Arc::make_mut`
* `Arc::try_unwrap`
* `Box::from_raw`
* `Box::into_raw`
* `CStr::to_str`
* `CStr::to_string_lossy`
* `CString::from_raw`
* `CString::into_raw`
* `IntoRawFd::into_raw_fd`
* `IntoRawFd`
* `IntoRawHandle::into_raw_handle`
* `IntoRawHandle`
* `IntoRawSocket::into_raw_socket`
* `IntoRawSocket`
* `Rc::downgrade`
* `Rc::get_mut`
* `Rc::make_mut`
* `Rc::try_unwrap`
* `Result::expect`
* `String::into_boxed_slice`
* `TcpSocket::read_timeout`
* `TcpSocket::set_read_timeout`
* `TcpSocket::set_write_timeout`
* `TcpSocket::write_timeout`
* `UdpSocket::read_timeout`
* `UdpSocket::set_read_timeout`
* `UdpSocket::set_write_timeout`
* `UdpSocket::write_timeout`
* `Vec::append`
* `Vec::split_off`
* `VecDeque::append`
* `VecDeque::retain`
* `VecDeque::split_off`
* `rc::Weak::upgrade`
* `rc::Weak`
* `slice::Iter::as_slice`
* `slice::IterMut::into_slice`
* `str::CharIndices::as_str`
* `str::Chars::as_str`
* `str::split_at_mut`
* `str::split_at`
* `sync::Weak::upgrade`
* `sync::Weak`
* `thread::park_timeout`
* `thread::sleep`

Deprecated APIs

* `BTreeMap::with_b`
* `BTreeSet::with_b`
* `Option::as_mut_slice`
* `Option::as_slice`
* `Result::as_mut_slice`
* `Result::as_slice`
* `f32::from_str_radix`
* `f64::from_str_radix`

Closes rust-lang#27277
Closes rust-lang#27718
Closes rust-lang#27736
Closes rust-lang#27764
Closes rust-lang#27765
Closes rust-lang#27766
Closes rust-lang#27767
Closes rust-lang#27768
Closes rust-lang#27769
Closes rust-lang#27771
Closes rust-lang#27773
Closes rust-lang#27775
Closes rust-lang#27776
Closes rust-lang#27785
Closes rust-lang#27792
Closes rust-lang#27795
Closes rust-lang#27797
  • Loading branch information
alexcrichton committed Sep 11, 2015
1 parent 79c6a4d commit f0b1326
Show file tree
Hide file tree
Showing 31 changed files with 121 additions and 140 deletions.
30 changes: 13 additions & 17 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
/// Weak pointers will not keep the data inside of the `Arc` alive, and can be
/// used to break cycles between `Arc` pointers.
#[unsafe_no_drop_flag]
#[unstable(feature = "arc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_weak", since = "1.4.0")]
pub struct Weak<T: ?Sized> {
// FIXME #12808: strange name to try to avoid interfering with
// field accesses of the contained type via Deref
Expand Down Expand Up @@ -201,7 +201,6 @@ impl<T> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_unique)]
/// use std::sync::Arc;
///
/// let x = Arc::new(3);
Expand All @@ -212,7 +211,7 @@ impl<T> Arc<T> {
/// assert_eq!(Arc::try_unwrap(x), Err(Arc::new(4)));
/// ```
#[inline]
#[unstable(feature = "arc_unique", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_unique", since = "1.4.0")]
pub fn try_unwrap(this: Self) -> Result<T, Self> {
// See `drop` for why all these atomics are like this
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 { return Err(this) }
Expand All @@ -238,14 +237,13 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
///
/// let weak_five = Arc::downgrade(&five);
/// ```
#[unstable(feature = "arc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_weak", since = "1.4.0")]
pub fn downgrade(this: &Self) -> Weak<T> {
loop {
// This Relaxed is OK because we're checking the value in the CAS
Expand All @@ -270,14 +268,16 @@ impl<T: ?Sized> Arc<T> {

/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy", issue = "27718")]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
pub fn weak_count(this: &Self) -> usize {
this.inner().weak.load(SeqCst) - 1
}

/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy", issue = "27718")]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
pub fn strong_count(this: &Self) -> usize {
this.inner().strong.load(SeqCst)
}
Expand Down Expand Up @@ -366,7 +366,8 @@ impl<T: ?Sized> Deref for Arc<T> {
}

impl<T: Clone> Arc<T> {
#[unstable(feature = "arc_unique", reason = "renamed to Arc::make_mut", issue = "27718")]
#[unstable(feature = "arc_make_unique", reason = "renamed to Arc::make_mut",
issue = "27718")]
#[deprecated(since = "1.4.0", reason = "renamed to Arc::make_mut")]
pub fn make_unique(this: &mut Self) -> &mut T {
Arc::make_mut(this)
Expand All @@ -381,7 +382,6 @@ impl<T: Clone> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_unique)]
/// use std::sync::Arc;
///
/// let mut data = Arc::new(5);
Expand All @@ -398,7 +398,7 @@ impl<T: Clone> Arc<T> {
///
/// ```
#[inline]
#[unstable(feature = "arc_unique", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_unique", since = "1.4.0")]
pub fn make_mut(this: &mut Self) -> &mut T {
// Note that we hold both a strong reference and a weak reference.
// Thus, releasing our strong reference only will not, by itself, cause
Expand Down Expand Up @@ -460,7 +460,6 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_unique)]
/// use std::sync::Arc;
///
/// let mut x = Arc::new(3);
Expand All @@ -471,7 +470,7 @@ impl<T: ?Sized> Arc<T> {
/// assert!(Arc::get_mut(&mut x).is_none());
/// ```
#[inline]
#[unstable(feature = "arc_unique", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_unique", since = "1.4.0")]
pub fn get_mut(this: &mut Self) -> Option<&mut T> {
if this.is_unique() {
// This unsafety is ok because we're guaranteed that the pointer
Expand Down Expand Up @@ -595,7 +594,6 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Expand All @@ -604,7 +602,7 @@ impl<T: ?Sized> Weak<T> {
///
/// let strong_five: Option<Arc<_>> = weak_five.upgrade();
/// ```
#[unstable(feature = "arc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_weak", since = "1.4.0")]
pub fn upgrade(&self) -> Option<Arc<T>> {
// We use a CAS loop to increment the strong count instead of a
// fetch_add because once the count hits 0 it must never be above 0.
Expand All @@ -630,7 +628,7 @@ impl<T: ?Sized> Weak<T> {
}
}

#[unstable(feature = "arc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized> Clone for Weak<T> {
/// Makes a clone of the `Weak<T>`.
///
Expand All @@ -639,7 +637,6 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let weak_five = Arc::downgrade(&Arc::new(5));
Expand Down Expand Up @@ -672,7 +669,6 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// {
Expand Down
14 changes: 3 additions & 11 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,8 @@ impl<T : ?Sized> Box<T> {
/// Function is unsafe, because improper use of this function may
/// lead to memory problems like double-free, for example if the
/// function is called twice on the same raw pointer.
#[unstable(feature = "box_raw",
reason = "may be renamed or moved out of Box scope",
issue = "27768")]
#[stable(feature = "box_raw", since = "1.4.0")]
#[inline]
// NB: may want to be called from_ptr, see comments on CStr::from_ptr
pub unsafe fn from_raw(raw: *mut T) -> Self {
mem::transmute(raw)
}
Expand All @@ -244,17 +241,14 @@ impl<T : ?Sized> Box<T> {
/// `Box` does not specify, how memory is allocated.
///
/// # Examples
/// ```
/// #![feature(box_raw)]
///
/// ```
/// let seventeen = Box::new(17u32);
/// let raw = Box::into_raw(seventeen);
/// let boxed_again = unsafe { Box::from_raw(raw) };
/// ```
#[unstable(feature = "box_raw", reason = "may be renamed",
issue = "27768")]
#[stable(feature = "box_raw", since = "1.4.0")]
#[inline]
// NB: may want to be called into_ptr, see comments on CStr::from_ptr
pub fn into_raw(b: Box<T>) -> *mut T {
unsafe { mem::transmute(b) }
}
Expand Down Expand Up @@ -289,8 +283,6 @@ impl<T: Clone> Clone for Box<T> {
/// # Examples
///
/// ```
/// #![feature(box_raw)]
///
/// let x = Box::new(5);
/// let mut y = Box::new(10);
///
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
#![cfg_attr(stage0, feature(alloc_system))]
#![cfg_attr(not(stage0), feature(needs_allocator))]

#![cfg_attr(test, feature(test, rustc_private, box_raw))]
#![cfg_attr(test, feature(test, rustc_private))]

#[cfg(stage0)]
extern crate alloc_system;
Expand Down
44 changes: 18 additions & 26 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// FIXME(27718): rc_counts stuff is useful internally, but was previously public
#![allow(deprecated)]

//! Thread-local reference-counted boxes (the `Rc<T>` type).
Expand Down Expand Up @@ -94,8 +93,6 @@
//! documentation for more details on interior mutability.
//!
//! ```rust
//! #![feature(rc_weak)]
//!
//! use std::rc::Rc;
//! use std::rc::Weak;
//! use std::cell::RefCell;
Expand Down Expand Up @@ -242,7 +239,7 @@ impl<T> Rc<T> {
/// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
/// ```
#[inline]
#[unstable(feature = "rc_unique", reason= "needs FCP", issue = "27718")]
#[stable(feature = "rc_unique", since = "1.4.0")]
pub fn try_unwrap(this: Self) -> Result<T, Self> {
if Rc::would_unwrap(&this) {
unsafe {
Expand All @@ -263,8 +260,9 @@ impl<T> Rc<T> {
}

/// Checks if `Rc::try_unwrap` would return `Ok`.
#[unstable(feature = "rc_would_unwrap", reason = "just added for niche usecase",
issue = "27718")]
#[unstable(feature = "rc_would_unwrap",
reason = "just added for niche usecase",
issue = "28356")]
pub fn would_unwrap(this: &Self) -> bool {
Rc::strong_count(&this) == 1
}
Expand All @@ -276,28 +274,28 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
///
/// let weak_five = Rc::downgrade(&five);
/// ```
#[unstable(feature = "rc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_weak", since = "1.4.0")]
pub fn downgrade(this: &Self) -> Weak<T> {
this.inc_weak();
Weak { _ptr: this._ptr }
}

/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "rc_counts", reason = "not clearly useful", issue = "27718")]
#[unstable(feature = "rc_counts", reason = "not clearly useful",
issue = "28356")]
pub fn weak_count(this: &Self) -> usize { this.weak() - 1 }

/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "rc_counts", reason = "not clearly useful", issue = "27718")]
#[unstable(feature = "rc_counts", reason = "not clearly useful",
issue = "28356")]
pub fn strong_count(this: &Self) -> usize { this.strong() }

/// Returns true if there are no other `Rc` or `Weak<T>` values that share
Expand All @@ -315,7 +313,8 @@ impl<T: ?Sized> Rc<T> {
/// assert!(Rc::is_unique(&five));
/// ```
#[inline]
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning", issue = "27718")]
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning",
issue = "28356")]
pub fn is_unique(this: &Self) -> bool {
Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1
}
Expand All @@ -328,8 +327,6 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// #![feature(rc_unique)]
///
/// use std::rc::Rc;
///
/// let mut x = Rc::new(3);
Expand All @@ -340,7 +337,7 @@ impl<T: ?Sized> Rc<T> {
/// assert!(Rc::get_mut(&mut x).is_none());
/// ```
#[inline]
#[unstable(feature = "rc_unique", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_unique", since = "1.4.0")]
pub fn get_mut(this: &mut Self) -> Option<&mut T> {
if Rc::is_unique(this) {
let inner = unsafe { &mut **this._ptr };
Expand All @@ -353,7 +350,8 @@ impl<T: ?Sized> Rc<T> {

impl<T: Clone> Rc<T> {
#[inline]
#[unstable(feature = "rc_unique", reason = "renamed to Rc::make_mut", issue = "27718")]
#[unstable(feature = "rc_make_unique", reason = "renamed to Rc::make_mut",
issue = "27718")]
#[deprecated(since = "1.4.0", reason = "renamed to Rc::make_mut")]
pub fn make_unique(&mut self) -> &mut T {
Rc::make_mut(self)
Expand Down Expand Up @@ -385,7 +383,7 @@ impl<T: Clone> Rc<T> {
///
/// ```
#[inline]
#[unstable(feature = "rc_unique", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_unique", since = "1.4.0")]
pub fn make_mut(this: &mut Self) -> &mut T {
if Rc::strong_count(this) != 1 {
// Gotta clone the data, there are other Rcs
Expand Down Expand Up @@ -693,7 +691,7 @@ impl<T> fmt::Pointer for Rc<T> {
///
/// See the [module level documentation](./index.html) for more.
#[unsafe_no_drop_flag]
#[unstable(feature = "rc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_weak", since = "1.4.0")]
pub struct Weak<T: ?Sized> {
// FIXME #12808: strange names to try to avoid interfering with
// field accesses of the contained type via Deref
Expand All @@ -716,8 +714,6 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand All @@ -726,7 +722,7 @@ impl<T: ?Sized> Weak<T> {
///
/// let strong_five: Option<Rc<_>> = weak_five.upgrade();
/// ```
#[unstable(feature = "rc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_weak", since = "1.4.0")]
pub fn upgrade(&self) -> Option<Rc<T>> {
if self.strong() == 0 {
None
Expand All @@ -746,8 +742,6 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// {
Expand Down Expand Up @@ -783,7 +777,7 @@ impl<T: ?Sized> Drop for Weak<T> {
}
}

#[unstable(feature = "rc_weak", reason = "needs FCP", issue = "27718")]
#[stable(feature = "rc_weak", since = "1.4.0")]
impl<T: ?Sized> Clone for Weak<T> {

/// Makes a clone of the `Weak<T>`.
Expand All @@ -793,8 +787,6 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let weak_five = Rc::downgrade(&Rc::new(5));
Expand Down
3 changes: 3 additions & 0 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub struct OccupiedEntry<'a, K:'a, V:'a> {
impl<K: Ord, V> BTreeMap<K, V> {
/// Makes a new empty BTreeMap with a reasonable choice for B.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn new() -> BTreeMap<K, V> {
//FIXME(Gankro): Tune this as a function of size_of<K/V>?
BTreeMap::with_b(6)
Expand All @@ -160,6 +161,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
#[unstable(feature = "btree_b",
reason = "probably want this to be on the type, eventually",
issue = "27795")]
#[deprecated(since = "1.4.0", reason = "niche API")]
pub fn with_b(b: usize) -> BTreeMap<K, V> {
assert!(b > 1, "B must be greater than 1");
BTreeMap {
Expand All @@ -183,6 +185,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// assert!(a.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn clear(&mut self) {
let b = self.b;
// avoid recursive destructors by manually traversing the tree
Expand Down
Loading

0 comments on commit f0b1326

Please sign in to comment.