Rollup merge of #83559 - m-ou-se:rwlock-guard-debug-fix, r=jackh726
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. MutexGuard had this problem too: https://github.com/rust-lang/rust/issues/57702
This commit is contained in:
commit
5dc29e189b
1 changed files with 2 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue