diff options
| author | joboet <jonasboettiger@icloud.com> | 2025-03-29 12:16:49 +0100 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2025-05-15 11:20:13 +0200 |
| commit | b7f2cd3a2b1606934018cc64bac52bb887ea892a (patch) | |
| tree | fc7da5ba2b2f5caa5ab7c8ba4a6f8f30ff623462 /library/panic_unwind | |
| parent | 414482f6a0d4e7290f614300581a0b55442552a3 (diff) | |
| download | rust-b7f2cd3a2b1606934018cc64bac52bb887ea892a.tar.gz rust-b7f2cd3a2b1606934018cc64bac52bb887ea892a.zip | |
deduplicate abort implementations
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
Diffstat (limited to 'library/panic_unwind')
| -rw-r--r-- | library/panic_unwind/src/hermit.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/library/panic_unwind/src/hermit.rs b/library/panic_unwind/src/hermit.rs index 8f4562d07fc..b36d1a019fd 100644 --- a/library/panic_unwind/src/hermit.rs +++ b/library/panic_unwind/src/hermit.rs @@ -5,20 +5,16 @@ use alloc::boxed::Box; use core::any::Any; +unsafe extern "Rust" { + // This is defined in std::rt + #[rustc_std_internal_symbol] + safe fn __rust_abort() -> !; +} + pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { - unsafe extern "C" { - fn __rust_abort() -> !; - } - unsafe { - __rust_abort(); - } + __rust_abort() } pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { - unsafe extern "C" { - fn __rust_abort() -> !; - } - unsafe { - __rust_abort(); - } + __rust_abort() } |
