diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-06-19 16:40:53 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-06-28 11:01:35 +0200 |
| commit | 6f8fe4eaefe8fbc4f8a8d314ded0fe1a300c35f7 (patch) | |
| tree | d30de39e4968155f811cae2e927f87b92fe56c94 /src/librustc_mir/interpret | |
| parent | 58fdac638ea57f60bb2bea4b35f8fc5988df9387 (diff) | |
| download | rust-6f8fe4eaefe8fbc4f8a8d314ded0fe1a300c35f7.tar.gz rust-6f8fe4eaefe8fbc4f8a8d314ded0fe1a300c35f7.zip | |
Eliminate old CTFE's `ErrKind`
Diffstat (limited to 'src/librustc_mir/interpret')
| -rw-r--r-- | src/librustc_mir/interpret/const_eval.rs | 16 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 4 |
3 files changed, 10 insertions, 14 deletions
diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index 592c9dbe6ff..831b3bfd8d1 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -1,6 +1,5 @@ use rustc::hir; -use rustc::middle::const_val::{ConstEvalErr, ErrKind}; -use rustc::middle::const_val::ErrKind::{TypeckError, CheckMatchError}; +use rustc::middle::const_val::{ConstEvalErr}; use rustc::mir; use rustc::ty::{self, TyCtxt, Ty, Instance}; use rustc::ty::layout::{self, LayoutOf, Primitive}; @@ -18,7 +17,6 @@ use super::{Place, EvalContext, StackPopCleanup, ValTy, PlaceExtra, Memory, Memo use std::fmt; use std::error::Error; -use rustc_data_structures::sync::Lrc; pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -106,7 +104,7 @@ pub fn value_to_const_value<'tcx>( let (frames, span) = ecx.generate_stacktrace(None); let err = ConstEvalErr { span, - kind: ErrKind::Miri(err, frames).into(), + data: (err, frames).into(), }; err.report_as_error( ecx.tcx, @@ -467,9 +465,8 @@ pub fn const_val_field<'a, 'tcx>( })(); result.map_err(|err| { let (trace, span) = ecx.generate_stacktrace(None); - let err = ErrKind::Miri(err, trace); ConstEvalErr { - kind: err.into(), + data: (err, trace).into(), span, } }) @@ -540,7 +537,7 @@ pub fn const_eval_provider<'a, 'tcx>( // Do match-check before building MIR if tcx.check_match(def_id).is_err() { return Err(ConstEvalErr { - kind: Lrc::new(CheckMatchError), + data: (EvalErrorKind::CheckMatchError.into(), Vec::new()).into(), span, }); } @@ -552,7 +549,7 @@ pub fn const_eval_provider<'a, 'tcx>( // Do not continue into miri if typeck errors occurred; it will fail horribly if tables.tainted_by_errors { return Err(ConstEvalErr { - kind: Lrc::new(TypeckError), + data: (EvalErrorKind::TypeckError.into(), Vec::new()).into(), span, }); } @@ -566,9 +563,8 @@ pub fn const_eval_provider<'a, 'tcx>( Ok(value_to_const_value(&ecx, val, miri_ty)) }).map_err(|err| { let (trace, span) = ecx.generate_stacktrace(None); - let err = ErrKind::Miri(err, trace); let err = ConstEvalErr { - kind: err.into(), + data: (err, trace).into(), span, }; if tcx.is_static(def_id).is_some() { diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index ea667273ece..32ec48e15b4 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -280,7 +280,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M self.param_env, def_id, substs, - ).ok_or_else(|| EvalErrorKind::TypeckError.into()) // turn error prop into a panic to expose associated type in const issue + ).ok_or_else(|| EvalErrorKind::ResolutionFailed.into()) } pub(super) fn type_is_sized(&self, ty: Ty<'tcx>) -> bool { @@ -739,7 +739,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M self.param_env, def_id, substs, - ).ok_or_else(|| EvalErrorKind::TypeckError.into()); + ).ok_or_else(|| EvalErrorKind::ResolutionFailed.into()); let fn_ptr = self.memory.create_fn_alloc(instance?); let valty = ValTy { value: Value::Scalar(fn_ptr.into()), diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index ad571fbe90d..3810aedb90c 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -285,10 +285,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { instance, promoted: None, }; - self.tcx.const_eval(ParamEnv::reveal_all().and(gid)).map_err(|_| { + self.tcx.const_eval(ParamEnv::reveal_all().and(gid)).map_err(|err| { // no need to report anything, the const_eval call takes care of that for statics assert!(self.tcx.is_static(def_id).is_some()); - EvalErrorKind::TypeckError.into() + EvalErrorKind::ReferencedConstant(err).into() }).map(|val| { let const_val = match val.val { ConstVal::Value(val) => val, |
