diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 0cfe5595af5..9a4c81f699b 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -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 diff --git a/src/libpanic_unwind/miri.rs b/src/libpanic_unwind/miri.rs index 3b4203c3c6d..90fd5cafc37 100644 --- a/src/libpanic_unwind/miri.rs +++ b/src/libpanic_unwind/miri.rs @@ -6,7 +6,7 @@ pub fn payload() -> *mut u8 { } pub unsafe fn panic(data: Box) -> ! { - 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 { 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() } +} diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 24b589df63a..50985a3a232 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -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 => {