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