diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-05-24 14:24:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-05-30 20:46:32 -0700 |
| commit | b64c9d56700e2c41207166fe8709711ff02488ff (patch) | |
| tree | 82e982ea6a6840e3f0f4d3d82a4d2ad24771200b /src/libstd | |
| parent | a967611d8ffececb5ed0ecf6a205b464d7a5a31e (diff) | |
| download | rust-b64c9d56700e2c41207166fe8709711ff02488ff.tar.gz rust-b64c9d56700e2c41207166fe8709711ff02488ff.zip | |
std: Clean out old unstable + deprecated APIs
These should all have been deprecated for at least one cycle, so this commit cleans them all out.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/panic.rs | 96 | ||||
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 105 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/process.rs | 20 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 11 | ||||
| -rw-r--r-- | src/libstd/thread/mod.rs | 10 | ||||
| -rw-r--r-- | src/libstd/thread/scoped_tls.rs | 298 | ||||
| -rw-r--r-- | src/libstd/time/mod.rs | 15 |
7 files changed, 2 insertions, 553 deletions
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 016130e9998..d8cadf09cb2 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -25,21 +25,7 @@ use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use panicking::{take_hook, set_hook, PanicInfo, Location}; -/// -#[rustc_deprecated(since = "1.9.0", reason = "renamed to set_hook")] -#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")] -pub fn set_handler<F>(handler: F) where F: Fn(&PanicInfo) + 'static + Sync + Send { - set_hook(Box::new(handler)) -} - -/// -#[rustc_deprecated(since = "1.9.0", reason = "renamed to take_hook")] -#[unstable(feature = "panic_handler", reason = "awaiting feedback", issue = "30449")] -pub fn take_handler() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { - take_hook() -} - -/// A marker trait which represents "unwind safe" types in Rust. +/// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in /// terms of inference of implementation to the `Send` and `Sync` traits. The @@ -117,14 +103,6 @@ pub fn take_handler() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { across an unwind boundary"] pub trait UnwindSafe {} -/// Deprecated, renamed to UnwindSafe -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `UnwindSafe`", since = "1.9.0")] -pub trait RecoverSafe {} -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[allow(deprecated)] -impl<T: UnwindSafe> RecoverSafe for T {} - /// A marker trait representing types where a shared reference is considered /// unwind safe. /// @@ -202,11 +180,6 @@ pub struct AssertUnwindSafe<T>( pub T ); -/// Deprecated, renamed to `AssertUnwindSafe` -#[unstable(feature = "recover", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `AssertUnwindSafe`", since = "1.9.0")] -pub struct AssertRecoverSafe<T>(pub T); - // Implementations of the `UnwindSafe` trait: // // * By default everything is unwind safe @@ -234,9 +207,6 @@ impl<T: ?Sized> UnwindSafe for Mutex<T> {} impl<T: ?Sized> UnwindSafe for RwLock<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> UnwindSafe for AssertUnwindSafe<T> {} -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> UnwindSafe for AssertRecoverSafe<T> {} // not covered via the Shared impl above b/c the inner contents use // Cell/AtomicUsize, but the usage here is unwind safe so we can lift the @@ -256,9 +226,6 @@ impl RefUnwindSafe for .. {} impl<T: ?Sized> !RefUnwindSafe for UnsafeCell<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> RefUnwindSafe for AssertUnwindSafe<T> {} -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> RefUnwindSafe for AssertRecoverSafe<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T> Deref for AssertUnwindSafe<T> { @@ -285,53 +252,6 @@ impl<R, F: FnOnce() -> R> FnOnce<()> for AssertUnwindSafe<F> { } } -#[allow(deprecated)] -impl<T> AssertRecoverSafe<T> { - /// Creates a new `AssertRecoverSafe` wrapper around the provided type. - #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, construct it directly", - since = "1.9.0")] - pub fn new(t: T) -> AssertRecoverSafe<T> { - AssertRecoverSafe(t) - } - - /// Consumes the `AssertRecoverSafe`, returning the wrapped value. - #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, access it directly", - since = "1.9.0")] - pub fn into_inner(self) -> T { - self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> Deref for AssertRecoverSafe<T> { - type Target = T; - - fn deref(&self) -> &T { - &self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<T> DerefMut for AssertRecoverSafe<T> { - fn deref_mut(&mut self) -> &mut T { - &mut self.0 - } -} - -#[unstable(feature = "recover", issue = "27719")] -#[allow(deprecated)] -impl<R, F: FnOnce() -> R> FnOnce<()> for AssertRecoverSafe<F> { - type Output = R; - - extern "rust-call" fn call_once(self, _args: ()) -> R { - (self.0)() - } -} - /// Invokes a closure, capturing the cause of an unwinding panic if one occurs. /// /// This function will return `Ok` with the closure's result if the closure @@ -388,13 +308,6 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { } } -/// Deprecated, renamed to `catch_unwind` -#[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -#[rustc_deprecated(reason = "renamed to `catch_unwind`", since = "1.9.0")] -pub fn recover<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { - catch_unwind(f) -} - /// Triggers a panic without invoking the panic hook. /// /// This is designed to be used in conjunction with `catch_unwind` to, for @@ -424,10 +337,3 @@ pub fn recover<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { pub fn resume_unwind(payload: Box<Any + Send>) -> ! { panicking::rust_panic(payload) } - -/// Deprecated, use resume_unwind instead -#[unstable(feature = "panic_propagate", reason = "awaiting feedback", issue = "30752")] -#[rustc_deprecated(reason = "renamed to `resume_unwind`", since = "1.9.0")] -pub fn propagate(payload: Box<Any + Send>) -> ! { - resume_unwind(payload) -} diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index e1e764bd255..03d3483902d 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -468,42 +468,6 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { } }) } - - /// Transform this guard to hold a sub-borrow of the original data. - /// - /// Applies the supplied closure to the data, returning a new lock - /// guard referencing the borrow returned by the closure. - /// - /// # Examples - /// - /// ```rust - /// # #![feature(guard_map)] - /// # use std::sync::{RwLockReadGuard, RwLock}; - /// let x = RwLock::new(vec![1, 2]); - /// - /// let y = RwLockReadGuard::map(x.read().unwrap(), |v| &v[0]); - /// assert_eq!(*y, 1); - /// ``` - #[unstable(feature = "guard_map", - reason = "recently added, needs RFC for stabilization, - questionable interaction with Condvar", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", - reason = "unsound on Mutex because of Condvar and \ - RwLock may also with to be used with Condvar \ - one day")] - pub fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockReadGuard<'rwlock, U> - where F: FnOnce(&T) -> &U - { - let new = RwLockReadGuard { - __lock: this.__lock, - __data: cb(this.__data) - }; - - mem::forget(this); - - new - } } #[allow(deprecated)] @@ -518,57 +482,6 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { } }) } - - /// Transform this guard to hold a sub-borrow of the original data. - /// - /// Applies the supplied closure to the data, returning a new lock - /// guard referencing the borrow returned by the closure. - /// - /// # Examples - /// - /// ```rust - /// # #![feature(guard_map)] - /// # use std::sync::{RwLockWriteGuard, RwLock}; - /// let x = RwLock::new(vec![1, 2]); - /// - /// { - /// let mut y = RwLockWriteGuard::map(x.write().unwrap(), |v| &mut v[0]); - /// assert_eq!(*y, 1); - /// - /// *y = 10; - /// } - /// - /// assert_eq!(&**x.read().unwrap(), &[10, 2]); - /// ``` - #[unstable(feature = "guard_map", - reason = "recently added, needs RFC for stabilization, - questionable interaction with Condvar", - issue = "27746")] - #[rustc_deprecated(since = "1.8.0", - reason = "unsound on Mutex because of Condvar and \ - RwLock may also with to be used with Condvar \ - one day")] - pub fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockWriteGuard<'rwlock, U> - where F: FnOnce(&mut T) -> &mut U - { - // Compute the new data while still owning the original lock - // in order to correctly poison if the callback panics. - let data = unsafe { ptr::read(&this.__data) }; - let new_data = cb(data); - - // We don't want to unlock the lock by running the destructor of the - // original lock, so just read the fields we need and forget it. - let (poison, lock) = unsafe { - (ptr::read(&this.__poison), ptr::read(&this.__lock)) - }; - mem::forget(this); - - RwLockWriteGuard { - __lock: lock, - __data: new_data, - __poison: poison - } - } } #[stable(feature = "rust1", since = "1.0.0")] @@ -619,7 +532,7 @@ mod tests { use rand::{self, Rng}; use sync::mpsc::channel; use thread; - use sync::{Arc, RwLock, StaticRwLock, TryLockError, RwLockWriteGuard}; + use sync::{Arc, RwLock, StaticRwLock, TryLockError}; use sync::atomic::{AtomicUsize, Ordering}; #[derive(Eq, PartialEq, Debug)] @@ -867,20 +780,4 @@ mod tests { Ok(x) => panic!("get_mut of poisoned RwLock is Ok: {:?}", x), } } - - #[test] - fn test_rwlock_write_map_poison() { - let rwlock = Arc::new(RwLock::new(vec![1, 2])); - let rwlock2 = rwlock.clone(); - - thread::spawn(move || { - let _ = RwLockWriteGuard::map::<usize, _>(rwlock2.write().unwrap(), |_| panic!()); - }).join().unwrap_err(); - - match rwlock.read() { - Ok(r) => panic!("Read lock on poisioned RwLock is Ok: {:?}", &*r), - Err(_) => {} - }; - } } - diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index b0fed2f4694..430ec5f94a6 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -34,21 +34,6 @@ pub trait CommandExt { #[stable(feature = "rust1", since = "1.0.0")] fn gid(&mut self, id: u32) -> &mut process::Command; - /// Create a new session (cf. `setsid(2)`) for the child process. This means - /// that the child is the leader of a new process group. The parent process - /// remains the child reaper of the new process. - /// - /// This is not enough to create a daemon process. The *init* process should - /// be the child reaper of a daemon. This can be achieved if the parent - /// process exit. Moreover, a daemon should not have a controlling terminal. - /// To achieve this, a session leader (the child) must spawn another process - /// (the daemon) in the same session. - #[unstable(feature = "process_session_leader", reason = "recently added", - issue = "27811")] - #[rustc_deprecated(reason = "use `before_exec` instead", - since = "1.9.0")] - fn session_leader(&mut self, on: bool) -> &mut process::Command; - /// Schedules a closure to be run just before the `exec` function is /// invoked. /// @@ -112,11 +97,6 @@ impl CommandExt for process::Command { self } - fn session_leader(&mut self, on: bool) -> &mut process::Command { - self.as_inner_mut().session_leader(on); - self - } - fn before_exec<F>(&mut self, f: F) -> &mut process::Command where F: FnMut() -> io::Result<()> + Send + Sync + 'static { diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index d5719167542..98cfdcdf110 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -55,7 +55,6 @@ pub struct Command { cwd: Option<CString>, uid: Option<uid_t>, gid: Option<gid_t>, - session_leader: bool, saw_nul: bool, closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>, stdin: Option<Stdio>, @@ -105,7 +104,6 @@ impl Command { cwd: None, uid: None, gid: None, - session_leader: false, saw_nul: saw_nul, closures: Vec::new(), stdin: None, @@ -197,9 +195,6 @@ impl Command { pub fn gid(&mut self, id: gid_t) { self.gid = Some(id); } - pub fn session_leader(&mut self, session_leader: bool) { - self.session_leader = session_leader; - } pub fn before_exec(&mut self, f: Box<FnMut() -> io::Result<()> + Send + Sync>) { @@ -367,12 +362,6 @@ impl Command { t!(cvt(libc::setuid(u as uid_t))); } - if self.session_leader { - // Don't check the error of setsid because it fails if we're the - // process leader already. We just forked so it shouldn't return - // error, but ignore it anyway. - let _ = libc::setsid(); - } if let Some(ref cwd) = self.cwd { t!(cvt(libc::chdir(cwd.as_ptr()))); } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index dc26370590c..c8783a60c41 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -183,25 +183,15 @@ use time::Duration; //////////////////////////////////////////////////////////////////////////////// #[macro_use] mod local; -#[macro_use] mod scoped_tls; #[stable(feature = "rust1", since = "1.0.0")] pub use self::local::{LocalKey, LocalKeyState}; -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully \ - consider stabilizing its interface", - issue = "27715")] -#[allow(deprecated)] -pub use self::scoped_tls::ScopedKey; - #[unstable(feature = "libstd_thread_internals", issue = "0")] #[cfg(target_thread_local)] #[doc(hidden)] pub use self::local::elf::Key as __ElfLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "0")] #[doc(hidden)] pub use self::local::os::Key as __OsLocalKeyInner; -#[unstable(feature = "libstd_thread_internals", issue = "0")] -#[doc(hidden)] pub use self::scoped_tls::__KeyInner as __ScopedKeyInner; //////////////////////////////////////////////////////////////////////////////// // Builder diff --git a/src/libstd/thread/scoped_tls.rs b/src/libstd/thread/scoped_tls.rs deleted file mode 100644 index dea58d016e4..00000000000 --- a/src/libstd/thread/scoped_tls.rs +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Scoped thread-local storage -//! -//! This module provides the ability to generate *scoped* thread-local -//! variables. In this sense, scoped indicates that thread local storage -//! actually stores a reference to a value, and this reference is only placed -//! in storage for a scoped amount of time. -//! -//! There are no restrictions on what types can be placed into a scoped -//! variable, but all scoped variables are initialized to the equivalent of -//! null. Scoped thread local storage is useful when a value is present for a known -//! period of time and it is not required to relinquish ownership of the -//! contents. -//! -//! # Examples -//! -//! ``` -//! #![feature(scoped_tls)] -//! -//! scoped_thread_local!(static FOO: u32); -//! -//! // Initially each scoped slot is empty. -//! assert!(!FOO.is_set()); -//! -//! // When inserting a value, the value is only in place for the duration -//! // of the closure specified. -//! FOO.set(&1, || { -//! FOO.with(|slot| { -//! assert_eq!(*slot, 1); -//! }); -//! }); -//! ``` - -#![unstable(feature = "thread_local_internals", issue = "0")] -#![allow(deprecated)] - -#[doc(hidden)] -pub use self::imp::KeyInner as __KeyInner; - -/// Type representing a thread local storage key corresponding to a reference -/// to the type parameter `T`. -/// -/// Keys are statically allocated and can contain a reference to an instance of -/// type `T` scoped to a particular lifetime. Keys provides two methods, `set` -/// and `with`, both of which currently use closures to control the scope of -/// their contents. -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully consider \ - stabilizing its interface", - issue = "27715")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -pub struct ScopedKey<T:'static> { inner: fn() -> &'static imp::KeyInner<T> } - -/// Declare a new scoped thread local storage key. -/// -/// This macro declares a `static` item on which methods are used to get and -/// set the value stored within. -/// -/// See [ScopedKey documentation](thread/struct.ScopedKey.html) for more -/// information. -#[unstable(feature = "thread_local_internals", - reason = "should not be necessary", - issue = "0")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -#[macro_export] -#[allow_internal_unstable] -macro_rules! scoped_thread_local { - (static $name:ident: $t:ty) => ( - static $name: $crate::thread::ScopedKey<$t> = - __scoped_thread_local_inner!($t); - ); - (pub static $name:ident: $t:ty) => ( - pub static $name: $crate::thread::ScopedKey<$t> = - __scoped_thread_local_inner!($t); - ); -} - -#[doc(hidden)] -#[unstable(feature = "thread_local_internals", - reason = "should not be necessary", - issue = "0")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -#[macro_export] -#[allow_internal_unstable] -macro_rules! __scoped_thread_local_inner { - ($t:ty) => {{ - #[cfg_attr(target_thread_local, thread_local)] - static _KEY: $crate::thread::__ScopedKeyInner<$t> = - $crate::thread::__ScopedKeyInner::new(); - fn _getit() -> &'static $crate::thread::__ScopedKeyInner<$t> { &_KEY } - $crate::thread::ScopedKey::new(_getit) - }} -} - -#[unstable(feature = "scoped_tls", - reason = "scoped TLS has yet to have wide enough use to fully consider \ - stabilizing its interface", - issue = "27715")] -#[rustc_deprecated(since = "1.8.0", - reason = "hasn't proven itself over LocalKey")] -impl<T> ScopedKey<T> { - #[doc(hidden)] - pub const fn new(inner: fn() -> &'static imp::KeyInner<T>) -> ScopedKey<T> { - ScopedKey { inner: inner } - } - - /// Inserts a value into this scoped thread local storage slot for a - /// duration of a closure. - /// - /// While `cb` is running, the value `t` will be returned by `get` unless - /// this function is called recursively inside of `cb`. - /// - /// Upon return, this function will restore the previous value, if any - /// was available. - /// - /// # Examples - /// - /// ``` - /// #![feature(scoped_tls)] - /// - /// scoped_thread_local!(static FOO: u32); - /// - /// FOO.set(&100, || { - /// let val = FOO.with(|v| *v); - /// assert_eq!(val, 100); - /// - /// // set can be called recursively - /// FOO.set(&101, || { - /// // ... - /// }); - /// - /// // Recursive calls restore the previous value. - /// let val = FOO.with(|v| *v); - /// assert_eq!(val, 100); - /// }); - /// ``` - pub fn set<R, F>(&'static self, t: &T, cb: F) -> R where - F: FnOnce() -> R, - { - struct Reset<'a, T: 'a> { - key: &'a imp::KeyInner<T>, - val: *mut T, - } - impl<'a, T> Drop for Reset<'a, T> { - fn drop(&mut self) { - unsafe { self.key.set(self.val) } - } - } - - let inner = (self.inner)(); - let prev = unsafe { - let prev = inner.get(); - inner.set(t as *const T as *mut T); - prev - }; - - let _reset = Reset { key: inner, val: prev }; - cb() - } - - /// Gets a value out of this scoped variable. - /// - /// This function takes a closure which receives the value of this - /// variable. - /// - /// # Panics - /// - /// This function will panic if `set` has not previously been called. - /// - /// # Examples - /// - /// ```no_run - /// #![feature(scoped_tls)] - /// - /// scoped_thread_local!(static FOO: u32); - /// - /// FOO.with(|slot| { - /// // work with `slot` - /// }); - /// ``` - pub fn with<R, F>(&'static self, cb: F) -> R where - F: FnOnce(&T) -> R - { - unsafe { - let ptr = (self.inner)().get(); - assert!(!ptr.is_null(), "cannot access a scoped thread local \ - variable without calling `set` first"); - cb(&*ptr) - } - } - - /// Test whether this TLS key has been `set` for the current thread. - pub fn is_set(&'static self) -> bool { - unsafe { !(self.inner)().get().is_null() } - } -} - -#[cfg(target_thread_local)] -#[doc(hidden)] -mod imp { - use cell::Cell; - use ptr; - - pub struct KeyInner<T> { inner: Cell<*mut T> } - - unsafe impl<T> ::marker::Sync for KeyInner<T> { } - - impl<T> KeyInner<T> { - pub const fn new() -> KeyInner<T> { - KeyInner { inner: Cell::new(ptr::null_mut()) } - } - pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr); } - pub unsafe fn get(&self) -> *mut T { self.inner.get() } - } -} - -#[cfg(not(target_thread_local))] -#[doc(hidden)] -mod imp { - use cell::Cell; - use marker; - use sys_common::thread_local::StaticKey as OsStaticKey; - - pub struct KeyInner<T> { - pub inner: OsStaticKey, - pub marker: marker::PhantomData<Cell<T>>, - } - - unsafe impl<T> marker::Sync for KeyInner<T> { } - - impl<T> KeyInner<T> { - pub const fn new() -> KeyInner<T> { - KeyInner { - inner: OsStaticKey::new(None), - marker: marker::PhantomData - } - } - pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr as *mut _) } - pub unsafe fn get(&self) -> *mut T { self.inner.get() as *mut _ } - } -} - - -#[cfg(test)] -mod tests { - use cell::Cell; - - scoped_thread_local!(static FOO: u32); - - #[test] - fn smoke() { - scoped_thread_local!(static BAR: u32); - - assert!(!BAR.is_set()); - BAR.set(&1, || { - assert!(BAR.is_set()); - BAR.with(|slot| { - assert_eq!(*slot, 1); - }); - }); - assert!(!BAR.is_set()); - } - - #[test] - fn cell_allowed() { - scoped_thread_local!(static BAR: Cell<u32>); - - BAR.set(&Cell::new(1), || { - BAR.with(|slot| { - assert_eq!(slot.get(), 1); - }); - }); - } - - #[test] - fn scope_item_allowed() { - assert!(!FOO.is_set()); - FOO.set(&1, || { - assert!(FOO.is_set()); - FOO.with(|slot| { - assert_eq!(*slot, 1); - }); - }); - assert!(!FOO.is_set()); - } -} diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index 80963a9b735..0e1508a1c4c 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -143,13 +143,6 @@ impl Instant { self.0.sub_instant(&earlier.0) } - /// Deprecated, renamed to `duration_since` - #[unstable(feature = "time2_old", issue = "29866")] - #[rustc_deprecated(since = "1.8.0", reason = "renamed to duration_since")] - pub fn duration_from_earlier(&self, earlier: Instant) -> Duration { - self.0.sub_instant(&earlier.0) - } - /// Returns the amount of time elapsed since this instant was created. /// /// # Panics @@ -235,14 +228,6 @@ impl SystemTime { self.0.sub_time(&earlier.0).map_err(SystemTimeError) } - /// Deprecated, renamed to `duration_since` - #[unstable(feature = "time2_old", issue = "29866")] - #[rustc_deprecated(since = "1.8.0", reason = "renamed to duration_since")] - pub fn duration_from_earlier(&self, earlier: SystemTime) - -> Result<Duration, SystemTimeError> { - self.0.sub_time(&earlier.0).map_err(SystemTimeError) - } - /// Returns the amount of time elapsed since this system time was created. /// /// This function may fail as the underlying system clock is susceptible to |
