Destructure Rc wrapped ErrorKind in miri

上级 790d131a
......@@ -235,13 +235,15 @@ fn eval_fn_call<'a>(
}
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 @@ pub fn dump_local(&self, place: Place) {
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 @@ pub fn modify_local<F>(&mut self, frame: usize, local: mir::Local, f: F) -> Eval
}
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 @@ fn const_prop(
)
} 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册