Skip to content

Commit fcbe668

Browse files
committed
Make __rust_alloc_error_handler_should_panic a function
1 parent 0cedc03 commit fcbe668

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

alloc/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,10 @@ pub mod __alloc_error_handler {
429429
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
430430
// Its value depends on the -Zoom={panic,abort} compiler option.
431431
#[rustc_std_internal_symbol]
432-
static __rust_alloc_error_handler_should_panic: u8;
432+
fn __rust_alloc_error_handler_should_panic_v2() -> u8;
433433
}
434434

435-
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
435+
if unsafe { __rust_alloc_error_handler_should_panic_v2() != 0 } {
436436
panic!("memory allocation of {size} bytes failed")
437437
} else {
438438
core::panicking::panic_nounwind_fmt(

std/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ fn default_alloc_error_hook(layout: Layout) {
349349
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
350350
// Its value depends on the -Zoom={panic,abort} compiler option.
351351
#[rustc_std_internal_symbol]
352-
static __rust_alloc_error_handler_should_panic: u8;
352+
fn __rust_alloc_error_handler_should_panic_v2() -> u8;
353353
}
354354

355-
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
355+
if unsafe { __rust_alloc_error_handler_should_panic_v2() != 0 } {
356356
panic!("memory allocation of {} bytes failed", layout.size());
357357
} else {
358358
// This is the default path taken on OOM, and the only path taken on stable with std.

0 commit comments

Comments
 (0)