From cae91d7c8c21aa860bda29c62207a6726837952b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 17 May 2016 11:57:07 -0700 Subject: std: Stabilize APIs for the 1.10 release 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 #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018 --- src/libstd/sync/condvar.rs | 24 ++++++++++++++++++++++++ src/libstd/sync/mod.rs | 4 ++++ src/libstd/sync/mutex.rs | 28 +++++++++++++++++++++++++++- src/libstd/sync/rwlock.rs | 31 ++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 2 deletions(-) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 57932f03796..bf4b119a0b6 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -72,6 +72,7 @@ impl WaitTimeoutResult { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct Condvar { inner: Box } /// Statically allocated condition variables. @@ -91,6 +92,11 @@ pub struct Condvar { inner: Box } #[unstable(feature = "static_condvar", reason = "may be merged with Condvar in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Condvar::new` in a static should \ + suffice")] pub struct StaticCondvar { inner: sys::Condvar, mutex: AtomicUsize, @@ -100,8 +106,15 @@ pub struct StaticCondvar { #[unstable(feature = "static_condvar", reason = "may be merged with Condvar in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Condvar::new` in a static should \ + suffice")] +#[allow(deprecated)] pub const CONDVAR_INIT: StaticCondvar = StaticCondvar::new(); +#[allow(deprecated)] impl Condvar { /// Creates a new condition variable which is ready to be waited on and /// notified. @@ -228,12 +241,22 @@ impl Default for Condvar { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Drop for Condvar { fn drop(&mut self) { unsafe { self.inner.inner.destroy() } } } +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Condvar::new` in a static should \ + suffice")] +#[unstable(feature = "static_condvar", + reason = "may be merged with Condvar in the future", + issue = "27717")] +#[allow(deprecated)] impl StaticCondvar { /// Creates a new condition variable #[unstable(feature = "static_condvar", @@ -392,6 +415,7 @@ impl StaticCondvar { } #[cfg(test)] +#[allow(deprecated)] mod tests { use prelude::v1::*; diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 21008ee3989..56eb7340c89 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -25,10 +25,13 @@ pub use core::sync::atomic; #[stable(feature = "rust1", since = "1.0.0")] pub use self::barrier::{Barrier, BarrierWaitResult}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::condvar::{Condvar, StaticCondvar, WaitTimeoutResult, CONDVAR_INIT}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::mutex::MUTEX_INIT; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::mutex::{Mutex, MutexGuard, StaticMutex}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::once::{Once, OnceState, ONCE_INIT}; @@ -37,6 +40,7 @@ pub use sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResul #[stable(feature = "rust1", since = "1.0.0")] pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT}; pub mod mpsc; diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 90cc79dad66..15e69628c7a 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -113,6 +113,7 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// *guard += 1; /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct Mutex { // Note that this static mutex is in a *box*, not inlined into the struct // itself. Once a native mutex has been used once, its address can never @@ -156,6 +157,11 @@ unsafe impl Sync for Mutex { } #[unstable(feature = "static_mutex", reason = "may be merged with Mutex in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Mutex::new` in a static should \ + suffice")] pub struct StaticMutex { lock: sys::Mutex, poison: poison::Flag, @@ -168,6 +174,7 @@ pub struct StaticMutex { /// `Deref` and `DerefMut` implementations #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct MutexGuard<'a, T: ?Sized + 'a> { // funny underscores due to how Deref/DerefMut currently work (they // disregard field privacy). @@ -184,8 +191,15 @@ impl<'a, T: ?Sized> !marker::Send for MutexGuard<'a, T> {} #[unstable(feature = "static_mutex", reason = "may be merged with Mutex in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Mutex::new` in a static should \ + suffice")] +#[allow(deprecated)] pub const MUTEX_INIT: StaticMutex = StaticMutex::new(); +#[allow(deprecated)] impl Mutex { /// Creates a new mutex in an unlocked state ready for use. #[stable(feature = "rust1", since = "1.0.0")] @@ -197,6 +211,7 @@ impl Mutex { } } +#[allow(deprecated)] impl Mutex { /// Acquires a mutex, blocking the current thread until it is able to do so. /// @@ -307,6 +322,7 @@ impl Mutex { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Drop for Mutex { #[unsafe_destructor_blind_to_params] fn drop(&mut self) { @@ -346,6 +362,12 @@ static DUMMY: Dummy = Dummy(UnsafeCell::new(())); #[unstable(feature = "static_mutex", reason = "may be merged with Mutex in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `Mutex::new` in a static should \ + suffice")] +#[allow(deprecated)] impl StaticMutex { /// Creates a new mutex in an unlocked state ready for use. pub const fn new() -> StaticMutex { @@ -391,8 +413,8 @@ impl StaticMutex { } } +#[allow(deprecated)] impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { - unsafe fn new(lock: &'mutex StaticMutex, data: &'mutex UnsafeCell) -> LockResult> { poison::map_result(lock.poison.borrow(), |guard| { @@ -418,6 +440,7 @@ impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { #[inline] fn drop(&mut self) { @@ -428,15 +451,18 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { } } +#[allow(deprecated)] pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex { &guard.__lock.lock } +#[allow(deprecated)] pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag { &guard.__lock.poison } #[cfg(test)] +#[allow(deprecated)] mod tests { use prelude::v1::*; diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index cfb8ee16cb0..e1e764bd255 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -66,6 +66,7 @@ use sys_common::rwlock as sys; /// } // write lock is dropped here /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct RwLock { inner: Box, data: UnsafeCell, @@ -104,6 +105,11 @@ unsafe impl Sync for RwLock {} #[unstable(feature = "static_rwlock", reason = "may be merged with RwLock in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `RwLock::new` in a static should \ + suffice")] pub struct StaticRwLock { lock: sys::RWLock, poison: poison::Flag, @@ -113,12 +119,19 @@ pub struct StaticRwLock { #[unstable(feature = "static_rwlock", reason = "may be merged with RwLock in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `RwLock::new` in a static should \ + suffice")] +#[allow(deprecated)] pub const RW_LOCK_INIT: StaticRwLock = StaticRwLock::new(); /// RAII structure used to release the shared read access of a lock when /// dropped. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { __lock: &'a StaticRwLock, __data: &'a T, @@ -131,6 +144,7 @@ impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {} /// dropped. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { __lock: &'a StaticRwLock, __data: &'a mut T, @@ -140,6 +154,7 @@ pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: ?Sized> !marker::Send for RwLockWriteGuard<'a, T> {} +#[allow(deprecated)] impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// @@ -156,6 +171,7 @@ impl RwLock { } } +#[allow(deprecated)] impl RwLock { /// Locks this rwlock with shared read access, blocking the current thread /// until it can be acquired. @@ -325,6 +341,7 @@ impl RwLock { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Drop for RwLock { #[unsafe_destructor_blind_to_params] fn drop(&mut self) { @@ -360,6 +377,12 @@ static DUMMY: Dummy = Dummy(UnsafeCell::new(())); #[unstable(feature = "static_rwlock", reason = "may be merged with RwLock in the future", issue = "27717")] +#[rustc_deprecated(since = "1.10.0", + reason = "the lazy-static crate suffices for static sync \ + primitives and eventually this type shouldn't \ + be necessary as `RwLock::new` in a static should \ + suffice")] +#[allow(deprecated)] impl StaticRwLock { /// Creates a new rwlock. pub const fn new() -> StaticRwLock { @@ -434,6 +457,7 @@ impl StaticRwLock { } } +#[allow(deprecated)] impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { unsafe fn new(lock: &'rwlock StaticRwLock, data: &'rwlock UnsafeCell) -> LockResult> { @@ -482,6 +506,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { } } +#[allow(deprecated)] impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { unsafe fn new(lock: &'rwlock StaticRwLock, data: &'rwlock UnsafeCell) -> LockResult> { @@ -562,10 +587,12 @@ impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T> { - fn deref_mut(&mut self) -> &mut T { self.__data + fn deref_mut(&mut self) -> &mut T { + self.__data } } +#[allow(deprecated)] #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> { fn drop(&mut self) { @@ -573,6 +600,7 @@ impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T> { } } +#[allow(deprecated)] #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { fn drop(&mut self) { @@ -582,6 +610,7 @@ impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T> { } #[cfg(test)] +#[allow(deprecated)] mod tests { #![allow(deprecated)] // rand -- cgit 1.4.1-3-g733a5