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) {
|
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)),
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue