Skip to content

Commit 4ad9a3c

Browse files
committed
Fix some minor issues
1 parent 5e320df commit 4ad9a3c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/libpanic_abort/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#![feature(panic_runtime)]
1818
#![feature(staged_api)]
1919
#![feature(rustc_attrs)]
20-
#![feature(raw)]
20+
21+
use core::any::Any;
2122

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

src/libpanic_unwind/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![feature(panic_runtime)]
3232

3333
use alloc::boxed::Box;
34+
use core::any::Any;
3435
use core::panic::BoxMeUp;
3536

3637
// If adding to this list, you should also look at libstd::panicking's identical
@@ -63,10 +64,10 @@ cfg_if::cfg_if! {
6364
mod dwarf;
6465

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

7273
// Entry point for raising an exception, just delegates to the platform-specific

src/libstd/panicking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cfg_if::cfg_if! {
6767
extern "C" {
6868
/// The payload ptr here is actually the same as the payload ptr for the try
6969
/// intrinsic (i.e., is really `*mut [u64; 2]` or `*mut *mut u8`).
70-
fn __rust_panic_cleanup(payload: *mut u8) -> core::raw::TraitObject;
70+
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
7171

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

0 commit comments

Comments
 (0)