]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #20262: arturoc/fix-scoped_thread_local
authorAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:25 +0000 (16:36 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:25 +0000 (16:36 -0800)
was missing a couple of semicolons and applications using it failed to compile

src/libstd/thread_local/scoped.rs

index 756c86c211547efaebea7df4e9e55adc557aa867..5f96548c0530ac63badbeef3a827a5ddbc702b07 100644 (file)
@@ -62,10 +62,10 @@ pub struct Key<T> { #[doc(hidden)] pub inner: KeyInner<T> }
 #[macro_export]
 macro_rules! scoped_thread_local {
     (static $name:ident: $t:ty) => (
-        __scoped_thread_local_inner!(static $name: $t)
+        __scoped_thread_local_inner!(static $name: $t);
     );
     (pub static $name:ident: $t:ty) => (
-        __scoped_thread_local_inner!(pub static $name: $t)
+        __scoped_thread_local_inner!(pub static $name: $t);
     );
 }
 
@@ -240,6 +240,8 @@ mod tests {
     use cell::Cell;
     use prelude::*;
 
+    scoped_thread_local!(static FOO: uint);
+
     #[test]
     fn smoke() {
         scoped_thread_local!(static BAR: uint);
@@ -264,4 +266,16 @@ fn cell_allowed() {
             });
         });
     }
+
+    #[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());
+    }
 }