File tree 5 files changed +12
-11
lines changed
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) {
315
315
}
316
316
317
317
fn 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( ) ) ;
319
319
}
320
320
321
321
#[ cfg( not( test) ) ]
Original file line number Diff line number Diff line change @@ -596,15 +596,12 @@ fn rust_panic_with_hook(
596
596
if panics > 2 {
597
597
// Don't try to print the message in this case
598
598
// - 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 " ) ;
600
600
} else {
601
601
// Unfortunately, this does not print a backtrace, because creating
602
602
// a `Backtrace` will allocate, which we must to avoid here.
603
603
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) ;
608
605
}
609
606
intrinsics:: abort ( )
610
607
}
@@ -637,7 +634,7 @@ fn rust_panic_with_hook(
637
634
// have limited options. Currently our preference is to
638
635
// just abort. In the future we may consider resuming
639
636
// unwinding or otherwise exiting the thread cleanly.
640
- rterr ! ( "thread panicked while panicking. aborting.\n " ) ;
637
+ rtprintpanic ! ( "thread panicked while panicking. aborting.\n " ) ;
641
638
intrinsics:: abort ( )
642
639
}
643
640
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ mod imp {
102
102
// If the faulting address is within the guard page, then we print a
103
103
// message saying so and abort.
104
104
if guard. start <= addr && addr < guard. end {
105
- rterr ! (
105
+ rtprintpanic ! (
106
106
"\n thread '{}' has overflowed its stack\n " ,
107
107
thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
108
108
) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
24
24
let code = rec. ExceptionCode ;
25
25
26
26
if code == c:: EXCEPTION_STACK_OVERFLOW {
27
- rterr ! (
27
+ rtprintpanic ! (
28
28
"\n thread '{}' has overflowed its stack\n " ,
29
29
thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
30
30
) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ pub fn cleanup() {
39
39
} ) ;
40
40
}
41
41
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 {
43
47
( $( $t: tt) * ) => {
44
48
if let Some ( mut out) = crate :: sys:: stdio:: panic_output( ) {
45
49
let _ = crate :: io:: Write :: write_fmt( & mut out, format_args!( $( $t) * ) ) ;
@@ -50,7 +54,7 @@ macro_rules! rterr {
50
54
macro_rules! rtabort {
51
55
( $( $t: tt) * ) => {
52
56
{
53
- rterr !( "fatal runtime error: {}\n " , format_args!( $( $t) * ) ) ;
57
+ rtprintpanic !( "fatal runtime error: {}\n " , format_args!( $( $t) * ) ) ;
54
58
crate :: sys:: abort_internal( ) ;
55
59
}
56
60
}
You can’t perform that action at this time.
0 commit comments