print errors in one central location
This commit is contained in:
parent
ba9e25b2eb
commit
fc935c10f8
2 changed files with 4 additions and 16 deletions
|
@ -322,7 +322,7 @@ impl<'a, 'tcx> GlobalEvalContext<'a, 'tcx> {
|
|||
|
||||
#[inline(never)]
|
||||
#[cold]
|
||||
fn report(&self, e: &EvalError) {
|
||||
fn report(&self, e: EvalError) {
|
||||
let stmt = self.frame().stmt;
|
||||
let block = self.basic_block();
|
||||
let span = if stmt < block.statements.len() {
|
||||
|
@ -347,13 +347,6 @@ impl<'a, 'tcx> GlobalEvalContext<'a, 'tcx> {
|
|||
err.emit();
|
||||
}
|
||||
|
||||
fn maybe_report<T>(&self, r: EvalResult<T>) -> EvalResult<T> {
|
||||
if let Err(ref e) = r {
|
||||
self.report(e);
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
fn run(&mut self) -> EvalResult<()> {
|
||||
let mut stepper = stepper::Stepper::new(self);
|
||||
while stepper.step()? {}
|
||||
|
@ -1435,10 +1428,7 @@ pub fn interpret_start_points<'a, 'tcx>(
|
|||
gecx.memory.dump(return_ptr.alloc_id);
|
||||
},
|
||||
Ok(None) => warn!("diverging function returned"),
|
||||
Err(_e) => {
|
||||
// TODO(solson): Detect whether the error was already reported or not.
|
||||
// tcx.sess.err(&e.to_string());
|
||||
}
|
||||
Err(e) => gecx.report(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
|
|||
fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<()> {
|
||||
trace!("{:?}", stmt);
|
||||
let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
|
||||
let result = self.gecx.eval_assignment(lvalue, rvalue);
|
||||
self.gecx.maybe_report(result)?;
|
||||
self.gecx.eval_assignment(lvalue, rvalue)?;
|
||||
self.gecx.frame_mut().stmt += 1;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -42,8 +41,7 @@ impl<'fncx, 'a, 'tcx> Stepper<'fncx, 'a, 'tcx> {
|
|||
// after a terminator we go to a new block
|
||||
self.gecx.frame_mut().stmt = 0;
|
||||
trace!("{:?}", terminator.kind);
|
||||
let result = self.gecx.eval_terminator(terminator);
|
||||
self.gecx.maybe_report(result)?;
|
||||
self.gecx.eval_terminator(terminator)?;
|
||||
if !self.gecx.stack.is_empty() {
|
||||
trace!("// {:?}", self.gecx.frame().next_block);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue