about summary refs log tree commit diff
path: root/src/libstd/sys_common
diff options
context:
space:
mode:
authorLee Bousfield <ljbousfield@gmail.com>2017-07-10 20:18:36 -0400
committerLee Bousfield <ljbousfield@gmail.com>2017-07-10 20:18:36 -0400
commita45c8b09e86ea4eed283a6163b44c493d15ee5c3 (patch)
tree22a055157f249feb88774d567f1901fd7d09068c /src/libstd/sys_common
parent32ae12b3d1062babf4f052db42c649e30b11673a (diff)
downloadrust-a45c8b09e86ea4eed283a6163b44c493d15ee5c3.tar.gz
rust-a45c8b09e86ea4eed283a6163b44c493d15ee5c3.zip
Use LocalKey::try_with in std
Diffstat (limited to 'src/libstd/sys_common')
-rw-r--r--src/libstd/sys_common/thread_info.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs
index 5ed48ee4558..2abb8afa828 100644
--- a/src/libstd/sys_common/thread_info.rs
+++ b/src/libstd/sys_common/thread_info.rs
@@ -12,7 +12,6 @@
 
 use cell::RefCell;
 use thread::Thread;
-use thread::LocalKeyState;
 
 struct ThreadInfo {
     stack_guard: Option<usize>,
@@ -23,19 +22,15 @@ thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(N
 
 impl ThreadInfo {
     fn with<R, F>(f: F) -> Option<R> where F: FnOnce(&mut ThreadInfo) -> R {
-        if THREAD_INFO.state() == LocalKeyState::Destroyed {
-            return None
-        }
-
-        THREAD_INFO.with(move |c| {
+        THREAD_INFO.try_with(move |c| {
             if c.borrow().is_none() {
                 *c.borrow_mut() = Some(ThreadInfo {
                     stack_guard: None,
                     thread: Thread::new(None),
                 })
             }
-            Some(f(c.borrow_mut().as_mut().unwrap()))
-        })
+            f(c.borrow_mut().as_mut().unwrap())
+        }).ok()
     }
 }