From 5b682354f2c8bf2c825b6229a6a125435f2053dd Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 26 Dec 2019 19:37:14 +0100 Subject: [PATCH] Fix some minor issues --- src/libpanic_abort/lib.rs | 5 +++-- src/libpanic_unwind/lib.rs | 5 +++-- src/libstd/panicking.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index ebc57860b9d..fe9196ef231 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -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!() } diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 60ddf70cea5..ad82f22510c 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -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 @@ -70,10 +71,10 @@ 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 diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 3dd1f09e076..b02cedd5da5 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -67,7 +67,7 @@ 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` because the other end of this call does not depend @@ -313,7 +313,7 @@ union Data { // non-cold function, though, as of the writing of this comment). #[cold] unsafe fn cleanup(mut payload: Payload) -> Box { - 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 } -- 2.44.0