1 //! Unwinding panics for Miri.
5 // The type of the payload that the Miri engine propagates through unwinding for us.
6 // Must be pointer-sized.
7 type Payload = Box<Box<dyn Any + Send>>;
10 /// Miri-provided extern function to begin unwinding.
11 fn miri_start_panic(payload: *mut u8) -> !;
14 pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 {
15 // The payload we pass to `miri_start_panic` will be exactly the argument we get
16 // in `cleanup` below. So we just box it up once, to get something pointer-sized.
17 let payload_box: Payload = Box::new(payload);
18 miri_start_panic(Box::into_raw(payload_box) as *mut u8)
21 pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> {
22 // Recover the underlying `Box`.
23 let payload_box: Payload = Box::from_raw(payload_box as *mut _);