Skip to content

Commit

Permalink
std: Stabilize APIs for the 1.10 release
Browse files Browse the repository at this point in the history
This commit applies the FCP decisions made by the libs team for the 1.10 cycle,
including both new stabilizations and deprecations. Specifically, the list of
APIs is:

Stabilized:

* `os::windows::fs::OpenOptionsExt::access_mode`
* `os::windows::fs::OpenOptionsExt::share_mode`
* `os::windows::fs::OpenOptionsExt::custom_flags`
* `os::windows::fs::OpenOptionsExt::attributes`
* `os::windows::fs::OpenOptionsExt::security_qos_flags`
* `os::unix::fs::OpenOptionsExt::custom_flags`
* `sync::Weak::new`
* `Default for sync::Weak`
* `panic::set_hook`
* `panic::take_hook`
* `panic::PanicInfo`
* `panic::PanicInfo::payload`
* `panic::PanicInfo::location`
* `panic::Location`
* `panic::Location::file`
* `panic::Location::line`
* `ffi::CStr::from_bytes_with_nul`
* `ffi::CStr::from_bytes_with_nul_unchecked`
* `ffi::FromBytesWithNulError`
* `fs::Metadata::modified`
* `fs::Metadata::accessed`
* `fs::Metadata::created`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange`
* `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak`
* `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key`
* `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}`
* `SocketAddr::is_unnamed`
* `SocketAddr::as_pathname`
* `UnixStream::connect`
* `UnixStream::pair`
* `UnixStream::try_clone`
* `UnixStream::local_addr`
* `UnixStream::peer_addr`
* `UnixStream::set_read_timeout`
* `UnixStream::set_write_timeout`
* `UnixStream::read_timeout`
* `UnixStream::write_Timeout`
* `UnixStream::set_nonblocking`
* `UnixStream::take_error`
* `UnixStream::shutdown`
* Read/Write/RawFd impls for `UnixStream`
* `UnixListener::bind`
* `UnixListener::accept`
* `UnixListener::try_clone`
* `UnixListener::local_addr`
* `UnixListener::set_nonblocking`
* `UnixListener::take_error`
* `UnixListener::incoming`
* RawFd impls for `UnixListener`
* `UnixDatagram::bind`
* `UnixDatagram::unbound`
* `UnixDatagram::pair`
* `UnixDatagram::connect`
* `UnixDatagram::try_clone`
* `UnixDatagram::local_addr`
* `UnixDatagram::peer_addr`
* `UnixDatagram::recv_from`
* `UnixDatagram::recv`
* `UnixDatagram::send_to`
* `UnixDatagram::send`
* `UnixDatagram::set_read_timeout`
* `UnixDatagram::set_write_timeout`
* `UnixDatagram::read_timeout`
* `UnixDatagram::write_timeout`
* `UnixDatagram::set_nonblocking`
* `UnixDatagram::take_error`
* `UnixDatagram::shutdown`
* RawFd impls for `UnixDatagram`
* `{BTree,Hash}Map::values_mut`
* `<[_]>::binary_search_by_key`

Deprecated:

* `StaticCondvar` - this, and all other static synchronization primitives
                    below, are usable today through the lazy-static crate on
                    stable Rust today. Additionally, we'd like the non-static
                    versions to be directly usable in a static context one day,
                    so they're unlikely to be the final forms of the APIs in any
                    case.
* `CONDVAR_INIT`
* `StaticMutex`
* `MUTEX_INIT`
* `StaticRwLock`
* `RWLOCK_INIT`
* `iter::Peekable::is_empty`

Closes rust-lang#27717
Closes rust-lang#27720
cc rust-lang#27784 (but encode methods still exist)
Closes rust-lang#30014
Closes rust-lang#30425
Closes rust-lang#30449
Closes rust-lang#31190
Closes rust-lang#31399
Closes rust-lang#31767
Closes rust-lang#32111
Closes rust-lang#32281
Closes rust-lang#32312
Closes rust-lang#32551
Closes rust-lang#33018
  • Loading branch information
alexcrichton committed May 24, 2016
1 parent 30422de commit cae91d7
Show file tree
Hide file tree
Showing 37 changed files with 567 additions and 494 deletions.
61 changes: 32 additions & 29 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,31 @@ impl<T: ?Sized> Drop for Arc<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// use std::sync::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
unsafe {
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
}))}
}
}
}

impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
Expand Down Expand Up @@ -682,6 +707,13 @@ impl<T: ?Sized> Clone for Weak<T> {
}
}

#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
fn default() -> Weak<T> {
Weak::new()
}
}

#[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized> Drop for Weak<T> {
/// Drops the `Weak<T>`.
Expand Down Expand Up @@ -907,35 +939,6 @@ impl<T> From<T> for Arc<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// #![feature(downgraded_weak)]
///
/// use std::sync::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[unstable(feature = "downgraded_weak",
reason = "recently added",
issue = "30425")]
pub fn new() -> Weak<T> {
unsafe {
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
}))}
}
}
}

#[cfg(test)]
mod tests {
use std::clone::Clone;
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(unsize)]
#![feature(extended_compare_and_swap)]

#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
#![cfg_attr(test, feature(test, box_heap))]
Expand Down
59 changes: 31 additions & 28 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,33 @@ impl<T: ?Sized> !marker::Sync for Weak<T> {}
#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// use std::rc::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Shared::new(Box::into_raw(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninitialized(),
})),
}
}
}
}

impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
Expand Down Expand Up @@ -823,34 +850,10 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// #![feature(downgraded_weak)]
///
/// use std::rc::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[unstable(feature = "downgraded_weak",
reason = "recently added",
issue="30425")]
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Shared::new(Box::into_raw(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninitialized(),
})),
}
}
#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
fn default() -> Weak<T> {
Weak::new()
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
}

/// A mutable iterator over a BTreeMap's values.
#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
type Item = &'a mut V;

Expand All @@ -1157,14 +1157,14 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> {
fn next_back(&mut self) -> Option<&'a mut V> {
self.inner.next_back().map(|(_, v)| v)
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
fn len(&self) -> usize {
self.inner.len()
Expand Down Expand Up @@ -1575,7 +1575,6 @@ impl<K, V> BTreeMap<K, V> {
/// Basic usage:
///
/// ```
/// # #![feature(map_values_mut)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
Expand All @@ -1590,8 +1589,8 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!(values, [String::from("hello!"),
/// String::from("goodbye!")]);
/// ```
#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
pub fn values_mut<'a>(&'a mut self) -> ValuesMut<'a, K, V> {
#[stable(feature = "map_values_mut", since = "1.10.0")]
pub fn values_mut(&mut self) -> ValuesMut<K, V> {
ValuesMut { inner: self.iter_mut() }
}

Expand Down Expand Up @@ -1656,7 +1655,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
}

/// Returns a reference to this entry's key.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
match *self {
Occupied(ref entry) => entry.key(),
Expand All @@ -1668,7 +1667,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
/// Gets a reference to the key that would be used when inserting a value
/// through the VacantEntry.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
&self.key
}
Expand Down Expand Up @@ -1718,7 +1717,7 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {

impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
/// Gets a reference to the key in the entry.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
self.handle.reborrow().into_kv().0
}
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]

#![cfg_attr(test, allow(deprecated))] // rand
#![cfg_attr(not(test), feature(slice_binary_search_by_key))] // impl [T]
#![cfg_attr(not(stage0), deny(warnings))]

#![feature(alloc)]
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ impl<T> [T] {
/// fourth could match any position in `[1,4]`.
///
/// ```rust
/// #![feature(slice_binary_search_by_key)]
/// let s = [(0, 0), (2, 1), (4, 1), (5, 1), (3, 1),
/// (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
/// (1, 21), (2, 34), (4, 55)];
Expand All @@ -770,7 +769,7 @@ impl<T> [T] {
/// let r = s.binary_search_by_key(&1, |&(a,b)| b);
/// assert!(match r { Ok(1...4) => true, _ => false, });
/// ```
#[unstable(feature = "slice_binary_search_by_key", reason = "recently added", issue = "33018")]
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
#[inline]
pub fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&T) -> B,
Expand Down
2 changes: 0 additions & 2 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#![feature(enumset)]
#![feature(iter_arith)]
#![feature(linked_list_contains)]
#![feature(map_entry_keys)]
#![feature(map_values_mut)]
#![feature(pattern)]
#![feature(rand)]
#![feature(step_by)]
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#![allow(non_snake_case)]
#![stable(feature = "core_char", since = "1.2.0")]

use iter::Iterator;
use prelude::v1::*;

use mem::transmute;
use option::Option::{None, Some};
use option::Option;
use slice::SliceExt;

// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000;
Expand Down
1 change: 1 addition & 0 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ impl<I: Iterator> Peekable<I> {
/// ```
#[unstable(feature = "peekable_is_empty", issue = "32111")]
#[inline]
#[rustc_deprecated(since = "1.10.0", reason = "replaced by .peek().is_none()")]
pub fn is_empty(&mut self) -> bool {
self.peek().is_none()
}
Expand Down
9 changes: 4 additions & 5 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ pub trait SliceExt {
#[stable(feature = "core", since = "1.6.0")]
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> Ordering;
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> B,
B: Ord;
#[stable(feature = "core", since = "1.6.0")]
fn len(&self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
Expand Down Expand Up @@ -157,11 +161,6 @@ pub trait SliceExt {
fn clone_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Clone;
#[stable(feature = "copy_from_slice", since = "1.9.0")]
fn copy_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Copy;

#[unstable(feature = "slice_binary_search_by_key", reason = "recently added", issue = "33018")]
fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> B,
B: Ord;
}

// Use macros to be generic over const/mut
Expand Down

0 comments on commit cae91d7

Please sign in to comment.