diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index fb2667bf883c2..4c6c728f6f7d4 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -39,9 +39,6 @@ cfg_if::cfg_if! { if #[cfg(miri)] { #[path = "miri.rs"] mod imp; - // Export this at the root of the crate so that Miri - // has a stable palce to look it up - pub use imp::miri_panic_trampoline; } else if #[cfg(target_os = "emscripten")] { #[path = "emcc.rs"] mod imp; diff --git a/src/libpanic_unwind/miri.rs b/src/libpanic_unwind/miri.rs index 2b41d338ce2b1..254a9383b4223 100644 --- a/src/libpanic_unwind/miri.rs +++ b/src/libpanic_unwind/miri.rs @@ -21,8 +21,3 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box { fn rust_eh_personality() { unsafe { core::intrinsics::abort() } } - -// A dummy helper function for Miri. -// Used to push an empty stack frame when we start unwinding -#[cfg(miri)] -pub fn miri_panic_trampoline() {} diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 812774fab8de4..e2d5eec6502e5 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -376,6 +376,8 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, instance: ty::Instance<'tcx>, args: &[OpTy<'tcx>], dest: Option>, + _ret: Option, + _unwind: Option ) -> InterpResult<'tcx> { if ecx.emulate_intrinsic(span, instance, args, dest)? { return Ok(()); diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index fa7b537b4df8d..92358ad247e18 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -585,21 +585,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { "tried to pop a stack frame, but there were none", ); let stack_pop_info = M::stack_pop(self, frame.extra, unwinding)?; - match (unwinding, stack_pop_info) { - (true, StackPopInfo::StartUnwinding) => - bug!("Attempted to start unwinding while already unwinding!"), - (false, StackPopInfo::StopUnwinding) => - bug!("Attempted to stop unwinding while there is no unwinding!"), - _ => {} + if let (false, StackPopInfo::StopUnwinding) = (unwinding, stack_pop_info) { + bug!("Attempted to stop unwinding while there is no unwinding!"); } // Now where do we jump next? // Determine if we leave this function normally or via unwinding. - let cur_unwinding = match stack_pop_info { - StackPopInfo::StartUnwinding => true, - StackPopInfo::StopUnwinding => false, - _ => unwinding + let cur_unwinding = if let StackPopInfo::StopUnwinding = stack_pop_info { + false + } else { + unwinding }; // Usually we want to clean up (deallocate locals), but in a few rare cases we don't. diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 08da5078f43a9..0ddd0962ba544 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -20,10 +20,6 @@ use super::{ /// to provide further control over the popping of the stack frame #[derive(Eq, PartialEq, Debug, Copy, Clone)] pub enum StackPopInfo { - /// Indicates that we have just started unwinding - /// as the result of panic - StartUnwinding, - /// Indicates that no special handling should be /// done - we'll either return normally or unwind /// based on the terminator for the function @@ -177,6 +173,8 @@ pub trait Machine<'mir, 'tcx>: Sized { instance: ty::Instance<'tcx>, args: &[OpTy<'tcx, Self::PointerTag>], dest: Option>, + ret: Option, + unwind: Option, ) -> InterpResult<'tcx>; /// Called for read access to a foreign static item. diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index f77bf56b0575e..f1e1c98e44eb4 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -265,7 +265,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match instance.def { ty::InstanceDef::Intrinsic(..) => { let old_stack = self.cur_frame(); - M::call_intrinsic(self, span, instance, args, dest)?; + M::call_intrinsic(self, span, instance, args, dest, ret, unwind)?; // No stack frame gets pushed, the main loop will just act as if the // call completed. if ret.is_some() { diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 3ee9445f9c0ea..2ede43e2111ed 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -164,6 +164,8 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine { _instance: ty::Instance<'tcx>, _args: &[OpTy<'tcx>], _dest: Option>, + _ret: Option, + _unwind: Option ) -> InterpResult<'tcx> { throw_unsup_format!("calling intrinsics isn't supported in ConstProp"); }