diff options
| author | Mica White <botahamec@outlook.com> | 2024-03-11 22:41:13 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2024-03-11 22:41:13 -0400 |
| commit | a22ffadbebddcbec9bb127b295f8a8516174e6e6 (patch) | |
| tree | 66925b072f43646aafb40834e293c11b98f08c87 /src/mutex | |
| parent | ef34f899313ed4e4c5e452aef2c670f7d51f1ca9 (diff) | |
More trait bound fixes
Diffstat (limited to 'src/mutex')
| -rw-r--r-- | src/mutex/guard.rs | 6 | ||||
| -rw-r--r-- | src/mutex/mutex.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs index f57926d..69960cf 100644 --- a/src/mutex/guard.rs +++ b/src/mutex/guard.rs @@ -57,13 +57,13 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> MutexGuard<'a, 'ke /// Create a guard to the given mutex. Undefined if multiple guards to the /// same mutex exist at once. #[must_use] - pub(super) const unsafe fn new(mutex: &'a Mutex<T, R>, thread_key: Key) -> Self { + pub(super) unsafe fn new(mutex: &'a Mutex<T, R>, thread_key: Key) -> Self { Self { - mutex: MutexRef(mutex), + mutex: MutexRef(mutex, PhantomData), thread_key, _phantom2: PhantomData, } } } -unsafe impl<'a, T: ?Sized + Send + 'a, R: RawMutex + Sync + 'a> Sync for MutexRef<'a, T, R> {} +unsafe impl<'a, T: ?Sized + Sync + 'a, R: RawMutex + Sync + 'a> Sync for MutexRef<'a, T, R> {} diff --git a/src/mutex/mutex.rs b/src/mutex/mutex.rs index 1976e57..917ab78 100644 --- a/src/mutex/mutex.rs +++ b/src/mutex/mutex.rs @@ -1,5 +1,5 @@ -use std::cell::UnsafeCell; use std::fmt::Debug; +use std::{cell::UnsafeCell, marker::PhantomData}; use lock_api::RawMutex; @@ -144,7 +144,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> { pub(crate) unsafe fn lock_no_key(&self) -> MutexRef<'_, T, R> { self.raw.lock(); - MutexRef(self) + MutexRef(self, PhantomData) } /// Attempts to lock the `Mutex` without blocking. @@ -190,7 +190,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> { /// Lock without a [`ThreadKey`]. It is undefined behavior to do this without /// owning the [`ThreadKey`]. pub(crate) unsafe fn try_lock_no_key(&self) -> Option<MutexRef<'_, T, R>> { - self.raw.try_lock().then_some(MutexRef(self)) + self.raw.try_lock().then_some(MutexRef(self, PhantomData)) } /// Forcibly unlocks the `Lock`. |
