Skip to content

Commit 998cd52

Browse files
ItsNoHaxsajattack
authored andcommitted
fix: #209 move PanicPayload to alloc::panicking
`PanicPayload` moved out of `core::panic` into `alloc::panicking`, is no longer an unsafe trait, and `take_box` now returns `Box<dyn Any + Send>` instead of a raw pointer.
1 parent 6098b80 commit 998cd52

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

psp/src/panic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use core::{any::Any, mem::ManuallyDrop};
1212
use core::{
1313
any::Any,
1414
mem::{self, ManuallyDrop},
15-
panic::{Location, PanicInfo, PanicMessage, PanicPayload as BoxMeUp},
15+
panic::{Location, PanicInfo, PanicMessage},
1616
};
1717

1818
#[cfg(not(feature = "std"))]
19-
use alloc::{boxed::Box, string::String};
19+
use alloc::{boxed::Box, panicking::PanicPayload as BoxMeUp, string::String};
2020

2121
#[link(name = "unwind", kind = "static")]
2222
extern "C" {}
@@ -74,10 +74,10 @@ fn panic_impl(info: &PanicInfo) -> ! {
7474
}
7575
}
7676

77-
unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
78-
fn take_box(&mut self) -> *mut (dyn Any + Send) {
77+
impl<'a> BoxMeUp for PanicPayload<'a> {
78+
fn take_box(&mut self) -> Box<dyn Any + Send> {
7979
let contents = mem::take(self.fill());
80-
Box::into_raw(Box::new(contents))
80+
Box::new(contents)
8181
}
8282

8383
fn get(&mut self) -> &(dyn Any + Send) {

0 commit comments

Comments
 (0)