Skip to content

Commit

Permalink
add Miri error variant for process exit
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 19, 2019
1 parent a2bbf7d commit dec2447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/librustc/mir/interpret/error.rs
Expand Up @@ -229,6 +229,10 @@ pub enum InterpError<'tcx, O> {
/// match an existing variant.
MachineError(String),

/// Not actually an interprer error -- used to signal that execution has exited
/// with the given status code.
Exit(i32),

FunctionAbiMismatch(Abi, Abi),
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
Expand Down Expand Up @@ -317,6 +321,8 @@ impl<'tcx, O> InterpError<'tcx, O> {
use self::InterpError::*;
match *self {
MachineError(ref inner) => inner,
Exit(..) =>
"exited",
FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..)
| FunctionArgCountMismatch =>
"tried to call a function through a function pointer of incompatible type",
Expand Down Expand Up @@ -515,6 +521,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
InvalidDiscriminant(val) =>
write!(f, "encountered invalid enum discriminant {}", val),
Exit(code) =>
write!(f, "exited with status code {}", code),
_ => write!(f, "{}", self.description()),
}
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/transform/const_prop.rs
Expand Up @@ -148,6 +148,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
match diagnostic.error {
// don't report these, they make no sense in a const prop context
| MachineError(_)
| Exit(_)
// at runtime these transformations might make sense
// FIXME: figure out the rules and start linting
| FunctionAbiMismatch(..)
Expand Down

0 comments on commit dec2447

Please sign in to comment.