Skip to content

Commit d730153

Browse files
committed
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.
1 parent feaac19 commit d730153

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/sync/rwlock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> {
473473
#[stable(feature = "std_debug", since = "1.16.0")]
474474
impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> {
475475
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
476-
f.debug_struct("RwLockReadGuard").field("lock", &self.lock).finish()
476+
(**self).fmt(f)
477477
}
478478
}
479479

@@ -487,7 +487,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'_, T> {
487487
#[stable(feature = "std_debug", since = "1.16.0")]
488488
impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> {
489489
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
490-
f.debug_struct("RwLockWriteGuard").field("lock", &self.lock).finish()
490+
(**self).fmt(f)
491491
}
492492
}
493493

0 commit comments

Comments
 (0)