diff --git a/src/error.rs b/src/error.rs index f806110190c..bc6510b1f12 100644 --- a/src/error.rs +++ b/src/error.rs @@ -56,6 +56,7 @@ pub enum EvalError<'tcx> { ExpectedConcreteFunction(Function<'tcx>), ExpectedDropGlue(Function<'tcx>), ManuallyCalledDropGlue, + Panic, } pub type EvalResult<'tcx, T = ()> = Result>; @@ -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", } } diff --git a/src/terminator/mod.rs b/src/terminator/mod.rs index e8fe9865783..6f6bb4b5978 100644 --- a/src/terminator/mod.rs +++ b/src/terminator/mod.rs @@ -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 => {