Skip to content

Commit 8a8870f

Browse files
committed
miri: add machine hook for Abort terminator
1 parent 4897594 commit 8a8870f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustc_mir/interpret/machine.rs

+5
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ pub trait Machine<'mir, 'tcx>: Sized {
170170
unwind: Option<mir::BasicBlock>,
171171
) -> InterpResult<'tcx>;
172172

173+
/// Called to evaluate `Abort` MIR terminator.
174+
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
175+
throw_unsup_format!("aborting execution is not supported");
176+
}
177+
173178
/// Called for all binary operations where the LHS has pointer type.
174179
///
175180
/// Returns a (value, overflowed) pair if the operation succeeded

src/librustc_mir/interpret/terminator.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9999
}
100100
}
101101

102+
Abort => {
103+
M::abort(self)?;
104+
}
105+
102106
// When we encounter Resume, we've finished unwinding
103107
// cleanup for the current stack frame. We pop it in order
104108
// to continue unwinding the next frame
@@ -118,8 +122,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
118122
| FalseEdges { .. }
119123
| FalseUnwind { .. }
120124
| Yield { .. }
121-
| GeneratorDrop
122-
| Abort => bug!("{:#?} should have been eliminated by MIR pass", terminator.kind),
125+
| GeneratorDrop => {
126+
bug!("{:#?} should have been eliminated by MIR pass", terminator.kind)
127+
}
123128
}
124129

125130
Ok(())

0 commit comments

Comments
 (0)