From 2e53b575b3b670e6a8feebb7992210a5138a7417 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 9 Jun 2022 20:05:43 +0000 Subject: [PATCH] Bug 1773399 - Update lock_api to 0.4.7. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D148713 --- Cargo.lock | 5 +- supply-chain/config.toml | 2 +- .../rust/lock_api/.cargo-checksum.json | 2 +- third_party/rust/lock_api/Cargo.toml | 20 ++- third_party/rust/lock_api/build.rs | 7 ++ third_party/rust/lock_api/src/lib.rs | 3 - third_party/rust/lock_api/src/mutex.rs | 21 +++- third_party/rust/lock_api/src/remutex.rs | 43 ++++--- third_party/rust/lock_api/src/rwlock.rs | 117 +++++++++++------- 9 files changed, 139 insertions(+), 81 deletions(-) create mode 100644 third_party/rust/lock_api/build.rs diff --git a/Cargo.lock b/Cargo.lock index c910802b1aef..8c3342b9a273 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3088,10 +3088,11 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ + "autocfg", "scopeguard", ] diff --git a/supply-chain/config.toml b/supply-chain/config.toml index d35043d2e4e0..a87c6a88456b 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -878,7 +878,7 @@ version = "0.11.2" criteria = "safe-to-deploy" [[unaudited.lock_api]] -version = "0.4.5" +version = "0.4.7" criteria = "safe-to-deploy" [[unaudited.log]] diff --git a/third_party/rust/lock_api/.cargo-checksum.json b/third_party/rust/lock_api/.cargo-checksum.json index a54edc0f3aa4..ceb83ada3c5e 100644 --- a/third_party/rust/lock_api/.cargo-checksum.json +++ b/third_party/rust/lock_api/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"480236b01449b56dad945652b3af7f73faea452dca132da3f1c90ba3ca4f984c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","src/lib.rs":"32992cb77fba83d77e979e328953ce3da21b4005d595857f006c8bd65fb6a9ee","src/mutex.rs":"789106fe52c17b706bac5b69ef1cb656d4cef1ce4ef147872d78504dad307705","src/remutex.rs":"03708cd1aa5b982ce278c7b3ef7b97a89253eb92dc96d229ecb1602ff8373b38","src/rwlock.rs":"242db97a58018101dab370f2d0551a4172f15bc5385ecd283bfc37d11891d83b"},"package":"712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"} \ No newline at end of file +{"files":{"Cargo.toml":"f0fb3e65549d1353e2e199977db7825c29721bbeb71dee9bb3905437dd444dce","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"af84139c71d151adead0b4398c394a7dd16087bb2db44b14a0ed970ce868a6c6","src/lib.rs":"7b67c3b69c1b5e97248afe0f6c3bc353c793ed1ce4a5d5177e63f3f05d79c63b","src/mutex.rs":"dc4131ebf73e0474948d1849934ad5156e4a3dbd55f6881e60fd6c0acb6aa861","src/remutex.rs":"659454e66fa72e678e0aa1b83151c81c90321368dc6f4c31315230b969d4936e","src/rwlock.rs":"4f35072ca1fb476089d1548c40af775564bb7e763f86ec41a2190f8c659593cc"},"package":"327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"} \ No newline at end of file diff --git a/third_party/rust/lock_api/Cargo.toml b/third_party/rust/lock_api/Cargo.toml index 4382f3070232..c1ebdb7b72da 100644 --- a/third_party/rust/lock_api/Cargo.toml +++ b/third_party/rust/lock_api/Cargo.toml @@ -12,13 +12,22 @@ [package] edition = "2018" name = "lock_api" -version = "0.4.5" +version = "0.4.7" authors = ["Amanieu d'Antras "] description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std." -keywords = ["mutex", "rwlock", "lock", "no_std"] -categories = ["concurrency", "no-std"] -license = "Apache-2.0/MIT" +keywords = [ + "mutex", + "rwlock", + "lock", + "no_std", +] +categories = [ + "concurrency", + "no-std", +] +license = "MIT OR Apache-2.0" repository = "https://github.com/Amanieu/parking_lot" + [dependencies.owning_ref] version = "0.4.1" optional = true @@ -32,6 +41,9 @@ version = "1.0.126" optional = true default-features = false +[build-dependencies.autocfg] +version = "1.1.0" + [features] arc_lock = [] nightly = [] diff --git a/third_party/rust/lock_api/build.rs b/third_party/rust/lock_api/build.rs new file mode 100644 index 000000000000..886a3454c304 --- /dev/null +++ b/third_party/rust/lock_api/build.rs @@ -0,0 +1,7 @@ +fn main() { + let cfg = autocfg::new(); + + if cfg.probe_rustc_version(1, 61) { + println!("cargo:rustc-cfg=has_const_fn_trait_bound"); + } +} diff --git a/third_party/rust/lock_api/src/lib.rs b/third_party/rust/lock_api/src/lib.rs index c99c68bd4f11..cfa53bce45a4 100644 --- a/third_party/rust/lock_api/src/lib.rs +++ b/third_party/rust/lock_api/src/lib.rs @@ -84,13 +84,10 @@ //! - `owning_ref`: Allows your lock types to be used with the `owning_ref` crate. //! - `arc_lock`: Enables locking from an `Arc`. This enables types such as `ArcMutexGuard`. Note that this //! requires the `alloc` crate to be present. -//! - `nightly`: Enables nightly-only features. At the moment the only such -//! feature is `const fn` constructors for lock types. #![no_std] #![warn(missing_docs)] #![warn(rust_2018_idioms)] -#![cfg_attr(feature = "nightly", feature(const_fn_trait_bound))] #[macro_use] extern crate scopeguard; diff --git a/third_party/rust/lock_api/src/mutex.rs b/third_party/rust/lock_api/src/mutex.rs index f64fc13f2e14..4e1b879e5f64 100644 --- a/third_party/rust/lock_api/src/mutex.rs +++ b/third_party/rust/lock_api/src/mutex.rs @@ -149,7 +149,7 @@ unsafe impl Sync for Mutex {} impl Mutex { /// Creates a new mutex in an unlocked state ready for use. - #[cfg(feature = "nightly")] + #[cfg(has_const_fn_trait_bound)] #[inline] pub const fn new(val: T) -> Mutex { Mutex { @@ -159,7 +159,7 @@ impl Mutex { } /// Creates a new mutex in an unlocked state ready for use. - #[cfg(not(feature = "nightly"))] + #[cfg(not(has_const_fn_trait_bound))] #[inline] pub fn new(val: T) -> Mutex { Mutex { @@ -565,6 +565,17 @@ impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> { defer!(s.mutex.raw.lock()); f() } + + /// Leaks the mutex guard and returns a mutable reference to the data + /// protected by the mutex. + /// + /// This will leave the `Mutex` in a locked state. + #[inline] + pub fn leak(s: Self) -> &'a mut T { + let r = unsafe { &mut *s.mutex.data.get() }; + mem::forget(s); + r + } } impl<'a, R: RawMutexFair + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> { @@ -663,8 +674,8 @@ impl<'a, R: RawMutex + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for Mutex unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MutexGuard<'a, R, T> {} /// An RAII mutex guard returned by the `Arc` locking operations on `Mutex`. -/// -/// This is similar to the `MutexGuard` struct, except instead of using a reference to unlock the `Mutex` it +/// +/// This is similar to the `MutexGuard` struct, except instead of using a reference to unlock the `Mutex` it /// uses an `Arc`. This has several advantages, most notably that it has an `'static` lifetime. #[cfg(feature = "arc_lock")] #[must_use = "if unused the Mutex will immediately unlock"] @@ -713,7 +724,7 @@ impl ArcMutexGuard { // SAFETY: make sure the Arc gets it reference decremented let mut s = ManuallyDrop::new(s); - unsafe { ptr::drop_in_place(&mut s.mutex) }; + unsafe { ptr::drop_in_place(&mut s.mutex) }; } /// Temporarily unlocks the mutex to execute the given function. diff --git a/third_party/rust/lock_api/src/remutex.rs b/third_party/rust/lock_api/src/remutex.rs index 8493a249c60d..fa0e934d1274 100644 --- a/third_party/rust/lock_api/src/remutex.rs +++ b/third_party/rust/lock_api/src/remutex.rs @@ -230,7 +230,7 @@ unsafe impl Sync impl ReentrantMutex { /// Creates a new reentrant mutex in an unlocked state ready for use. - #[cfg(feature = "nightly")] + #[cfg(has_const_fn_trait_bound)] #[inline] pub const fn new(val: T) -> ReentrantMutex { ReentrantMutex { @@ -245,7 +245,7 @@ impl ReentrantMutex { } /// Creates a new reentrant mutex in an unlocked state ready for use. - #[cfg(not(feature = "nightly"))] + #[cfg(not(has_const_fn_trait_bound))] #[inline] pub fn new(val: T) -> ReentrantMutex { ReentrantMutex { @@ -401,7 +401,7 @@ impl ReentrantMutex { } /// # Safety - /// + /// /// The lock must be held before calling this method. #[cfg(feature = "arc_lock")] #[inline] @@ -413,7 +413,7 @@ impl ReentrantMutex { } /// Acquires a reentrant mutex through an `Arc`. - /// + /// /// This method is similar to the `lock` method; however, it requires the `ReentrantMutex` to be inside of an /// `Arc` and the resulting mutex guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -425,7 +425,7 @@ impl ReentrantMutex { } /// Attempts to acquire a reentrant mutex through an `Arc`. - /// + /// /// This method is similar to the `try_lock` method; however, it requires the `ReentrantMutex` to be inside /// of an `Arc` and the resulting mutex guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -490,12 +490,15 @@ impl ReentrantMutex { } /// Attempts to acquire this lock until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_lock_for` method; however, it requires the `ReentrantMutex` to be /// inside of an `Arc` and the resulting mutex guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_lock_arc_for(self: &Arc, timeout: R::Duration) -> Option> { + pub fn try_lock_arc_for( + self: &Arc, + timeout: R::Duration, + ) -> Option> { if self.raw.try_lock_for(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.guard_arc() }) @@ -505,12 +508,15 @@ impl ReentrantMutex { } /// Attempts to acquire this lock until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_lock_until` method; however, it requires the `ReentrantMutex` to be /// inside of an `Arc` and the resulting mutex guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_lock_arc_until(self: &Arc, timeout: R::Instant) -> Option> { + pub fn try_lock_arc_until( + self: &Arc, + timeout: R::Instant, + ) -> Option> { if self.raw.try_lock_until(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.guard_arc() }) @@ -736,7 +742,6 @@ impl<'a, R: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> s.remutex.raw.bump(); } } - } impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Deref @@ -783,9 +788,9 @@ unsafe impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> StableAdd { } -/// An RAII mutex guard returned by the `Arc` locking operations on `ReentrantMutex`. -/// -/// This is similar to the `ReentrantMutexGuard` struct, except instead of using a reference to unlock the +/// An RAII mutex guard returned by the `Arc` locking operations on `ReentrantMutex`. +/// +/// This is similar to the `ReentrantMutexGuard` struct, except instead of using a reference to unlock the /// `Mutex` it uses an `Arc`. This has several advantages, most notably that it has an `'static` /// lifetime. #[cfg(feature = "arc_lock")] @@ -821,9 +826,7 @@ impl ArcReentrantMutexGuard { } #[cfg(feature = "arc_lock")] -impl - ArcReentrantMutexGuard -{ +impl ArcReentrantMutexGuard { /// Unlocks the mutex using a fair unlock protocol. /// /// This is functionally identical to the `unlock_fair` method on [`ReentrantMutexGuard`]. @@ -868,9 +871,7 @@ impl } #[cfg(feature = "arc_lock")] -impl Deref - for ArcReentrantMutexGuard -{ +impl Deref for ArcReentrantMutexGuard { type Target = T; #[inline] fn deref(&self) -> &T { @@ -879,9 +880,7 @@ impl Deref } #[cfg(feature = "arc_lock")] -impl Drop - for ArcReentrantMutexGuard -{ +impl Drop for ArcReentrantMutexGuard { #[inline] fn drop(&mut self) { // Safety: A ReentrantMutexGuard always holds the lock. diff --git a/third_party/rust/lock_api/src/rwlock.rs b/third_party/rust/lock_api/src/rwlock.rs index c404934e83af..e947f1ec03e2 100644 --- a/third_party/rust/lock_api/src/rwlock.rs +++ b/third_party/rust/lock_api/src/rwlock.rs @@ -84,6 +84,18 @@ pub unsafe trait RawRwLock { } !acquired_lock } + + /// Check if this `RwLock` is currently exclusively locked. + fn is_locked_exclusive(&self) -> bool { + let acquired_lock = self.try_lock_shared(); + if acquired_lock { + // Safety: A shared lock was successfully acquired above. + unsafe { + self.unlock_shared(); + } + } + !acquired_lock + } } /// Additional methods for RwLocks which support fair unlocking. @@ -354,7 +366,7 @@ unsafe impl Sync for RwLock impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. - #[cfg(feature = "nightly")] + #[cfg(has_const_fn_trait_bound)] #[inline] pub const fn new(val: T) -> RwLock { RwLock { @@ -364,7 +376,7 @@ impl RwLock { } /// Creates a new instance of an `RwLock` which is unlocked. - #[cfg(not(feature = "nightly"))] + #[cfg(not(has_const_fn_trait_bound))] #[inline] pub fn new(val: T) -> RwLock { RwLock { @@ -502,6 +514,12 @@ impl RwLock { self.raw.is_locked() } + /// Check if this `RwLock` is currently exclusively locked. + #[inline] + pub fn is_locked_exclusive(&self) -> bool { + self.raw.is_locked_exclusive() + } + /// Forcibly unlocks a read lock. /// /// This is useful when combined with `mem::forget` to hold a lock without @@ -590,7 +608,7 @@ impl RwLock { } /// Locks this `RwLock` with read access, through an `Arc`. - /// + /// /// This method is similar to the `read` method; however, it requires the `RwLock` to be inside of an `Arc` /// and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -602,8 +620,8 @@ impl RwLock { } /// Attempts to lock this `RwLock` with read access, through an `Arc`. - /// - /// This method is similar to the `try_read` method; however, it requires the `RwLock` to be inside of an + /// + /// This method is similar to the `try_read` method; however, it requires the `RwLock` to be inside of an /// `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] @@ -617,7 +635,7 @@ impl RwLock { } /// Locks this `RwLock` with write access, through an `Arc`. - /// + /// /// This method is similar to the `write` method; however, it requires the `RwLock` to be inside of an `Arc` /// and the resulting write guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -629,8 +647,8 @@ impl RwLock { } /// Attempts to lock this `RwLock` with writ access, through an `Arc`. - /// - /// This method is similar to the `try_write` method; however, it requires the `RwLock` to be inside of an + /// + /// This method is similar to the `try_write` method; however, it requires the `RwLock` to be inside of an /// `Arc` and the resulting write guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] @@ -744,12 +762,15 @@ impl RwLock { } /// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_read_for` method; however, it requires the `RwLock` to be inside of an /// `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_read_arc_for(self: &Arc, timeout: R::Duration) -> Option> { + pub fn try_read_arc_for( + self: &Arc, + timeout: R::Duration, + ) -> Option> { if self.raw.try_lock_shared_for(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.read_guard_arc() }) @@ -759,12 +780,15 @@ impl RwLock { } /// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_read_until` method; however, it requires the `RwLock` to be inside of /// an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_read_arc_until(self: &Arc, timeout: R::Instant) -> Option> { + pub fn try_read_arc_until( + self: &Arc, + timeout: R::Instant, + ) -> Option> { if self.raw.try_lock_shared_until(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.read_guard_arc() }) @@ -774,12 +798,15 @@ impl RwLock { } /// Attempts to acquire this `RwLock` with write access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_write_for` method; however, it requires the `RwLock` to be inside of /// an `Arc` and the resulting write guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_write_arc_for(self: &Arc, timeout: R::Duration) -> Option> { + pub fn try_write_arc_for( + self: &Arc, + timeout: R::Duration, + ) -> Option> { if self.raw.try_lock_exclusive_for(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.write_guard_arc() }) @@ -789,12 +816,15 @@ impl RwLock { } /// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_write_until` method; however, it requires the `RwLock` to be inside of /// an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_write_arc_until(self: &Arc, timeout: R::Instant) -> Option> { + pub fn try_write_arc_until( + self: &Arc, + timeout: R::Instant, + ) -> Option> { if self.raw.try_lock_exclusive_until(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.write_guard_arc() }) @@ -848,7 +878,7 @@ impl RwLock { } /// Locks this `RwLock` with shared read access, through an `Arc`. - /// + /// /// This method is similar to the `read_recursive` method; however, it requires the `RwLock` to be inside of /// an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -860,9 +890,9 @@ impl RwLock { } /// Attempts to lock this `RwLock` with shared read access, through an `Arc`. - /// + /// /// This method is similar to the `try_read_recursive` method; however, it requires the `RwLock` to be inside - /// of an `Arc` and the resulting read guard has no lifetime requirements. + /// of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] pub fn try_read_recursive_arc(self: &Arc) -> Option> { @@ -924,7 +954,10 @@ impl RwLock { /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_read_arc_recursive_for(self: &Arc, timeout: R::Duration) -> Option> { + pub fn try_read_arc_recursive_for( + self: &Arc, + timeout: R::Duration, + ) -> Option> { if self.raw.try_lock_shared_recursive_for(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.read_guard_arc() }) @@ -939,7 +972,10 @@ impl RwLock { /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] #[inline] - pub fn try_read_arc_recursive_until(self: &Arc, timeout: R::Instant) -> Option> { + pub fn try_read_arc_recursive_until( + self: &Arc, + timeout: R::Instant, + ) -> Option> { if self.raw.try_lock_shared_recursive_until(timeout) { // SAFETY: locking guarantee is upheld Some(unsafe { self.read_guard_arc() }) @@ -995,19 +1031,19 @@ impl RwLock { } /// # Safety - /// + /// /// The lock must be held when calling this method. #[cfg(feature = "arc_lock")] #[inline] unsafe fn upgradable_guard_arc(self: &Arc) -> ArcRwLockUpgradableReadGuard { ArcRwLockUpgradableReadGuard { rwlock: self.clone(), - marker: PhantomData + marker: PhantomData, } } /// Locks this `RwLock` with upgradable read access, through an `Arc`. - /// + /// /// This method is similar to the `upgradable_read` method; however, it requires the `RwLock` to be /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -1019,7 +1055,7 @@ impl RwLock { } /// Attempts to lock this `RwLock` with upgradable read access, through an `Arc`. - /// + /// /// This method is similar to the `try_upgradable_read` method; however, it requires the `RwLock` to be /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -1074,7 +1110,7 @@ impl RwLock { } /// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_upgradable_read_for` method; however, it requires the `RwLock` to be /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -1092,7 +1128,7 @@ impl RwLock { } /// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `Arc`. - /// + /// /// This method is similar to the `try_upgradable_read_until` method; however, it requires the `RwLock` to be /// inside of an `Arc` and the resulting read guard has no lifetime requirements. #[cfg(feature = "arc_lock")] @@ -1318,9 +1354,9 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display #[cfg(feature = "owning_ref")] unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockReadGuard<'a, R, T> {} -/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`. -/// -/// This is similar to the `RwLockReadGuard` struct, except instead of using a reference to unlock the `RwLock` +/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`. +/// +/// This is similar to the `RwLockReadGuard` struct, except instead of using a reference to unlock the `RwLock` /// it uses an `Arc`. This has several advantages, most notably that it has an `'static` lifetime. #[cfg(feature = "arc_lock")] #[must_use = "if unused the RwLock will immediately unlock"] @@ -1426,9 +1462,7 @@ impl fmt::Debug for ArcRwLockReadGuard fmt::Display - for ArcRwLockReadGuard -{ +impl fmt::Display for ArcRwLockReadGuard { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } @@ -1655,8 +1689,8 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display #[cfg(feature = "owning_ref")] unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockWriteGuard<'a, R, T> {} -/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`. -/// This is similar to the `RwLockWriteGuard` struct, except instead of using a reference to unlock the `RwLock` +/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`. +/// This is similar to the `RwLockWriteGuard` struct, except instead of using a reference to unlock the `RwLock` /// it uses an `Arc`. This has several advantages, most notably that it has an `'static` lifetime. #[cfg(feature = "arc_lock")] #[must_use = "if unused the RwLock will immediately unlock"] @@ -1770,7 +1804,7 @@ impl ArcRwLockWriteGuard { /// Temporarily yields the `RwLock` to a waiting thread if there is one. /// - /// This method is functionally equivalent to the `bump` method on [`RwLockWriteGuard`]. + /// This method is functionally equivalent to the `bump` method on [`RwLockWriteGuard`]. #[inline] pub fn bump(s: &mut Self) { // Safety: An RwLockWriteGuard always holds an exclusive lock. @@ -1816,9 +1850,7 @@ impl fmt::Debug for ArcRwLockWriteGuard fmt::Display - for ArcRwLockWriteGuard -{ +impl fmt::Display for ArcRwLockWriteGuard { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } @@ -2059,7 +2091,7 @@ unsafe impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> StableAddress /// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`. /// This is similar to the `RwLockUpgradableReadGuard` struct, except instead of using a reference to unlock the -/// `RwLock` it uses an `Arc`. This has several advantages, most notably that it has an `'static` +/// `RwLock` it uses an `Arc`. This has several advantages, most notably that it has an `'static` /// lifetime. #[cfg(feature = "arc_lock")] #[must_use = "if unused the RwLock will immediately unlock"] @@ -2069,7 +2101,7 @@ pub struct ArcRwLockUpgradableReadGuard { } #[cfg(feature = "arc_lock")] -impl ArcRwLockUpgradableReadGuard { +impl ArcRwLockUpgradableReadGuard { /// Returns a reference to the rwlock, contained in its original `Arc`. pub fn rwlock(s: &Self) -> &Arc> { &s.rwlock @@ -2144,7 +2176,7 @@ impl ArcRwLockUpgradableReadGuard { // SAFETY: make sure we decrement the refcount properly let mut s = ManuallyDrop::new(s); - unsafe { ptr::drop_in_place(&mut s.rwlock) }; + unsafe { ptr::drop_in_place(&mut s.rwlock) }; } /// Temporarily unlocks the `RwLock` to execute the given function. @@ -2291,7 +2323,6 @@ impl fmt::Display } } - /// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a /// subfield of the protected data. ///