More work on miri_start_panic
This commit is contained in:
parent
fe88fc03c5
commit
848e1d827e
3 changed files with 16 additions and 3 deletions
|
@ -1352,7 +1352,12 @@ extern "rust-intrinsic" {
|
|||
/// Internal hook used by Miri to implement unwinding.
|
||||
/// Perma-unstable: do not use
|
||||
#[cfg(not(bootstrap))]
|
||||
pub fn miri_start_panic(data: u128) -> !;
|
||||
// Note that the type is data is pretty arbitrary:
|
||||
// we just need something that's guarnateed to be a fat
|
||||
// pointer. Using `*mut [()]` instead of the actual type
|
||||
// `*mut (Any + Send)` allows us to avoid making `Any` and `Send`
|
||||
// lang items
|
||||
pub fn miri_start_panic(data: *mut [()]) -> !;
|
||||
}
|
||||
|
||||
// Some functions are defined here because they accidentally got made
|
||||
|
|
|
@ -6,7 +6,7 @@ pub fn payload() -> *mut u8 {
|
|||
}
|
||||
|
||||
pub unsafe fn panic(data: Box<dyn Any + Send>) -> ! {
|
||||
let raw_val = core::mem::transmute::<_, u128>(Box::into_raw(data));
|
||||
let raw_val: *mut [()] = core::mem::transmute::<*mut (dyn Any + Send), _>(Box::into_raw(data));
|
||||
core::intrinsics::miri_start_panic(raw_val)
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,11 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
|
|||
Box::from_raw(ptr)
|
||||
}
|
||||
|
||||
|
||||
// This is required by the compiler to exist (e.g., it's a lang item),
|
||||
// but is never used by Miri. Therefore, we just use a stub here
|
||||
#[lang = "eh_personality"]
|
||||
#[cfg(not(test))]
|
||||
fn rust_eh_personality() {
|
||||
unsafe { core::intrinsics::abort() }
|
||||
}
|
||||
|
|
|
@ -385,7 +385,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
|||
}
|
||||
|
||||
"miri_start_panic" => {
|
||||
(0, vec![tcx.types.u128], tcx.types.never)
|
||||
(0, vec![tcx.mk_mut_ptr(tcx.mk_slice(tcx.mk_unit()))], tcx.types.never)
|
||||
}
|
||||
|
||||
ref other => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue