about summary refs log tree commit diff
path: root/library/std/src/sys/hermit
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2022-06-03 16:45:47 +0200
committerMara Bos <m-ou.se@m-ou.se>2022-06-03 16:45:47 +0200
commitac5aa1ded529cd8317b351ba952ff9cd78b1e172 (patch)
tree209ea71e0de957f31459e3a1d97c0ef2f074d1bb /library/std/src/sys/hermit
parentfb1976011e3df96b5d3eccd6b2f4e51ef7dc8f16 (diff)
downloadrust-ac5aa1ded529cd8317b351ba952ff9cd78b1e172.tar.gz
rust-ac5aa1ded529cd8317b351ba952ff9cd78b1e172.zip
Use Drop instead of destroy() for locks.
Diffstat (limited to 'library/std/src/sys/hermit')
-rw-r--r--library/std/src/sys/hermit/condvar.rs10
-rw-r--r--library/std/src/sys/hermit/mutex.rs3
-rw-r--r--library/std/src/sys/hermit/rwlock.rs6
3 files changed, 7 insertions, 12 deletions
diff --git a/library/std/src/sys/hermit/condvar.rs b/library/std/src/sys/hermit/condvar.rs
index f6083530005..46f45b19771 100644
--- a/library/std/src/sys/hermit/condvar.rs
+++ b/library/std/src/sys/hermit/condvar.rs
@@ -70,9 +70,13 @@ impl Condvar {
         mutex.lock();
         res == 0
     }
+}
 
-    pub unsafe fn destroy(&self) {
-        let _ = abi::sem_destroy(self.sem1);
-        let _ = abi::sem_destroy(self.sem2);
+impl Drop for Condvar {
+    fn drop(&mut self) {
+        unsafe {
+            let _ = abi::sem_destroy(self.sem1);
+            let _ = abi::sem_destroy(self.sem2);
+        }
     }
 }
diff --git a/library/std/src/sys/hermit/mutex.rs b/library/std/src/sys/hermit/mutex.rs
index 97b4c49896f..ef44bf411fb 100644
--- a/library/std/src/sys/hermit/mutex.rs
+++ b/library/std/src/sys/hermit/mutex.rs
@@ -215,7 +215,4 @@ impl Mutex {
         }
         guard.locked
     }
-
-    #[inline]
-    pub unsafe fn destroy(&self) {}
 }
diff --git a/library/std/src/sys/hermit/rwlock.rs b/library/std/src/sys/hermit/rwlock.rs
index 690bb155e1a..d43fa08a171 100644
--- a/library/std/src/sys/hermit/rwlock.rs
+++ b/library/std/src/sys/hermit/rwlock.rs
@@ -84,12 +84,6 @@ impl RwLock {
         // FIXME: should only wake up one of these some of the time
         self.cond.notify_all();
     }
-
-    #[inline]
-    pub unsafe fn destroy(&self) {
-        self.lock.destroy();
-        self.cond.destroy();
-    }
 }
 
 impl State {