This commit is contained in:
Oliver Schneider 2018-07-01 16:01:42 +02:00
parent 9143a69f4b
commit e1dbbe538f
2 changed files with 4 additions and 6 deletions

View File

@ -24,7 +24,6 @@ use rustc::ty::layout::{TyLayout, LayoutOf, Size};
use rustc::ty::subst::Subst;
use rustc::hir::def_id::DefId;
use rustc::mir;
use rustc::middle::const_val;
use syntax::ast::Mutability;
use syntax::codemap::Span;
@ -270,10 +269,10 @@ pub fn eval_main<'a, 'tcx: 'a>(
block.terminator().source_info.span
};
let mut err = const_val::struct_error(ecx.tcx.tcx.at(span), "constant evaluation error");
let mut err = mir::interpret::struct_error(ecx.tcx.tcx.at(span), "constant evaluation error");
let (frames, span) = ecx.generate_stacktrace(None);
err.span_label(span, e.to_string());
for const_val::FrameInfo { span, location, .. } in frames {
for mir::interpret::FrameInfo { span, location, .. } in frames {
err.span_note(span, &format!("inside call to `{}`", location));
}
err.emit();

View File

@ -8,7 +8,6 @@ use rustc::ty::subst::{Substs, Subst};
use rustc::traits::{self, TraitEngine};
use rustc::infer::InferCtxt;
use rustc::middle::region;
use rustc::middle::const_val::ConstVal;
use rustc_data_structures::indexed_vec::Idx;
use rustc_mir::interpret::HasMemory;
@ -719,14 +718,14 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
}
TyArray(elem_ty, len) => {
let len = match len.val {
ConstVal::Unevaluated(def_id, substs) => {
mir::interpret::ConstValue::Unevaluated(def_id, substs) => {
self.tcx.const_eval(self.tcx.param_env(def_id).and(GlobalId {
instance: Instance::new(def_id, substs),
promoted: None,
}))
.map_err(|_err|EvalErrorKind::MachineError("<already reported>".to_string()))?
}
ConstVal::Value(_) => len,
_ => len,
};
let len = len.unwrap_usize(self.tcx.tcx);
for i in 0..len {