Skip to content

Commit

Permalink
Fix some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Mar 2, 2020
1 parent bdcc023 commit 5b68235
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/libpanic_abort/lib.rs
Expand Up @@ -17,10 +17,11 @@
#![feature(panic_runtime)]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![feature(raw)]

use core::any::Any;

#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rust_cleanup(_: *mut u8) -> core::raw::TraitObject {
pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Send + 'static) {
unreachable!()
}

Expand Down
5 changes: 3 additions & 2 deletions src/libpanic_unwind/lib.rs
Expand Up @@ -32,6 +32,7 @@
#![feature(panic_runtime)]

use alloc::boxed::Box;
use core::any::Any;
use core::panic::BoxMeUp;

// If adding to this list, you should also look at libstd::panicking's identical
Expand Down Expand Up @@ -70,10 +71,10 @@ extern "C" {
mod dwarf;

#[no_mangle]
pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> core::raw::TraitObject {
pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) {
let payload = payload as *mut imp::Payload;
let payload = *(payload);
core::mem::transmute(imp::cleanup(payload))
Box::into_raw(imp::cleanup(payload))
}

// Entry point for raising an exception, just delegates to the platform-specific
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/panicking.rs
Expand Up @@ -67,7 +67,7 @@ cfg_if::cfg_if! {
extern "C" {
/// The payload ptr here is actually the same as the payload ptr for the try
/// intrinsic (i.e., is really `*mut [u64; 2]` or `*mut *mut u8`).
fn __rust_panic_cleanup(payload: *mut u8) -> core::raw::TraitObject;
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);

/// `payload` is actually a `*mut &mut dyn BoxMeUp` but that would cause FFI warnings.
/// It cannot be `Box<dyn BoxMeUp>` because the other end of this call does not depend
Expand Down Expand Up @@ -313,7 +313,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
// non-cold function, though, as of the writing of this comment).
#[cold]
unsafe fn cleanup(mut payload: Payload) -> Box<dyn Any + Send + 'static> {
let obj = crate::mem::transmute(__rust_panic_cleanup(&mut payload as *mut _ as *mut u8));
let obj = Box::from_raw(__rust_panic_cleanup(&mut payload as *mut _ as *mut u8));
update_panic_count(-1);
obj
}
Expand Down

0 comments on commit 5b68235

Please sign in to comment.