about summary refs log tree commit diff
path: root/library/std/src/sync
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-03-27 13:31:17 +0100
committerMara Bos <m-ou.se@m-ou.se>2021-03-27 13:33:52 +0100
commitd73015397dc43eb8067644ab2bbb1c2203c795d4 (patch)
tree4372dc66d67a28bc9704b6a414bb3bc2d02eea03 /library/std/src/sync
parentfeaac19f1710ebcfecc783d51f52a9b0d8e998f5 (diff)
Fix Debug implementation for RwLock{Read,Write}Guard.
This would attempt to print the Debug representation of the lock that
the guard has locked, which will try to lock again, fail, and just print
"<locked>" unhelpfully.

After this change, this just prints the contents of the mutex, like the
other smart pointers (and MutexGuard) do.
Diffstat (limited to 'library/std/src/sync')
-rw-r--r--library/std/src/sync/rwlock.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs
index 0298f59228c..c6c753b103f 100644
--- a/library/std/src/sync/rwlock.rs
+++ b/library/std/src/sync/rwlock.rs
@@ -473,7 +473,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> {
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("RwLockReadGuard").field("lock", &self.lock).finish()
+        (**self).fmt(f)
     }
 }
 
@@ -487,7 +487,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'_, T> {
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("RwLockWriteGuard").field("lock", &self.lock).finish()
+        (**self).fmt(f)
     }
 }