File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,21 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
315315}
316316
317317fn default_alloc_error_hook ( layout : Layout ) {
318- rtprintpanic ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
318+ #[ cfg( not( bootstrap) ) ]
319+ extern "Rust" {
320+ // This symbol is emitted by rustc next to __rust_alloc_error_handler.
321+ // Its value depends on the -Zoom={panic,abort} compiler option.
322+ static __rust_alloc_error_handler_should_panic: u8 ;
323+ }
324+ #[ cfg( bootstrap) ]
325+ let __rust_alloc_error_handler_should_panic = 0 ;
326+
327+ #[ allow( unused_unsafe) ]
328+ if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
329+ panic ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
330+ } else {
331+ rtprintpanic ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
332+ }
319333}
320334
321335#[ cfg( not( test) ) ]
You can’t perform that action at this time.
0 commit comments