message: Split error reporting from main eval function
diff: @@ -8,6 +8,7 @@ use rand::SeedableRng;
  use rustc_hir::def_id::DefId;
  use rustc::ty::layout::{LayoutOf, Size};
  use rustc::ty::{self, TyCtxt};
  +use rustc_mir::interpret::InterpErrorInfo;
  use crate::*;
  @@ -205,27 +206,30 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
  }
  return Some(return_code);
  }
  - Err(mut e) => {
  + Err(e) => report_err(&ecx, e),
  + }
  +}
  +
  +fn report_err<'tcx, 'mir>(
  + ecx: &InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
  + mut e: InterpErrorInfo<'tcx>,
  +) -> Option<i64> {
  // Special treatment for some error kinds
  let msg = match e.kind {
  InterpError::MachineStop(ref info) => {
  - let info = info
  - .downcast_ref::<TerminationInfo>()
  - .expect("invalid MachineStop payload");
  + let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
  match info {
  TerminationInfo::Exit(code) => return Some(*code),
  TerminationInfo::PoppedTrackedPointerTag(item) =>
  format!("popped tracked tag for item {:?}", item),
  - TerminationInfo::Abort =>
  - format!("the evaluated program aborted execution"),
  + TerminationInfo::Abort => format!("the evaluated program aborted execution"),
  }
  }
  err_unsup!(NoMirFor(..)) => format!(
  "{}. Did you set `MIRI_SYSROOT` to a Miri-enabled sysroot? You can prepare one with `cargo miri setup`.",
  e
  ),
  - InterpError::InvalidProgram(_) =>
  - bug!("This error should be impossible in Miri: {}", e),
  + InterpError::InvalidProgram(_) => bug!("This error should be impossible in Miri: {}", e),
  _ => e.to_string(),
  };
  e.print_backtrace();
  @@ -264,5 +268,3 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
  // Let the reported error determine the return code.
  return None;
  }
  - }
  -}
  