about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick-6 <pamu99@gmx.ch>2025-05-28 15:12:56 +0200
committerPatrick-6 <pamu99@gmx.ch>2025-05-28 15:12:56 +0200
commit2e99a880e22f5a1f3800e1a26828b188204d037e (patch)
treee4c1cc7ac0238e223b8967399a93de721c0bad74
parent77101febcc9662a076ff43887497cd5b30674d93 (diff)
downloadrust-2e99a880e22f5a1f3800e1a26828b188204d037e.tar.gz
rust-2e99a880e22f5a1f3800e1a26828b188204d037e.zip
Add diagnostic items to sys::Mutex
-rw-r--r--compiler/rustc_span/src/symbol.rs3
-rw-r--r--library/std/src/sys/sync/mutex/futex.rs3
-rw-r--r--library/std/src/sys/sync/mutex/pthread.rs3
3 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 0447713fb05..58091bc32d2 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -2071,6 +2071,9 @@ symbols! {
         sym,
         sync,
         synthetic,
+        sys_mutex_lock,
+        sys_mutex_try_lock,
+        sys_mutex_unlock,
         t32,
         target,
         target_abi,
diff --git a/library/std/src/sys/sync/mutex/futex.rs b/library/std/src/sys/sync/mutex/futex.rs
index ce9b2daa5f8..01e91a6294a 100644
--- a/library/std/src/sys/sync/mutex/futex.rs
+++ b/library/std/src/sys/sync/mutex/futex.rs
@@ -19,11 +19,13 @@ impl Mutex {
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_try_lock")]
     pub fn try_lock(&self) -> bool {
         self.futex.compare_exchange(UNLOCKED, LOCKED, Acquire, Relaxed).is_ok()
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_lock")]
     pub fn lock(&self) {
         if self.futex.compare_exchange(UNLOCKED, LOCKED, Acquire, Relaxed).is_err() {
             self.lock_contended();
@@ -80,6 +82,7 @@ impl Mutex {
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_unlock")]
     pub unsafe fn unlock(&self) {
         if self.futex.swap(UNLOCKED, Release) == CONTENDED {
             // We only wake up one thread. When that thread locks the mutex, it
diff --git a/library/std/src/sys/sync/mutex/pthread.rs b/library/std/src/sys/sync/mutex/pthread.rs
index 75b4b9c6dad..52588a7899a 100644
--- a/library/std/src/sys/sync/mutex/pthread.rs
+++ b/library/std/src/sys/sync/mutex/pthread.rs
@@ -28,6 +28,7 @@ impl Mutex {
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_lock")]
     pub fn lock(&self) {
         // SAFETY: we call `init` above, therefore reentrant locking is safe.
         // In `drop` we ensure that the mutex is not destroyed while locked.
@@ -35,6 +36,7 @@ impl Mutex {
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_unlock")]
     pub unsafe fn unlock(&self) {
         // SAFETY: the mutex can only be locked if it is already initialized
         // and we observed this initialization since we observed the locking.
@@ -42,6 +44,7 @@ impl Mutex {
     }
 
     #[inline]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "sys_mutex_try_lock")]
     pub fn try_lock(&self) -> bool {
         // SAFETY: we call `init` above, therefore reentrant locking is safe.
         // In `drop` we ensure that the mutex is not destroyed while locked.