about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorStjepan Glavina <stjepang@gmail.com>2018-02-27 17:00:01 +0100
committerStjepan Glavina <stjepang@gmail.com>2018-02-28 12:41:36 +0100
commitc99f4c4c5b9f968b82037cf643b6662b140d9b1f (patch)
tree56e38b4172ad4e4899f0a29aff53e40165d23935 /src/libstd/thread
parent29f5c699b11a6a148f097f82eaa05202f8799bbc (diff)
downloadrust-c99f4c4c5b9f968b82037cf643b6662b140d9b1f.tar.gz
rust-c99f4c4c5b9f968b82037cf643b6662b140d9b1f.zip
Stabilize LocalKey::try_with
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/local.rs28
-rw-r--r--src/libstd/thread/mod.rs5
2 files changed, 19 insertions, 14 deletions
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index fcbca38a98f..b6dbcf8914c 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -199,6 +199,7 @@ macro_rules! __thread_local_inner {
 #[unstable(feature = "thread_local_state",
            reason = "state querying was recently added",
            issue = "27716")]
+#[rustc_deprecated(since = "1.26.0", reason = "use `LocalKey::try_with` instead")]
 #[derive(Debug, Eq, PartialEq, Copy, Clone)]
 pub enum LocalKeyState {
     /// All keys are in this state whenever a thread starts. Keys will
@@ -234,25 +235,19 @@ pub enum LocalKeyState {
 }
 
 /// An error returned by [`LocalKey::try_with`](struct.LocalKey.html#method.try_with).
-#[unstable(feature = "thread_local_state",
-           reason = "state querying was recently added",
-           issue = "27716")]
+#[stable(feature = "thread_local_try_with", since = "1.26.0")]
 pub struct AccessError {
     _private: (),
 }
 
-#[unstable(feature = "thread_local_state",
-           reason = "state querying was recently added",
-           issue = "27716")]
+#[stable(feature = "thread_local_try_with", since = "1.26.0")]
 impl fmt::Debug for AccessError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.debug_struct("AccessError").finish()
     }
 }
 
-#[unstable(feature = "thread_local_state",
-           reason = "state querying was recently added",
-           issue = "27716")]
+#[stable(feature = "thread_local_try_with", since = "1.26.0")]
 impl fmt::Display for AccessError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt("already destroyed", f)
@@ -341,6 +336,8 @@ impl<T: 'static> LocalKey<T> {
     #[unstable(feature = "thread_local_state",
                reason = "state querying was recently added",
                issue = "27716")]
+    #[rustc_deprecated(since = "1.26.0", reason = "use `LocalKey::try_with` instead")]
+    #[allow(deprecated)]
     pub fn state(&'static self) -> LocalKeyState {
         unsafe {
             match (self.inner)() {
@@ -365,11 +362,11 @@ impl<T: 'static> LocalKey<T> {
     ///
     /// This function will still `panic!()` if the key is uninitialized and the
     /// key's initializer panics.
-    #[unstable(feature = "thread_local_state",
-               reason = "state querying was recently added",
-               issue = "27716")]
+    #[stable(feature = "thread_local_try_with", since = "1.26.0")]
     pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError>
-                      where F: FnOnce(&T) -> R {
+    where
+        F: FnOnce(&T) -> R,
+    {
         unsafe {
             let slot = (self.inner)().ok_or(AccessError {
                 _private: (),
@@ -530,6 +527,7 @@ pub mod os {
 mod tests {
     use sync::mpsc::{channel, Sender};
     use cell::{Cell, UnsafeCell};
+    #[allow(deprecated)]
     use super::LocalKeyState;
     use thread;
 
@@ -565,6 +563,7 @@ mod tests {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn states() {
         struct Foo;
         impl Drop for Foo {
@@ -602,6 +601,7 @@ mod tests {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn circular() {
         struct S1;
         struct S2;
@@ -642,6 +642,7 @@ mod tests {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn self_referential() {
         struct S1;
         thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
@@ -663,6 +664,7 @@ mod tests {
     // test on macOS.
     #[test]
     #[cfg_attr(target_os = "macos", ignore)]
+    #[allow(deprecated)]
     fn dtors_in_dtors_in_dtors() {
         struct S1(Sender<()>);
         thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index ff121e2d7ee..01898679bdc 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -191,7 +191,10 @@ use time::Duration;
 #[macro_use] mod local;
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use self::local::{LocalKey, LocalKeyState, AccessError};
+pub use self::local::{LocalKey, AccessError};
+#[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated)]
+pub use self::local::LocalKeyState;
 
 // The types used by the thread_local! macro to access TLS keys. Note that there
 // are two types, the "OS" type and the "fast" type. The OS thread local key