[rust_crates] Upgrade tracing-mutex

Change-Id: I62192716b6c835558ff6a1a97e0cdc3c6432fd24
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/693508
Commit-Queue: Theodore Dubois <tbodt@google.com>
Reviewed-by: Joseph Ryan <josephry@google.com>
diff --git a/third_party/rust_crates/BUILD.gn b/third_party/rust_crates/BUILD.gn
index 99d23fd..26e7ff4 100644
--- a/third_party/rust_crates/BUILD.gn
+++ b/third_party/rust_crates/BUILD.gn
@@ -945,7 +945,7 @@
 }
 
 group("tracing-mutex") {
-  public_deps = [ ":tracing-mutex-v0_2_0" ]
+  public_deps = [ ":tracing-mutex-v0_2_1" ]
 }
 
 group("tracing-subscriber") {
@@ -10939,10 +10939,10 @@
   visibility = [ ":*" ]
 }
 
-rust_library("tracing-mutex-v0_2_0") {
+rust_library("tracing-mutex-v0_2_1") {
   crate_name = "tracing_mutex"
   crate_root = "//third_party/rust_crates/vendor/tracing-mutex/src/lib.rs"
-  output_name = "tracing_mutex-4f32008b94479e94"
+  output_name = "tracing_mutex-d2105b4603a79f7d"
   configs -= [ "//build/config/rust:2018_idioms" ]
 
   deps = []
@@ -10955,8 +10955,8 @@
   rustflags = [
     "--cap-lints=allow",
     "--edition=2021",
-    "-Cmetadata=4f32008b94479e94",
-    "-Cextra-filename=-4f32008b94479e94",
+    "-Cmetadata=d2105b4603a79f7d",
+    "-Cextra-filename=-d2105b4603a79f7d",
     "--cfg=feature=\"lock_api\"",
     "--cfg=feature=\"lockapi\"",
     "--cfg=feature=\"parking_lot\"",
diff --git a/third_party/rust_crates/Cargo.lock b/third_party/rust_crates/Cargo.lock
index f979cfc..1f63b55 100644
--- a/third_party/rust_crates/Cargo.lock
+++ b/third_party/rust_crates/Cargo.lock
@@ -4272,9 +4272,9 @@
 
 [[package]]
 name = "tracing-mutex"
-version = "0.2.0"
+version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "029d8c53606e2efde3b3f632ea242856e3169eb05e4696bcf1f5afa3b7c9747d"
+checksum = "b3df21ca58f0e0b5ee3181d8eebb8f2ec16d6ecbb2a04f351aa6abd7cf700f22"
 dependencies = [
  "lazy_static",
  "lock_api 0.4.7",
diff --git a/third_party/rust_crates/Cargo.toml b/third_party/rust_crates/Cargo.toml
index 31b186e..cf86854 100644
--- a/third_party/rust_crates/Cargo.toml
+++ b/third_party/rust_crates/Cargo.toml
@@ -200,7 +200,7 @@
 tracing-core = "0.1.21"
 tracing-futures = "0.2.5"
 tracing-log = "0.1.2"
-tracing-mutex = { version = "0.2.0", features = ["parkinglot"] }
+tracing-mutex = { version = "0.2.1", features = ["parkinglot"] }
 typed-builder = "0.10.0"
 unicase = "2.2.0"
 untrusted = "0.7.1"
diff --git a/third_party/rust_crates/vendor/tracing-mutex/.cargo-checksum.json b/third_party/rust_crates/vendor/tracing-mutex/.cargo-checksum.json
index b445442..0b1a0d2 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/.cargo-checksum.json
+++ b/third_party/rust_crates/vendor/tracing-mutex/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"2050919f53f93e30a40a3153a39a838afb64f20c70200300e6181495dc60ffa1","Cargo.toml":"e83a9ff0051b87a71b15d11bdb6535d95609cac6a25931aca50a5a00e4b1dcf8","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"e5982eb5c91c78ffc2ce50a16e08195dda9a1240638441553b2449f98b6a6e2b","README.md":"e488b0cb6fa6b38f1d72f19a5f8b03a81c89cd9680417d0290d45f77fb4899c3","benches/mutex.rs":"f928d85fedaf63298e3502bd48e492aeb368a75eeecb4cd9c5fe2b706a6f41ad","src/graph.rs":"1ac5c7f8af24e11b6e53686c3bcfc5fa66deadcd9e67de9a593ea9584830bfff","src/lib.rs":"46cedb71b2a6df94a2004267bde95c935ccc925a169dd90efca5cad522da69de","src/lockapi.rs":"a6434bdaaeb7e4b1d6a32d98a61cc35770d9c92980286fa525872e5225552718","src/parkinglot.rs":"a281340725d6a39c4aefb9fc55f12bd11d4b9d8f9c8324ea00a5f02bd96b11e3","src/stdsync.rs":"ee7a2bc6393bed37aeb3d1f602240ceec63b46aa8aed467982b0bd9fc408d5fa"},"package":"029d8c53606e2efde3b3f632ea242856e3169eb05e4696bcf1f5afa3b7c9747d"}
\ No newline at end of file
+{"files":{"CHANGELOG.md":"ac7dd275834222bae8eeefb8497ce6f16546b99bd8fef9e7f344c02e900fb2b8","Cargo.toml":"70a62e01d3c46de1c81adfb8f40dd7d1aef5a3cada1f995804abadf4e0e8d858","LICENSE-APACHE":"8091982a4b26d43c3f33c9c6a935b6b61051838c3d8269d7cd142643965167a3","LICENSE-MIT":"3fb71d0876faaf8779e76ba9cfb5ef3a785f6d46d27fd757f15e6ffd8b952fc8","README.md":"7392c81d48e2c5944349a1c26d30dac7c692c9d7e3897a550b660047dd8a6b6f","benches/mutex.rs":"f928d85fedaf63298e3502bd48e492aeb368a75eeecb4cd9c5fe2b706a6f41ad","bors.toml":"131e36b8c26b1653d0253d59bd41a9360b44ee88ac1aaa0e3dfb260580c097fe","src/graph.rs":"1ac5c7f8af24e11b6e53686c3bcfc5fa66deadcd9e67de9a593ea9584830bfff","src/lib.rs":"128c04330d80333a64f2848583a1c34484a4c2d5dcf15137b81e2e028c055291","src/lockapi.rs":"a6434bdaaeb7e4b1d6a32d98a61cc35770d9c92980286fa525872e5225552718","src/parkinglot.rs":"ed20503bf58df701d110a565ba5d46ff575a2732918d0e2d11d4bb2a0efe0deb","src/stdsync.rs":"a56f9fbc7e78a4866c4df1e560ffdba1da1de4f1be583c9026f6d304d1f833f9"},"package":"b3df21ca58f0e0b5ee3181d8eebb8f2ec16d6ecbb2a04f351aa6abd7cf700f22"}
\ No newline at end of file
diff --git a/third_party/rust_crates/vendor/tracing-mutex/CHANGELOG.md b/third_party/rust_crates/vendor/tracing-mutex/CHANGELOG.md
index 31689c5..15a5ab3 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/CHANGELOG.md
+++ b/third_party/rust_crates/vendor/tracing-mutex/CHANGELOG.md
@@ -6,7 +6,19 @@
 
 ## [Unreleased]
 
-## [0.2.0]
+## [0.2.1] - 2022-05-23
+
+### Added
+
+- Build [docs.rs] documentation with all features enabled for completeness.
+- Add support for `std::sync::Condvar`
+
+### Fixed
+
+- The `parkinglot` module is now correctly enabled by the `parkinglot` feature rather than the
+  `lockapi` feature.
+
+## [0.2.0] - 2022-05-07
 
 ### Added
 - Generic support for wrapping mutexes that implement the traits provided by the
@@ -55,11 +67,13 @@
 
 Initial release.
 
-[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.0...HEAD
+[Unreleased]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.1...HEAD
+[0.2.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.2.0...v0.2.1
 [0.2.0]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.2...v0.2.0
 [0.1.2]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.1...v0.1.2
 [0.1.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.0...v0.1.1
 [0.1.0]: https://github.com/bertptrs/tracing-mutex/releases/tag/v0.1.0
 
+[docs.rs]: https://docs.rs/tracing-mutex/latest/tracing_mutex/
 [lock_api]: https://docs.rs/lock_api/
 [parking_lot]: https://docs.rs/parking_lot/
diff --git a/third_party/rust_crates/vendor/tracing-mutex/Cargo.toml b/third_party/rust_crates/vendor/tracing-mutex/Cargo.toml
index df2ae23..5e4e1ec 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/Cargo.toml
+++ b/third_party/rust_crates/vendor/tracing-mutex/Cargo.toml
@@ -12,7 +12,7 @@
 [package]
 edition = "2021"
 name = "tracing-mutex"
-version = "0.2.0"
+version = "0.2.1"
 authors = ["Bert Peters <bert@bertptrs.nl>"]
 description = "Ensure deadlock-free mutexes by allocating in order, or else."
 documentation = "https://docs.rs/tracing-mutex"
@@ -31,6 +31,13 @@
 repository = "https://github.com/bertptrs/tracing-mutex"
 resolver = "2"
 
+[package.metadata.docs.rs]
+all-features = true
+rustdoc-args = [
+    "--cfg",
+    "docsrs",
+]
+
 [[bench]]
 name = "mutex"
 harness = false
diff --git a/third_party/rust_crates/vendor/tracing-mutex/LICENSE-APACHE b/third_party/rust_crates/vendor/tracing-mutex/LICENSE-APACHE
index 16fe87b..790581d 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/LICENSE-APACHE
+++ b/third_party/rust_crates/vendor/tracing-mutex/LICENSE-APACHE
@@ -186,7 +186,7 @@
    same "printed page" as the copyright notice for easier
    identification within third-party archives.
 
-Copyright [yyyy] [name of copyright owner]
+Copyright 2022 Bert Peters
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
diff --git a/third_party/rust_crates/vendor/tracing-mutex/LICENSE-MIT b/third_party/rust_crates/vendor/tracing-mutex/LICENSE-MIT
index 05fc1db..afcfc2d 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/LICENSE-MIT
+++ b/third_party/rust_crates/vendor/tracing-mutex/LICENSE-MIT
@@ -1,4 +1,4 @@
-Copyright © 2021 Bert Peters
+Copyright © 2022 Bert Peters
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 associated documentation files (the “Software”), to deal in the Software without restriction,
diff --git a/third_party/rust_crates/vendor/tracing-mutex/README.md b/third_party/rust_crates/vendor/tracing-mutex/README.md
index 610a164..4513fac 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/README.md
+++ b/third_party/rust_crates/vendor/tracing-mutex/README.md
@@ -34,7 +34,7 @@
 
 ```toml
 [dependencies]
-tracing-mutex = "0.1"
+tracing-mutex = "0.2"
 ```
 
 Then use the locks provided by this library instead of the ones you would use otherwise.
@@ -59,12 +59,23 @@
 when debug assertions are enabled, and to `Mutex` when they are not. Similar helper types are
 available for other synchronization primitives.
 
+### Features
+
+- Dependency-tracking wrappers for all locking primitives
+- Optional opt-out for release mode code
+- Support for primitives from:
+  - `std::sync`
+  - `parking_lot`
+  - Any library that implements the `lock_api` traits
+
 ## Future improvements
 
 - Improve performance in lock tracing
 - Optional logging to make debugging easier
 - Better and configurable error handling when detecting cyclic dependencies
-- Support for other locking libraries, such as `parking_lot`
+- Support for other locking libraries
+- Support for async locking libraries
+- Support for `Send` mutex guards
 
 **Note:** `parking_lot` has already began work on its own deadlock detection mechanism, which works
 in a different way. Both can be complimentary.
diff --git a/third_party/rust_crates/vendor/tracing-mutex/src/lib.rs b/third_party/rust_crates/vendor/tracing-mutex/src/lib.rs
index 2c15a7b..0b6f425 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/src/lib.rs
+++ b/third_party/rust_crates/vendor/tracing-mutex/src/lib.rs
@@ -45,6 +45,7 @@
 //! enabled, and to the underlying mutex when they're not.
 //!
 //! [paper]: https://whileydave.com/publications/pk07_jea/
+#![cfg_attr(docsrs, feature(doc_cfg))]
 use std::cell::RefCell;
 use std::cell::UnsafeCell;
 use std::fmt;
@@ -61,16 +62,20 @@
 
 use lazy_static::lazy_static;
 #[cfg(feature = "lockapi")]
+#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))]
 pub use lock_api;
 #[cfg(feature = "parkinglot")]
+#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))]
 pub use parking_lot;
 
 use crate::graph::DiGraph;
 
 mod graph;
 #[cfg(feature = "lockapi")]
+#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))]
 pub mod lockapi;
-#[cfg(feature = "lockapi")]
+#[cfg(feature = "parkinglot")]
+#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))]
 pub mod parkinglot;
 pub mod stdsync;
 
diff --git a/third_party/rust_crates/vendor/tracing-mutex/src/parkinglot.rs b/third_party/rust_crates/vendor/tracing-mutex/src/parkinglot.rs
index bd7777b..fff2cb4 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/src/parkinglot.rs
+++ b/third_party/rust_crates/vendor/tracing-mutex/src/parkinglot.rs
@@ -194,9 +194,9 @@
         self.inner.call_once(f);
     }
 
-    /// Performs the given initialization routeine once and only once.
+    /// Performs the given initialization routine once and only once.
     ///
-    /// This method is identical to [`TracingOnce::call_once`] except it ignores poisining.
+    /// This method is identical to [`TracingOnce::call_once`] except it ignores poisoning.
     pub fn call_once_force(&self, f: impl FnOnce(OnceState)) {
         let _borrow = self.id.get_borrowed();
         self.inner.call_once_force(f);
diff --git a/third_party/rust_crates/vendor/tracing-mutex/src/stdsync.rs b/third_party/rust_crates/vendor/tracing-mutex/src/stdsync.rs
index c6050fc..3cdb4d3 100644
--- a/third_party/rust_crates/vendor/tracing-mutex/src/stdsync.rs
+++ b/third_party/rust_crates/vendor/tracing-mutex/src/stdsync.rs
@@ -16,6 +16,7 @@
 use std::fmt;
 use std::ops::Deref;
 use std::ops::DerefMut;
+use std::sync::Condvar;
 use std::sync::LockResult;
 use std::sync::Mutex;
 use std::sync::MutexGuard;
@@ -27,6 +28,8 @@
 use std::sync::RwLockWriteGuard;
 use std::sync::TryLockError;
 use std::sync::TryLockResult;
+use std::sync::WaitTimeoutResult;
+use std::time::Duration;
 
 use crate::BorrowedMutex;
 use crate::LazyMutexId;
@@ -48,6 +51,14 @@
 #[cfg(not(debug_assertions))]
 pub type DebugMutexGuard<'a, T> = MutexGuard<'a, T>;
 
+/// Debug-only `Condvar`
+///
+/// Type alias that accepts the mutex guard emitted from [`DebugMutex`].
+#[cfg(debug_assertions)]
+pub type DebugCondvar = TracingCondvar;
+#[cfg(not(debug_assertions))]
+pub type DebugCondvar = Condvar;
+
 /// Debug-only tracing `RwLock`.
 ///
 /// Type alias that resolves to [`TracingRwLock`] when debug assertions are enabled and to
@@ -214,6 +225,123 @@
     }
 }
 
+/// Wrapper around [`std::sync::Condvar`].
+///
+/// Allows `TracingMutexGuard` to be used with a `Condvar`. Unlike other structs in this module,
+/// this wrapper does not add any additional dependency tracking or other overhead on top of the
+/// primitive it wraps. All dependency tracking happens through the mutexes itself.
+///
+/// # Panics
+///
+/// This struct does not add any panics over the base implementation of `Condvar`, but panics due to
+/// dependency tracking may poison associated mutexes.
+///
+/// # Examples
+///
+/// ```
+/// use std::sync::Arc;
+/// use std::thread;
+///
+/// use tracing_mutex::stdsync::{TracingCondvar, TracingMutex};
+///
+/// let pair = Arc::new((TracingMutex::new(false), TracingCondvar::new()));
+/// let pair2 = Arc::clone(&pair);
+///
+/// // Spawn a thread that will unlock the condvar
+/// thread::spawn(move || {
+///     let (lock, condvar) = &*pair2;
+///     *lock.lock().unwrap() = true;
+///     condvar.notify_one();
+/// });
+///
+/// // Wait until the thread unlocks the condvar
+/// let (lock, condvar) = &*pair;
+/// let guard = lock.lock().unwrap();
+/// let guard = condvar.wait_while(guard, |started| !*started).unwrap();
+///
+/// // Guard should read true now
+/// assert!(*guard);
+/// ```
+#[derive(Debug, Default)]
+pub struct TracingCondvar(Condvar);
+
+impl TracingCondvar {
+    /// Creates a new condition variable which is ready to be waited on and notified.
+    pub fn new() -> Self {
+        Default::default()
+    }
+
+    /// Wrapper for [`std::sync::Condvar::wait`].
+    pub fn wait<'a, T>(
+        &self,
+        guard: TracingMutexGuard<'a, T>,
+    ) -> LockResult<TracingMutexGuard<'a, T>> {
+        let TracingMutexGuard { _mutex, inner } = guard;
+
+        map_lockresult(self.0.wait(inner), |inner| TracingMutexGuard {
+            _mutex,
+            inner,
+        })
+    }
+
+    /// Wrapper for [`std::sync::Condvar::wait_while`].
+    pub fn wait_while<'a, T, F>(
+        &self,
+        guard: TracingMutexGuard<'a, T>,
+        condition: F,
+    ) -> LockResult<TracingMutexGuard<'a, T>>
+    where
+        F: FnMut(&mut T) -> bool,
+    {
+        let TracingMutexGuard { _mutex, inner } = guard;
+
+        map_lockresult(self.0.wait_while(inner, condition), |inner| {
+            TracingMutexGuard { _mutex, inner }
+        })
+    }
+
+    /// Wrapper for [`std::sync::Condvar::wait_timeout`].
+    pub fn wait_timeout<'a, T>(
+        &self,
+        guard: TracingMutexGuard<'a, T>,
+        dur: Duration,
+    ) -> LockResult<(TracingMutexGuard<'a, T>, WaitTimeoutResult)> {
+        let TracingMutexGuard { _mutex, inner } = guard;
+
+        map_lockresult(self.0.wait_timeout(inner, dur), |(inner, result)| {
+            (TracingMutexGuard { _mutex, inner }, result)
+        })
+    }
+
+    /// Wrapper for [`std::sync::Condvar::wait_timeout_while`].
+    pub fn wait_timeout_while<'a, T, F>(
+        &self,
+        guard: TracingMutexGuard<'a, T>,
+        dur: Duration,
+        condition: F,
+    ) -> LockResult<(TracingMutexGuard<'a, T>, WaitTimeoutResult)>
+    where
+        F: FnMut(&mut T) -> bool,
+    {
+        let TracingMutexGuard { _mutex, inner } = guard;
+
+        map_lockresult(
+            self.0.wait_timeout_while(inner, dur, condition),
+            |(inner, result)| (TracingMutexGuard { _mutex, inner }, result),
+        )
+    }
+
+    /// Wrapper for [`std::sync::Condvar::notify_one`].
+    pub fn notify_one(&self) {
+        self.0.notify_one();
+    }
+
+    /// Wrapper for [`std::sync::Condvar::notify_all`].
+    pub fn notify_all(&self) {
+        self.0.notify_all();
+    }
+}
+
 /// Wrapper for [`std::sync::RwLock`].
 #[derive(Debug, Default)]
 pub struct TracingRwLock<T> {