File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -441,10 +441,13 @@ impl<T: ?Sized + Default> Default for Mutex<T> {
441
441
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
442
442
impl < T : ?Sized + fmt:: Debug > fmt:: Debug for Mutex < T > {
443
443
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
444
+ let mut d = f. debug_struct ( "Mutex" ) ;
444
445
match self . try_lock ( ) {
445
- Ok ( guard) => f. debug_struct ( "Mutex" ) . field ( "data" , & & * guard) . finish ( ) ,
446
+ Ok ( guard) => {
447
+ d. field ( "data" , & & * guard) ;
448
+ }
446
449
Err ( TryLockError :: Poisoned ( err) ) => {
447
- f . debug_struct ( "Mutex" ) . field ( "data" , & & * * err. get_ref ( ) ) . finish ( )
450
+ d . field ( "data" , & & * * err. get_ref ( ) ) ;
448
451
}
449
452
Err ( TryLockError :: WouldBlock ) => {
450
453
struct LockedPlaceholder ;
@@ -453,10 +456,11 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
453
456
f. write_str ( "<locked>" )
454
457
}
455
458
}
456
-
457
- f. debug_struct ( "Mutex" ) . field ( "data" , & LockedPlaceholder ) . finish ( )
459
+ d. field ( "data" , & LockedPlaceholder ) ;
458
460
}
459
461
}
462
+ d. field ( "poisoned" , & self . poison . get ( ) ) ;
463
+ d. finish_non_exhaustive ( )
460
464
}
461
465
}
462
466
Original file line number Diff line number Diff line change @@ -422,10 +422,13 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
422
422
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
423
423
impl < T : ?Sized + fmt:: Debug > fmt:: Debug for RwLock < T > {
424
424
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
425
+ let mut d = f. debug_struct ( "RwLock" ) ;
425
426
match self . try_read ( ) {
426
- Ok ( guard) => f. debug_struct ( "RwLock" ) . field ( "data" , & & * guard) . finish ( ) ,
427
+ Ok ( guard) => {
428
+ d. field ( "data" , & & * guard) ;
429
+ }
427
430
Err ( TryLockError :: Poisoned ( err) ) => {
428
- f . debug_struct ( "RwLock" ) . field ( "data" , & & * * err. get_ref ( ) ) . finish ( )
431
+ d . field ( "data" , & & * * err. get_ref ( ) ) ;
429
432
}
430
433
Err ( TryLockError :: WouldBlock ) => {
431
434
struct LockedPlaceholder ;
@@ -434,10 +437,11 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
434
437
f. write_str ( "<locked>" )
435
438
}
436
439
}
437
-
438
- f. debug_struct ( "RwLock" ) . field ( "data" , & LockedPlaceholder ) . finish ( )
440
+ d. field ( "data" , & LockedPlaceholder ) ;
439
441
}
440
442
}
443
+ d. field ( "poisoned" , & self . poison . get ( ) ) ;
444
+ d. finish_non_exhaustive ( )
441
445
}
442
446
}
443
447
You can’t perform that action at this time.
0 commit comments