ignore print!, turn panic! into a EvalError

This commit is contained in:
Oliver Schneider 2017-02-09 10:34:23 +01:00
parent 6aed897c70
commit 250f66562c
2 changed files with 22 additions and 1 deletions

View File

@ -56,6 +56,7 @@ pub enum EvalError<'tcx> {
ExpectedConcreteFunction(Function<'tcx>),
ExpectedDropGlue(Function<'tcx>),
ManuallyCalledDropGlue,
Panic,
}
pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
@ -134,6 +135,8 @@ fn description(&self) -> &str {
"tried to use non-drop-glue function as drop glue",
EvalError::ManuallyCalledDropGlue =>
"tried to manually invoke drop glue",
EvalError::Panic =>
"the evaluated program panicked",
}
}

View File

@ -292,7 +292,25 @@ fn eval_fn_call(
}
}
let mir = self.load_mir(resolved_def_id)?;
let mir = match self.load_mir(resolved_def_id) {
Ok(mir) => mir,
Err(EvalError::NoMirFor(path)) => {
match &path[..] {
// let's just ignore all output for now
"std::io::_print" => {
self.goto_block(destination.unwrap().1);
return Ok(());
},
"std::thread::Builder::new" => return Err(EvalError::Unimplemented("miri does not support threading".to_owned())),
"std::env::args" => return Err(EvalError::Unimplemented("miri does not support program arguments".to_owned())),
"std::panicking::rust_panic_with_hook" |
"std::rt::begin_panic_fmt" => return Err(EvalError::Panic),
_ => {},
}
return Err(EvalError::NoMirFor(path));
},
Err(other) => return Err(other),
};
let (return_lvalue, return_to_block) = match destination {
Some((lvalue, block)) => (lvalue, StackPopCleanup::Goto(block)),
None => {