Destructure Rc wrapped ErrorKind in miri
This commit is contained in:
parent
790d131ac2
commit
2f2c90e733
3 changed files with 15 additions and 16 deletions
|
@ -235,13 +235,15 @@ impl<'mir, 'tcx> super::Machine<'mir, 'tcx> for CompileTimeEvaluator {
|
|||
}
|
||||
let mir = match ecx.load_mir(instance.def) {
|
||||
Ok(mir) => mir,
|
||||
Err(EvalError { kind: EvalErrorKind::NoMirFor(path), .. }) => {
|
||||
return Err(
|
||||
ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
|
||||
.into(),
|
||||
);
|
||||
Err(err) => {
|
||||
if let EvalErrorKind::NoMirFor(ref path) = *err.kind {
|
||||
return Err(
|
||||
ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
return Err(err);
|
||||
}
|
||||
Err(other) => return Err(other),
|
||||
};
|
||||
let (return_place, return_to_block) = match destination {
|
||||
Some((place, block)) => (place, StackPopCleanup::Goto(block)),
|
||||
|
|
|
@ -1513,11 +1513,12 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
|||
write!(msg, ":").unwrap();
|
||||
|
||||
match self.stack[frame].get_local(local) {
|
||||
Err(EvalError { kind: EvalErrorKind::DeadLocal, .. }) => {
|
||||
write!(msg, " is dead").unwrap();
|
||||
}
|
||||
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)) => {
|
||||
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>) {
|
||||
if let EvalErrorKind::TypeckError = e.kind {
|
||||
if let EvalErrorKind::TypeckError = *e.kind {
|
||||
return;
|
||||
}
|
||||
if let Some(ref mut backtrace) = e.backtrace {
|
||||
|
|
|
@ -362,12 +362,8 @@ impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
|
|||
)
|
||||
} else {
|
||||
if overflow {
|
||||
use rustc::mir::interpret::EvalError;
|
||||
use rustc::mir::interpret::EvalErrorKind;
|
||||
let mut err = EvalError {
|
||||
kind: EvalErrorKind::OverflowingMath,
|
||||
backtrace: None,
|
||||
};
|
||||
let mut err = EvalErrorKind::OverflowingMath.into();
|
||||
ecx.report(&mut err, false, Some(span));
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue