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