File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -712,9 +712,31 @@ pub fn _eprint(args: fmt::Arguments) {
712712
713713#[ cfg( test) ]
714714mod tests {
715+ use panic:: { UnwindSafe , RefUnwindSafe } ;
715716 use thread;
716717 use super :: * ;
717718
719+ #[ test]
720+ fn stdout_unwind_safe ( ) {
721+ assert_unwind_safe :: < Stdout > ( ) ;
722+ }
723+ #[ test]
724+ fn stdoutlock_unwind_safe ( ) {
725+ assert_unwind_safe :: < StdoutLock > ( ) ;
726+ assert_unwind_safe :: < StdoutLock < ' static > > ( ) ;
727+ }
728+ #[ test]
729+ fn stderr_unwind_safe ( ) {
730+ assert_unwind_safe :: < Stderr > ( ) ;
731+ }
732+ #[ test]
733+ fn stderrlock_unwind_safe ( ) {
734+ assert_unwind_safe :: < StderrLock > ( ) ;
735+ assert_unwind_safe :: < StderrLock < ' static > > ( ) ;
736+ }
737+
738+ fn assert_unwind_safe < T : UnwindSafe + RefUnwindSafe > ( ) { }
739+
718740 #[ test]
719741 #[ cfg_attr( target_os = "emscripten" , ignore) ]
720742 fn panic_doesnt_poison ( ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use marker;
1313use ops:: Deref ;
1414use sys_common:: poison:: { self , TryLockError , TryLockResult , LockResult } ;
1515use sys:: mutex as sys;
16+ use panic:: { UnwindSafe , RefUnwindSafe } ;
1617
1718/// A re-entrant mutual exclusion
1819///
@@ -28,6 +29,9 @@ pub struct ReentrantMutex<T> {
2829unsafe impl < T : Send > Send for ReentrantMutex < T > { }
2930unsafe impl < T : Send > Sync for ReentrantMutex < T > { }
3031
32+ impl < T > UnwindSafe for ReentrantMutex < T > { }
33+ impl < T > RefUnwindSafe for ReentrantMutex < T > { }
34+
3135
3236/// An RAII implementation of a "scoped lock" of a mutex. When this structure is
3337/// dropped (falls out of scope), the lock will be unlocked.
You can’t perform that action at this time.
0 commit comments