about summary refs log tree commit diff
path: root/library/std/src/sync
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sync')
-rw-r--r--library/std/src/sync/mpmc/mod.rs9
-rw-r--r--library/std/src/sync/mpmc/tests.rs14
-rw-r--r--library/std/src/sync/mpmc/waker.rs2
-rw-r--r--library/std/src/sync/once_lock.rs2
-rw-r--r--library/std/src/sync/poison/once.rs4
5 files changed, 24 insertions, 7 deletions
diff --git a/library/std/src/sync/mpmc/mod.rs b/library/std/src/sync/mpmc/mod.rs
index 00966ee3ecf..8712332dd27 100644
--- a/library/std/src/sync/mpmc/mod.rs
+++ b/library/std/src/sync/mpmc/mod.rs
@@ -616,9 +616,9 @@ impl<T> Sender<T> {
     #[unstable(feature = "mpmc_channel", issue = "126840")]
     pub fn same_channel(&self, other: &Sender<T>) -> bool {
         match (&self.flavor, &other.flavor) {
-            (SenderFlavor::Array(ref a), SenderFlavor::Array(ref b)) => a == b,
-            (SenderFlavor::List(ref a), SenderFlavor::List(ref b)) => a == b,
-            (SenderFlavor::Zero(ref a), SenderFlavor::Zero(ref b)) => a == b,
+            (SenderFlavor::Array(a), SenderFlavor::Array(b)) => a == b,
+            (SenderFlavor::List(a), SenderFlavor::List(b)) => a == b,
+            (SenderFlavor::Zero(a), SenderFlavor::Zero(b)) => a == b,
             _ => false,
         }
     }
@@ -1382,3 +1382,6 @@ impl<T> fmt::Debug for Receiver<T> {
         f.pad("Receiver { .. }")
     }
 }
+
+#[cfg(test)]
+mod tests;
diff --git a/library/std/src/sync/mpmc/tests.rs b/library/std/src/sync/mpmc/tests.rs
new file mode 100644
index 00000000000..6deb4dc2fe0
--- /dev/null
+++ b/library/std/src/sync/mpmc/tests.rs
@@ -0,0 +1,14 @@
+// Ensure that thread_local init with `const { 0 }` still has unique address at run-time
+#[test]
+fn waker_current_thread_id() {
+    let first = super::waker::current_thread_id();
+    let t = crate::thread::spawn(move || {
+        let second = super::waker::current_thread_id();
+        assert_ne!(first, second);
+        assert_eq!(second, super::waker::current_thread_id());
+    });
+
+    assert_eq!(first, super::waker::current_thread_id());
+    t.join().unwrap();
+    assert_eq!(first, super::waker::current_thread_id());
+}
diff --git a/library/std/src/sync/mpmc/waker.rs b/library/std/src/sync/mpmc/waker.rs
index 1895466f95d..f5e764e69bd 100644
--- a/library/std/src/sync/mpmc/waker.rs
+++ b/library/std/src/sync/mpmc/waker.rs
@@ -204,6 +204,6 @@ impl Drop for SyncWaker {
 pub fn current_thread_id() -> usize {
     // `u8` is not drop so this variable will be available during thread destruction,
     // whereas `thread::current()` would not be
-    thread_local! { static DUMMY: u8 = 0 }
+    thread_local! { static DUMMY: u8 = const { 0 } }
     DUMMY.with(|x| (x as *const u8).addr())
 }
diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs
index 21e6b65a744..ffb90b14695 100644
--- a/library/std/src/sync/once_lock.rs
+++ b/library/std/src/sync/once_lock.rs
@@ -191,7 +191,7 @@ impl<T> OnceLock<T> {
     /// })
     /// ```
     #[inline]
-    #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")]
+    #[stable(feature = "once_wait", since = "1.86.0")]
     pub fn wait(&self) -> &T {
         self.once.wait_force();
 
diff --git a/library/std/src/sync/poison/once.rs b/library/std/src/sync/poison/once.rs
index d2938b7a0c1..103e5195407 100644
--- a/library/std/src/sync/poison/once.rs
+++ b/library/std/src/sync/poison/once.rs
@@ -284,7 +284,7 @@ impl Once {
     /// If this [`Once`] has been poisoned because an initialization closure has
     /// panicked, this method will also panic. Use [`wait_force`](Self::wait_force)
     /// if this behavior is not desired.
-    #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")]
+    #[stable(feature = "once_wait", since = "1.86.0")]
     pub fn wait(&self) {
         if !self.inner.is_completed() {
             self.inner.wait(false);
@@ -293,7 +293,7 @@ impl Once {
 
     /// Blocks the current thread until initialization has completed, ignoring
     /// poisoning.
-    #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")]
+    #[stable(feature = "once_wait", since = "1.86.0")]
     pub fn wait_force(&self) {
         if !self.inner.is_completed() {
             self.inner.wait(true);