]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/thread_local/mod.rs
rollup merge of #21438: taralx/kill-racycell
[rust.git] / src / libstd / thread_local / mod.rs
index e0cbaa8ca50edbbb99c63a147445d1951f8551a7..4c99cff34da65cba8ace81c1f800c29ff9f732da 100644 (file)
@@ -40,8 +40,7 @@
 
 use cell::UnsafeCell;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod scoped;
 
 // Sure wish we had macro hygiene, no?
@@ -87,7 +86,7 @@ pub mod __impl {
 ///         assert_eq!(*f.borrow(), 1);
 ///         *f.borrow_mut() = 3;
 ///     });
-/// }).detach();
+/// });
 ///
 /// // we retain our original value of 2 despite the child thread
 /// FOO.with(|f| {
@@ -346,7 +345,7 @@ pub struct Key<T> {
         pub dtor_running: UnsafeCell<bool>, // should be Cell
     }
 
-    unsafe impl<T> ::kinds::Sync for Key<T> { }
+    unsafe impl<T> ::marker::Sync for Key<T> { }
 
     #[doc(hidden)]
     impl<T> Key<T> {
@@ -450,7 +449,7 @@ fn _tlv_atexit(dtor: unsafe extern fn(*mut u8),
         // destructor as running for this thread so calls to `get` will return
         // `None`.
         *(*ptr).dtor_running.get() = true;
-        ptr::read((*ptr).inner.get() as *const T);
+        ptr::read((*ptr).inner.get());
     }
 }
 
@@ -472,7 +471,7 @@ pub struct Key<T> {
         pub os: OsStaticKey,
     }
 
-    unsafe impl<T> ::kinds::Sync for Key<T> { }
+    unsafe impl<T> ::marker::Sync for Key<T> { }
 
     struct Value<T: 'static> {
         key: &'static Key<T>,
@@ -581,7 +580,7 @@ fn foo() -> Foo {
         }
         thread_local!(static FOO: Foo = foo());
 
-        Thread::spawn(|| {
+        Thread::scoped(|| {
             assert!(FOO.state() == State::Uninitialized);
             FOO.with(|_| {
                 assert!(FOO.state() == State::Valid);
@@ -645,7 +644,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             drop(S1);
         }).join().ok().unwrap();
     }
@@ -663,7 +662,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::spawn(move|| unsafe {
+        Thread::scoped(move|| unsafe {
             K1.with(|s| *s.get() = Some(S1));
         }).join().ok().unwrap();
     }