mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
slightly more typed interface to panic implementation
This commit is contained in:
parent
463ce40428
commit
29bed26036
|
@ -14,11 +14,13 @@
|
|||
#![feature(core_intrinsics)]
|
||||
#![feature(nll)]
|
||||
#![feature(panic_runtime)]
|
||||
#![feature(std_internals)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(asm)]
|
||||
|
||||
use core::any::Any;
|
||||
use core::panic::BoxMeUp;
|
||||
|
||||
#[rustc_std_internal_symbol]
|
||||
#[allow(improper_ctypes_definitions)]
|
||||
|
@ -28,7 +30,7 @@
|
|||
|
||||
// "Leak" the payload and shim to the relevant abort on the platform in question.
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
|
||||
pub unsafe extern "C" fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
abort();
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
|
|
|
@ -104,8 +104,7 @@
|
|||
// implementation.
|
||||
#[rustc_std_internal_symbol]
|
||||
#[unwind(allowed)]
|
||||
pub unsafe extern "C" fn __rust_start_panic(payload: usize) -> u32 {
|
||||
let payload = payload as *mut &mut dyn BoxMeUp;
|
||||
pub unsafe extern "C" fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
let payload = (*payload).take_box();
|
||||
|
||||
imp::panic(Box::from_raw(payload))
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
/// It cannot be `Box<dyn BoxMeUp>` because the other end of this call does not depend
|
||||
/// on liballoc, and thus cannot use `Box`.
|
||||
#[unwind(allowed)]
|
||||
fn __rust_start_panic(payload: usize) -> u32;
|
||||
fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32;
|
||||
}
|
||||
|
||||
/// This function is called by the panic runtime if FFI code catches a Rust
|
||||
|
@ -637,7 +637,7 @@ fn get(&mut self) -> &(dyn Any + Send) {
|
|||
fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! {
|
||||
let code = unsafe {
|
||||
let obj = &mut msg as *mut &mut dyn BoxMeUp;
|
||||
__rust_start_panic(obj as usize)
|
||||
__rust_start_panic(obj)
|
||||
};
|
||||
rtabort!("failed to initiate panic, error {}", code)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue