File tree Expand file tree Collapse file tree 5 files changed +12
-11
lines changed Expand file tree Collapse file tree 5 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
315315}
316316
317317fn default_alloc_error_hook ( layout : Layout ) {
318- rterr ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
318+ rtprintpanic ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
319319}
320320
321321#[ cfg( not( test) ) ]
Original file line number Diff line number Diff line change @@ -596,15 +596,12 @@ fn rust_panic_with_hook(
596596 if panics > 2 {
597597 // Don't try to print the message in this case
598598 // - perhaps that is causing the recursive panics.
599- rterr ! ( "thread panicked while processing panic. aborting.\n " ) ;
599+ rtprintpanic ! ( "thread panicked while processing panic. aborting.\n " ) ;
600600 } else {
601601 // Unfortunately, this does not print a backtrace, because creating
602602 // a `Backtrace` will allocate, which we must to avoid here.
603603 let panicinfo = PanicInfo :: internal_constructor ( message, location) ;
604- rterr ! (
605- "{}\n panicked after panic::always_abort(), aborting.\n " ,
606- panicinfo
607- ) ;
604+ rtprintpanic ! ( "{}\n panicked after panic::always_abort(), aborting.\n " , panicinfo) ;
608605 }
609606 intrinsics:: abort ( )
610607 }
@@ -637,7 +634,7 @@ fn rust_panic_with_hook(
637634 // have limited options. Currently our preference is to
638635 // just abort. In the future we may consider resuming
639636 // unwinding or otherwise exiting the thread cleanly.
640- rterr ! ( "thread panicked while panicking. aborting.\n " ) ;
637+ rtprintpanic ! ( "thread panicked while panicking. aborting.\n " ) ;
641638 intrinsics:: abort ( )
642639 }
643640
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ mod imp {
102102 // If the faulting address is within the guard page, then we print a
103103 // message saying so and abort.
104104 if guard. start <= addr && addr < guard. end {
105- rterr ! (
105+ rtprintpanic ! (
106106 "\n thread '{}' has overflowed its stack\n " ,
107107 thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
108108 ) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
2424 let code = rec. ExceptionCode ;
2525
2626 if code == c:: EXCEPTION_STACK_OVERFLOW {
27- rterr ! (
27+ rtprintpanic ! (
2828 "\n thread '{}' has overflowed its stack\n " ,
2929 thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
3030 ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ pub fn cleanup() {
3939 } ) ;
4040}
4141
42- macro_rules! rterr {
42+ // Prints to the "panic output", depending on the platform this may be:
43+ // - the standard error output
44+ // - some dedicated platform specific output
45+ // - nothing (so this macro is a no-op)
46+ macro_rules! rtprintpanic {
4347 ( $( $t: tt) * ) => {
4448 if let Some ( mut out) = crate :: sys:: stdio:: panic_output( ) {
4549 let _ = crate :: io:: Write :: write_fmt( & mut out, format_args!( $( $t) * ) ) ;
@@ -50,7 +54,7 @@ macro_rules! rterr {
5054macro_rules! rtabort {
5155 ( $( $t: tt) * ) => {
5256 {
53- rterr !( "fatal runtime error: {}\n " , format_args!( $( $t) * ) ) ;
57+ rtprintpanic !( "fatal runtime error: {}\n " , format_args!( $( $t) * ) ) ;
5458 crate :: sys:: abort_internal( ) ;
5559 }
5660 }
You can’t perform that action at this time.
0 commit comments