@@ -357,7 +357,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
357
357
#[ cfg( not( no_global_oom_handling) ) ]
358
358
extern "Rust" {
359
359
// This is the magic symbol to call the global alloc error handler. rustc generates
360
- // it if there is a `#[alloc_error_handler]`, or to the weak implementations below
360
+ // it if there is an `#[alloc_error_handler]`, or to the weak implementations below
361
361
// is called otherwise.
362
362
fn __rust_alloc_error_handler ( size : usize , align : usize ) -> !;
363
363
}
@@ -425,13 +425,16 @@ pub mod __alloc_error_handler {
425
425
#[ rustc_std_internal_symbol]
426
426
#[ linkage = "weak" ]
427
427
pub unsafe extern "Rust" fn __rust_alloc_error_handler ( size : usize , _align : usize ) -> ! {
428
- extern "Rust" {
429
- // This symbol is emitted by rustc next to __rust_alloc_error_handler.
430
- // Its value depends on the -Zoom={panic,abort} compiler option.
431
- static __rust_alloc_error_handler_should_panic: u8 ;
432
- }
433
-
434
- if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
428
+ // This symbol is normally overwritten by rustc next to __rust_alloc_error_handler.
429
+ // However when skipping the allocator handler shim the value here is used which
430
+ // corresponds to -Zoom=abort.
431
+ // Its value depends on the -Zoom={panic,abort} compiler option.
432
+ #[ rustc_std_internal_symbol]
433
+ #[ linkage = "weak" ]
434
+ #[ allow( non_upper_case_globals) ]
435
+ static __rust_alloc_error_handler_should_panic: u8 = 0 ;
436
+
437
+ if __rust_alloc_error_handler_should_panic != 0 {
435
438
panic ! ( "memory allocation of {size} bytes failed" )
436
439
} else {
437
440
core:: panicking:: panic_nounwind_fmt (
0 commit comments