Skip to content

Commit 9224be5

Browse files
committed
Auto merge of #60116 - RalfJung:miri-exit, r=oli-obk
add Miri error variant for process exit This is to support rust-lang/miri#702 r? @oli-obk
2 parents c3a7194 + 79b91b7 commit 9224be5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/librustc/mir/interpret/error.rs

+8
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ pub enum InterpError<'tcx, O> {
229229
/// match an existing variant.
230230
MachineError(String),
231231

232+
/// Not actually an interpreter error -- used to signal that execution has exited
233+
/// with the given status code. Used by Miri, but not by CTFE.
234+
Exit(i32),
235+
232236
FunctionAbiMismatch(Abi, Abi),
233237
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
234238
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
@@ -317,6 +321,8 @@ impl<'tcx, O> InterpError<'tcx, O> {
317321
use self::InterpError::*;
318322
match *self {
319323
MachineError(ref inner) => inner,
324+
Exit(..) =>
325+
"exited",
320326
FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..)
321327
| FunctionArgCountMismatch =>
322328
"tried to call a function through a function pointer of incompatible type",
@@ -515,6 +521,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
515521
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
516522
InvalidDiscriminant(val) =>
517523
write!(f, "encountered invalid enum discriminant {}", val),
524+
Exit(code) =>
525+
write!(f, "exited with status code {}", code),
518526
_ => write!(f, "{}", self.description()),
519527
}
520528
}

src/librustc_mir/transform/const_prop.rs

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
148148
match diagnostic.error {
149149
// don't report these, they make no sense in a const prop context
150150
| MachineError(_)
151+
| Exit(_)
151152
// at runtime these transformations might make sense
152153
// FIXME: figure out the rules and start linting
153154
| FunctionAbiMismatch(..)

0 commit comments

Comments
 (0)