mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
Remove unnecessary raw pointer in __rust_start_panic arg
It is no longer necessary as __rust_start_panic switched to the Rust abi.
This commit is contained in:
parent
89c2e3d3d7
commit
b874502a20
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
// Weakly resolve the symbol for android_set_abort_message. This function is only available
|
||||
// for API >= 21.
|
||||
pub(crate) unsafe fn android_set_abort_message(payload: *mut &mut dyn BoxMeUp) {
|
||||
pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn BoxMeUp) {
|
||||
let func_addr =
|
||||
libc::dlsym(libc::RTLD_DEFAULT, ANDROID_SET_ABORT_MESSAGE.as_ptr() as *const libc::c_char)
|
||||
as usize;
|
||||
|
@ -23,7 +23,7 @@ pub(crate) unsafe fn android_set_abort_message(payload: *mut &mut dyn BoxMeUp) {
|
|||
return;
|
||||
}
|
||||
|
||||
let payload = (*payload).get();
|
||||
let payload = payload.get();
|
||||
let msg = match payload.downcast_ref::<&'static str>() {
|
||||
Some(msg) => msg.as_bytes(),
|
||||
None => match payload.downcast_ref::<String>() {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
// "Leak" the payload and shim to the relevant abort on the platform in question.
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
pub unsafe fn __rust_start_panic(_payload: &mut dyn BoxMeUp) -> u32 {
|
||||
// Android has the ability to attach a message as part of the abort.
|
||||
#[cfg(target_os = "android")]
|
||||
android::android_set_abort_message(_payload);
|
||||
|
|
|
@ -99,8 +99,8 @@
|
|||
// Entry point for raising an exception, just delegates to the platform-specific
|
||||
// implementation.
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
let payload = Box::from_raw((*payload).take_box());
|
||||
pub unsafe fn __rust_start_panic(payload: &mut dyn BoxMeUp) -> u32 {
|
||||
let payload = Box::from_raw(payload.take_box());
|
||||
|
||||
imp::panic(payload)
|
||||
}
|
||||
|
|
|
@ -46,12 +46,10 @@
|
|||
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
|
||||
}
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
extern "Rust" {
|
||||
/// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not
|
||||
/// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations
|
||||
/// when using the "abort" panic runtime).
|
||||
fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32;
|
||||
/// `BoxMeUp` lazily performs allocation only when needed (this avoids
|
||||
/// allocations when using the "abort" panic runtime).
|
||||
fn __rust_start_panic(payload: &mut dyn BoxMeUp) -> u32;
|
||||
}
|
||||
|
||||
/// This function is called by the panic runtime if FFI code catches a Rust
|
||||
|
@ -738,10 +736,7 @@ fn get(&mut self) -> &(dyn Any + Send) {
|
|||
/// yer breakpoints.
|
||||
#[inline(never)]
|
||||
#[cfg_attr(not(test), rustc_std_internal_symbol)]
|
||||
fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! {
|
||||
let code = unsafe {
|
||||
let obj = &mut msg as *mut &mut dyn BoxMeUp;
|
||||
__rust_start_panic(obj)
|
||||
};
|
||||
fn rust_panic(msg: &mut dyn BoxMeUp) -> ! {
|
||||
let code = unsafe { __rust_start_panic(msg) };
|
||||
rtabort!("failed to initiate panic, error {code}")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue