File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -905,6 +905,10 @@ impl fmt::Debug for StderrLock<'_> {
905905#[ doc( hidden) ]
906906pub fn set_panic ( sink : Option < Box < dyn Write + Send > > ) -> Option < Box < dyn Write + Send > > {
907907 use crate :: mem;
908+ if sink. is_none ( ) && !LOCAL_STREAMS . load ( Ordering :: Relaxed ) {
909+ // LOCAL_STDERR is definitely None since LOCAL_STREAMS is false.
910+ return None ;
911+ }
908912 let s = LOCAL_STDERR . with ( move |slot| mem:: replace ( & mut * slot. borrow_mut ( ) , sink) ) . and_then (
909913 |mut s| {
910914 let _ = s. flush ( ) ;
@@ -932,6 +936,10 @@ pub fn set_panic(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write +
932936#[ doc( hidden) ]
933937pub fn set_print ( sink : Option < Box < dyn Write + Send > > ) -> Option < Box < dyn Write + Send > > {
934938 use crate :: mem;
939+ if sink. is_none ( ) && !LOCAL_STREAMS . load ( Ordering :: Relaxed ) {
940+ // LOCAL_STDOUT is definitely None since LOCAL_STREAMS is false.
941+ return None ;
942+ }
935943 let s = LOCAL_STDOUT . with ( move |slot| mem:: replace ( & mut * slot. borrow_mut ( ) , sink) ) . and_then (
936944 |mut s| {
937945 let _ = s. flush ( ) ;
You can’t perform that action at this time.
0 commit comments