about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorStjepan Glavina <stjepang@gmail.com>2018-03-01 00:07:27 +0100
committerStjepan Glavina <stjepang@gmail.com>2018-03-01 00:07:27 +0100
commitcb56b2d1522e83c5bb0613abcf78b686e994df9e (patch)
treed7ff08c46d6b2f34897cadf194fc51baf55c9e41 /src/libstd/thread
parent082dd6d7af37ac76d99147ae7242080d4f5c74aa (diff)
downloadrust-cb56b2d1522e83c5bb0613abcf78b686e994df9e.tar.gz
rust-cb56b2d1522e83c5bb0613abcf78b686e994df9e.zip
Fix a bug introduced in previous commit
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/local.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index 25fedcb2772..99479bc56ef 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -272,7 +272,7 @@ impl<T: 'static> LocalKey<T> {
     ///
     /// This will lazily initialize the value if this thread has not referenced
     /// this key yet. If the key has been destroyed (which may happen if this is called
-    /// in a destructor), this function will return a ThreadLocalError.
+    /// in a destructor), this function will return a `ThreadLocalError`.
     ///
     /// # Panics
     ///
@@ -484,11 +484,7 @@ mod tests {
                 assert!(FOO.try_with(|_| ()).is_err());
             }
         }
-        fn foo() -> Foo {
-            assert!(FOO.try_with(|_| ()).is_err());
-            Foo
-        }
-        thread_local!(static FOO: Foo = foo());
+        thread_local!(static FOO: Foo = Foo);
 
         thread::spawn(|| {
             assert!(FOO.try_with(|_| ()).is_ok());
@@ -520,6 +516,7 @@ mod tests {
         impl Drop for S1 {
             fn drop(&mut self) {
                 unsafe {
+                    HITS += 1;
                     if K2.try_with(|_| ()).is_err() {
                         assert_eq!(HITS, 3);
                     } else {