1
Fork 0

Destructure Rc wrapped ErrorKind in miri

This commit is contained in:
Oliver Schneider 2018-01-25 14:15:56 +01:00
parent 790d131ac2
commit 2f2c90e733
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
3 changed files with 15 additions and 16 deletions

View file

@ -235,13 +235,15 @@ impl<'mir, 'tcx> super::Machine<'mir, 'tcx> for CompileTimeEvaluator {
} }
let mir = match ecx.load_mir(instance.def) { let mir = match ecx.load_mir(instance.def) {
Ok(mir) => mir, Ok(mir) => mir,
Err(EvalError { kind: EvalErrorKind::NoMirFor(path), .. }) => { Err(err) => {
return Err( if let EvalErrorKind::NoMirFor(ref path) = *err.kind {
ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path)) return Err(
.into(), ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
); .into(),
);
}
return Err(err);
} }
Err(other) => return Err(other),
}; };
let (return_place, return_to_block) = match destination { let (return_place, return_to_block) = match destination {
Some((place, block)) => (place, StackPopCleanup::Goto(block)), Some((place, block)) => (place, StackPopCleanup::Goto(block)),

View file

@ -1513,11 +1513,12 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
write!(msg, ":").unwrap(); write!(msg, ":").unwrap();
match self.stack[frame].get_local(local) { match self.stack[frame].get_local(local) {
Err(EvalError { kind: EvalErrorKind::DeadLocal, .. }) => {
write!(msg, " is dead").unwrap();
}
Err(err) => { Err(err) => {
panic!("Failed to access local: {:?}", err); if let EvalErrorKind::DeadLocal = *err.kind {
write!(msg, " is dead").unwrap();
} else {
panic!("Failed to access local: {:?}", err);
}
} }
Ok(Value::ByRef(ptr, align)) => { Ok(Value::ByRef(ptr, align)) => {
match ptr.into_inner_primval() { match ptr.into_inner_primval() {
@ -1576,7 +1577,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
} }
pub fn report(&self, e: &mut EvalError, as_err: bool, explicit_span: Option<Span>) { pub fn report(&self, e: &mut EvalError, as_err: bool, explicit_span: Option<Span>) {
if let EvalErrorKind::TypeckError = e.kind { if let EvalErrorKind::TypeckError = *e.kind {
return; return;
} }
if let Some(ref mut backtrace) = e.backtrace { if let Some(ref mut backtrace) = e.backtrace {

View file

@ -362,12 +362,8 @@ impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
) )
} else { } else {
if overflow { if overflow {
use rustc::mir::interpret::EvalError;
use rustc::mir::interpret::EvalErrorKind; use rustc::mir::interpret::EvalErrorKind;
let mut err = EvalError { let mut err = EvalErrorKind::OverflowingMath.into();
kind: EvalErrorKind::OverflowingMath,
backtrace: None,
};
ecx.report(&mut err, false, Some(span)); ecx.report(&mut err, false, Some(span));
return None; return None;
} }