Skip to content

Commit

Permalink
Use proper intrinsic type
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Nov 11, 2019
1 parent 848e1d8 commit 5553476
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/libcore/intrinsics.rs
Expand Up @@ -1352,12 +1352,7 @@ extern "rust-intrinsic" {
/// Internal hook used by Miri to implement unwinding.
/// Perma-unstable: do not use
#[cfg(not(bootstrap))]
// 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 [()]) -> !;
pub fn miri_start_panic(data: *mut (dyn crate::any::Any + crate::marker::Send)) -> !;
}

// Some functions are defined here because they accidentally got made
Expand Down
3 changes: 1 addition & 2 deletions src/libpanic_unwind/miri.rs
Expand Up @@ -6,8 +6,7 @@ pub fn payload() -> *mut u8 {
}

pub unsafe fn panic(data: Box<dyn Any + Send>) -> ! {
let raw_val: *mut [()] = core::mem::transmute::<*mut (dyn Any + Send), _>(Box::into_raw(data));
core::intrinsics::miri_start_panic(raw_val)
core::intrinsics::miri_start_panic(Box::into_raw(data))
}

pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/intrinsic.rs
Expand Up @@ -385,7 +385,9 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
}

"miri_start_panic" => {
(0, vec![tcx.mk_mut_ptr(tcx.mk_slice(tcx.mk_unit()))], tcx.types.never)
// TODO - the relevant types aren't lang items,
// so it's not trivial to check this
return;
}

ref other => {
Expand Down

0 comments on commit 5553476

Please sign in to comment.