Update lock_api to 0.4.6 am: 93e109d886

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/lock_api/+/2005911

Change-Id: I1513c7dbdfae8c2c8ebd1c761e800359e08377ee
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 58935f2..9ed45c2 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
 {
   "git": {
-    "sha1": "18001b819c1539c06c176c671bbe54e70b5c3d69"
-  }
-}
+    "sha1": "a75875b0bf904287a9749e8eabea919b5e9dd8a9"
+  },
+  "path_in_vcs": "lock_api"
+}
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 06ca975..67d3a3b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -42,7 +42,7 @@
     host_supported: true,
     crate_name: "lock_api",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.4.5",
+    cargo_pkg_version: "0.4.6",
     srcs: ["src/lib.rs"],
     edition: "2018",
     rustlibs: [
diff --git a/Cargo.toml b/Cargo.toml
index 4382f30..63cf8c3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
 [package]
 edition = "2018"
 name = "lock_api"
-version = "0.4.5"
+version = "0.4.6"
 authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
 description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std."
 keywords = ["mutex", "rwlock", "lock", "no_std"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 96ffdfc..e6a805f 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "lock_api"
-version = "0.4.5"
+version = "0.4.6"
 authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
 description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std."
 license = "Apache-2.0/MIT"
diff --git a/METADATA b/METADATA
index ebfc44b..1caadde 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/lock_api/lock_api-0.4.5.crate"
+    value: "https://static.crates.io/crates/lock_api/lock_api-0.4.6.crate"
   }
-  version: "0.4.5"
+  version: "0.4.6"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2021
-    month: 9
-    day: 22
+    year: 2022
+    month: 3
+    day: 1
   }
 }
diff --git a/src/mutex.rs b/src/mutex.rs
index f64fc13..81c25fb 100644
--- a/src/mutex.rs
+++ b/src/mutex.rs
@@ -663,8 +663,8 @@
 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<Mutex>`. 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 +713,7 @@
 
         // 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/src/remutex.rs b/src/remutex.rs
index 8493a24..dd992b4 100644
--- a/src/remutex.rs
+++ b/src/remutex.rs
@@ -401,7 +401,7 @@
     }
 
     /// # Safety
-    /// 
+    ///
     /// The lock must be held before calling this method.
     #[cfg(feature = "arc_lock")]
     #[inline]
@@ -413,7 +413,7 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
     }
 
     /// 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<Self>, timeout: R::Duration) -> Option<ArcReentrantMutexGuard<R, G, T>> {
+    pub fn try_lock_arc_for(
+        self: &Arc<Self>,
+        timeout: R::Duration,
+    ) -> Option<ArcReentrantMutexGuard<R, G, T>> {
         if self.raw.try_lock_for(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.guard_arc() })
@@ -505,12 +508,15 @@
     }
 
     /// 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<Self>, timeout: R::Instant) -> Option<ArcReentrantMutexGuard<R, G, T>> {
+    pub fn try_lock_arc_until(
+        self: &Arc<Self>,
+        timeout: R::Instant,
+    ) -> Option<ArcReentrantMutexGuard<R, G, T>> {
         if self.raw.try_lock_until(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.guard_arc() })
@@ -736,7 +742,6 @@
             s.remutex.raw.bump();
         }
     }
-
 }
 
 impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Deref
@@ -783,9 +788,9 @@
 {
 }
 
-/// 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<ReentrantMutex>`. This has several advantages, most notably that it has an `'static`
 /// lifetime.
 #[cfg(feature = "arc_lock")]
@@ -821,9 +826,7 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawMutexFair, G: GetThreadId, T: ?Sized>
-    ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutexFair, G: GetThreadId, T: ?Sized> ArcReentrantMutexGuard<R, G, T> {
     /// Unlocks the mutex using a fair unlock protocol.
     ///
     /// This is functionally identical to the `unlock_fair` method on [`ReentrantMutexGuard`].
@@ -868,9 +871,7 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawMutex, G: GetThreadId, T: ?Sized> Deref
-    for ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutex, G: GetThreadId, T: ?Sized> Deref for ArcReentrantMutexGuard<R, G, T> {
     type Target = T;
     #[inline]
     fn deref(&self) -> &T {
@@ -879,9 +880,7 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop
-    for ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop for ArcReentrantMutexGuard<R, G, T> {
     #[inline]
     fn drop(&mut self) {
         // Safety: A ReentrantMutexGuard always holds the lock.
diff --git a/src/rwlock.rs b/src/rwlock.rs
index c404934..9bfa1da 100644
--- a/src/rwlock.rs
+++ b/src/rwlock.rs
@@ -84,6 +84,18 @@
         }
         !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.
@@ -502,6 +514,12 @@
         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 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
     }
 
     /// 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<Self>, timeout: R::Duration) -> Option<ArcRwLockReadGuard<R, T>> {
+    pub fn try_read_arc_for(
+        self: &Arc<Self>,
+        timeout: R::Duration,
+    ) -> Option<ArcRwLockReadGuard<R, T>> {
         if self.raw.try_lock_shared_for(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.read_guard_arc() })
@@ -759,12 +780,15 @@
     }
 
     /// 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<Self>, timeout: R::Instant) -> Option<ArcRwLockReadGuard<R, T>> {
+    pub fn try_read_arc_until(
+        self: &Arc<Self>,
+        timeout: R::Instant,
+    ) -> Option<ArcRwLockReadGuard<R, T>> {
         if self.raw.try_lock_shared_until(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.read_guard_arc() })
@@ -774,12 +798,15 @@
     }
 
     /// 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<Self>, timeout: R::Duration) -> Option<ArcRwLockWriteGuard<R, T>> {
+    pub fn try_write_arc_for(
+        self: &Arc<Self>,
+        timeout: R::Duration,
+    ) -> Option<ArcRwLockWriteGuard<R, T>> {
         if self.raw.try_lock_exclusive_for(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.write_guard_arc() })
@@ -789,12 +816,15 @@
     }
 
     /// 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<Self>, timeout: R::Instant) -> Option<ArcRwLockWriteGuard<R, T>> {
+    pub fn try_write_arc_until(
+        self: &Arc<Self>,
+        timeout: R::Instant,
+    ) -> Option<ArcRwLockWriteGuard<R, T>> {
         if self.raw.try_lock_exclusive_until(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.write_guard_arc() })
@@ -848,7 +878,7 @@
     }
 
     /// 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,7 +890,7 @@
     }
 
     /// 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.   
     #[cfg(feature = "arc_lock")]
@@ -924,7 +954,10 @@
     /// 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<Self>, timeout: R::Duration) -> Option<ArcRwLockReadGuard<R, T>> {
+    pub fn try_read_arc_recursive_for(
+        self: &Arc<Self>,
+        timeout: R::Duration,
+    ) -> Option<ArcRwLockReadGuard<R, T>> {
         if self.raw.try_lock_shared_recursive_for(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.read_guard_arc() })
@@ -939,7 +972,10 @@
     /// 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<Self>, timeout: R::Instant) -> Option<ArcRwLockReadGuard<R, T>> {
+    pub fn try_read_arc_recursive_until(
+        self: &Arc<Self>,
+        timeout: R::Instant,
+    ) -> Option<ArcRwLockReadGuard<R, T>> {
         if self.raw.try_lock_shared_recursive_until(timeout) {
             // SAFETY: locking guarantee is upheld
             Some(unsafe { self.read_guard_arc() })
@@ -995,19 +1031,19 @@
     }
 
     /// # Safety
-    /// 
+    ///
     /// The lock must be held when calling this method.
     #[cfg(feature = "arc_lock")]
     #[inline]
     unsafe fn upgradable_guard_arc(self: &Arc<Self>) -> ArcRwLockUpgradableReadGuard<R, T> {
         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 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
     }
 
     /// 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 @@
 #[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<RwLock>`. 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 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display
-    for ArcRwLockReadGuard<R, T>
-{
+impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display for ArcRwLockReadGuard<R, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         (**self).fmt(f)
     }
@@ -1655,8 +1689,8 @@
 #[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<RwLock>`. 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 @@
 
     /// 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 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display
-    for ArcRwLockWriteGuard<R, T>
-{
+impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display for ArcRwLockWriteGuard<R, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         (**self).fmt(f)
     }
@@ -2059,7 +2091,7 @@
 
 /// 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<RwLock>`. This has several advantages, most notably that it has an `'static` 
+/// `RwLock` it uses an `Arc<RwLock>`. 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 @@
 }
 
 #[cfg(feature = "arc_lock")]
-impl<R: RawRwLockUpgrade , T: ?Sized> ArcRwLockUpgradableReadGuard<R, T> {
+impl<R: RawRwLockUpgrade, T: ?Sized> ArcRwLockUpgradableReadGuard<R, T> {
     /// Returns a reference to the rwlock, contained in its original `Arc`.
     pub fn rwlock(s: &Self) -> &Arc<RwLock<R, T>> {
         &s.rwlock
@@ -2144,7 +2176,7 @@
 
         // 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 @@
     }
 }
 
-
 /// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a
 /// subfield of the protected data.
 ///