Skip to content

Commit 6f032b5

Browse files
committed
Fix some minor issues
1 parent 2df8e22 commit 6f032b5

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
@@ -32,6 +32,7 @@
3232
#![feature(panic_runtime)]
3333

3434
use alloc::boxed::Box;
35+
use core::any::Any;
3536
use core::panic::BoxMeUp;
3637

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

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

7980
// 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
@@ -313,7 +313,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
313313
// non-cold function, though, as of the writing of this comment).
314314
#[cold]
315315
unsafe fn cleanup(mut payload: Payload) -> Box<dyn Any + Send + 'static> {
316-
let obj = crate::mem::transmute(__rust_panic_cleanup(&mut payload as *mut _ as *mut u8));
316+
let obj = Box::from_raw(__rust_panic_cleanup(&mut payload as *mut _ as *mut u8));
317317
update_panic_count(-1);
318318
obj
319319
}

0 commit comments

Comments
 (0)