Skip to content

Commit 3c8caac

Browse files
committed
renames EvalErrorKind to InterpError
1 parent eab3eb3 commit 3c8caac

File tree

21 files changed

+73
-73
lines changed

21 files changed

+73
-73
lines changed

src/librustc/mir/interpret/error.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub type ConstEvalResult<'tcx> = Result<ty::Const<'tcx>, ErrorHandled>;
4343
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
4444
pub struct ConstEvalErr<'tcx> {
4545
pub span: Span,
46-
pub error: crate::mir::interpret::EvalErrorKind<'tcx, u64>,
46+
pub error: crate::mir::interpret::InterpError<'tcx, u64>,
4747
pub stacktrace: Vec<FrameInfo<'tcx>>,
4848
}
4949

@@ -135,10 +135,10 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
135135
lint_root: Option<hir::HirId>,
136136
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
137137
match self.error {
138-
EvalErrorKind::Layout(LayoutError::Unknown(_)) |
139-
EvalErrorKind::TooGeneric => return Err(ErrorHandled::TooGeneric),
140-
EvalErrorKind::Layout(LayoutError::SizeOverflow(_)) |
141-
EvalErrorKind::TypeckError => return Err(ErrorHandled::Reported),
138+
InterpError::Layout(LayoutError::Unknown(_)) |
139+
InterpError::TooGeneric => return Err(ErrorHandled::TooGeneric),
140+
InterpError::Layout(LayoutError::SizeOverflow(_)) |
141+
InterpError::TypeckError => return Err(ErrorHandled::Reported),
142142
_ => {},
143143
}
144144
trace!("reporting const eval failure at {:?}", self.span);
@@ -180,7 +180,7 @@ pub fn struct_error<'a, 'gcx, 'tcx>(
180180

181181
#[derive(Debug, Clone)]
182182
pub struct EvalError<'tcx> {
183-
pub kind: EvalErrorKind<'tcx, u64>,
183+
pub kind: InterpError<'tcx, u64>,
184184
pub backtrace: Option<Box<Backtrace>>,
185185
}
186186

@@ -197,8 +197,8 @@ fn print_backtrace(backtrace: &mut Backtrace) {
197197
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
198198
}
199199

200-
impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
201-
fn from(kind: EvalErrorKind<'tcx, u64>) -> Self {
200+
impl<'tcx> From<InterpError<'tcx, u64>> for EvalError<'tcx> {
201+
fn from(kind: InterpError<'tcx, u64>) -> Self {
202202
let backtrace = match env::var("RUST_CTFE_BACKTRACE") {
203203
// matching RUST_BACKTRACE, we treat "0" the same as "not present".
204204
Ok(ref val) if val != "0" => {
@@ -221,10 +221,10 @@ impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
221221
}
222222
}
223223

224-
pub type AssertMessage<'tcx> = EvalErrorKind<'tcx, mir::Operand<'tcx>>;
224+
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
225225

226226
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
227-
pub enum EvalErrorKind<'tcx, O> {
227+
pub enum InterpError<'tcx, O> {
228228
/// This variant is used by machines to signal their own errors that do not
229229
/// match an existing variant.
230230
MachineError(String),
@@ -312,9 +312,9 @@ pub enum EvalErrorKind<'tcx, O> {
312312

313313
pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
314314

315-
impl<'tcx, O> EvalErrorKind<'tcx, O> {
315+
impl<'tcx, O> InterpError<'tcx, O> {
316316
pub fn description(&self) -> &str {
317-
use self::EvalErrorKind::*;
317+
use self::InterpError::*;
318318
match *self {
319319
MachineError(ref inner) => inner,
320320
FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..)
@@ -450,15 +450,15 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
450450
}
451451
}
452452

453-
impl<'tcx> fmt::Display for EvalErrorKind<'tcx, u64> {
453+
impl<'tcx> fmt::Display for InterpError<'tcx, u64> {
454454
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
455455
write!(f, "{:?}", self)
456456
}
457457
}
458458

459-
impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> {
459+
impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
460460
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
461-
use self::EvalErrorKind::*;
461+
use self::InterpError::*;
462462
match *self {
463463
PointerOutOfBounds { ptr, check, allocation_size } => {
464464
write!(f, "Pointer must be in-bounds{} at offset {}, but is outside bounds of \

src/librustc/mir/interpret/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#[macro_export]
44
macro_rules! err {
5-
($($tt:tt)*) => { Err($crate::mir::interpret::EvalErrorKind::$($tt)*.into()) };
5+
($($tt:tt)*) => { Err($crate::mir::interpret::InterpError::$($tt)*.into()) };
66
}
77

88
mod error;
@@ -11,7 +11,7 @@ mod allocation;
1111
mod pointer;
1212

1313
pub use self::error::{
14-
EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstEvalErr, struct_error,
14+
EvalError, EvalResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
1515
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
1616
};
1717

src/librustc/mir/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::hir::def::{CtorKind, Namespace};
66
use crate::hir::def_id::DefId;
77
use crate::hir::{self, HirId, InlineAsm};
8-
use crate::mir::interpret::{ConstValue, EvalErrorKind, Scalar};
8+
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
99
use crate::mir::visit::MirVisitable;
1010
use rustc_apfloat::ieee::{Double, Single};
1111
use rustc_apfloat::Float;
@@ -3226,8 +3226,8 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
32263226
target,
32273227
cleanup,
32283228
} => {
3229-
let msg = if let EvalErrorKind::BoundsCheck { ref len, ref index } = *msg {
3230-
EvalErrorKind::BoundsCheck {
3229+
let msg = if let InterpError::BoundsCheck { ref len, ref index } = *msg {
3230+
InterpError::BoundsCheck {
32313231
len: len.fold_with(folder),
32323232
index: index.fold_with(folder),
32333233
}
@@ -3301,7 +3301,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
33013301
ref cond, ref msg, ..
33023302
} => {
33033303
if cond.visit_with(visitor) {
3304-
if let EvalErrorKind::BoundsCheck { ref len, ref index } = *msg {
3304+
if let InterpError::BoundsCheck { ref len, ref index } = *msg {
33053305
len.visit_with(visitor) || index.visit_with(visitor)
33063306
} else {
33073307
false

src/librustc/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ macro_rules! make_mir_visitor {
560560
fn super_assert_message(&mut self,
561561
msg: & $($mutability)? AssertMessage<'tcx>,
562562
location: Location) {
563-
use crate::mir::interpret::EvalErrorKind::*;
563+
use crate::mir::interpret::InterpError::*;
564564
if let BoundsCheck { len, index } = msg {
565565
self.visit_operand(len, location);
566566
self.visit_operand(index, location);

src/librustc_codegen_ssa/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::middle::lang_items;
22
use rustc::ty::{self, Ty, TypeFoldable};
33
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
44
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
5-
use rustc::mir::interpret::EvalErrorKind;
5+
use rustc::mir::interpret::InterpError;
66
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
77
use rustc_target::spec::abi::Abi;
88
use rustc_mir::monomorphize;
@@ -365,7 +365,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
365365
// checked operation, just a comparison with the minimum
366366
// value, so we have to check for the assert message.
367367
if !bx.check_overflow() {
368-
if let mir::interpret::EvalErrorKind::OverflowNeg = *msg {
368+
if let mir::interpret::InterpError::OverflowNeg = *msg {
369369
const_cond = Some(expected);
370370
}
371371
}
@@ -400,7 +400,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
400400

401401
// Put together the arguments to the panic entry point.
402402
let (lang_item, args) = match *msg {
403-
EvalErrorKind::BoundsCheck { ref len, ref index } => {
403+
InterpError::BoundsCheck { ref len, ref index } => {
404404
let len = self.codegen_operand(&mut bx, len).immediate();
405405
let index = self.codegen_operand(&mut bx, index).immediate();
406406

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
688688
cleanup: _,
689689
} => {
690690
self.consume_operand(ContextKind::Assert.new(loc), (cond, span), flow_state);
691-
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
691+
use rustc::mir::interpret::InterpError::BoundsCheck;
692692
if let BoundsCheck { ref len, ref index } = *msg {
693693
self.consume_operand(ContextKind::Assert.new(loc), (len, span), flow_state);
694694
self.consume_operand(ContextKind::Assert.new(loc), (index, span), flow_state);

src/librustc_mir/borrow_check/nll/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
215215
cleanup: _,
216216
} => {
217217
self.consume_operand(ContextKind::Assert.new(location), cond);
218-
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
218+
use rustc::mir::interpret::InterpError::BoundsCheck;
219219
if let BoundsCheck { ref len, ref index } = *msg {
220220
self.consume_operand(ContextKind::Assert.new(location), len);
221221
self.consume_operand(ContextKind::Assert.new(location), index);

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc::infer::canonical::QueryRegionConstraint;
2828
use rustc::infer::outlives::env::RegionBoundPairs;
2929
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
3030
use rustc::infer::type_variable::TypeVariableOrigin;
31-
use rustc::mir::interpret::{EvalErrorKind::BoundsCheck, ConstValue};
31+
use rustc::mir::interpret::{InterpError::BoundsCheck, ConstValue};
3232
use rustc::mir::tcx::PlaceTy;
3333
use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext};
3434
use rustc::mir::*;

src/librustc_mir/build/expr/as_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::build::expr::category::Category;
44
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
55
use crate::build::{BlockAnd, BlockAndExtension, Builder};
66
use crate::hair::*;
7-
use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
7+
use rustc::mir::interpret::InterpError::BoundsCheck;
88
use rustc::mir::*;
99
use rustc::ty::{CanonicalUserTypeAnnotation, Variance};
1010

src/librustc_mir/build/expr/as_rvalue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::build::expr::category::{Category, RvalueFunc};
77
use crate::build::{BlockAnd, BlockAndExtension, Builder};
88
use crate::hair::*;
99
use rustc::middle::region;
10-
use rustc::mir::interpret::EvalErrorKind;
10+
use rustc::mir::interpret::InterpError;
1111
use rustc::mir::*;
1212
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
1313
use syntax_pos::Span;
@@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
101101
block,
102102
Operand::Move(is_min),
103103
false,
104-
EvalErrorKind::OverflowNeg,
104+
InterpError::OverflowNeg,
105105
expr_span,
106106
);
107107
}
@@ -433,7 +433,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
433433
let val = result_value.clone().field(val_fld, ty);
434434
let of = result_value.field(of_fld, bool_ty);
435435

436-
let err = EvalErrorKind::Overflow(op);
436+
let err = InterpError::Overflow(op);
437437

438438
block = self.assert(block, Operand::Move(of), false, err, span);
439439

@@ -444,9 +444,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
444444
// and 2. there are two possible failure cases, divide-by-zero and overflow.
445445

446446
let (zero_err, overflow_err) = if op == BinOp::Div {
447-
(EvalErrorKind::DivisionByZero, EvalErrorKind::Overflow(op))
447+
(InterpError::DivisionByZero, InterpError::Overflow(op))
448448
} else {
449-
(EvalErrorKind::RemainderByZero, EvalErrorKind::Overflow(op))
449+
(InterpError::RemainderByZero, InterpError::Overflow(op))
450450
};
451451

452452
// Check for / 0

src/librustc_mir/const_eval.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use syntax::source_map::{Span, DUMMY_SP};
2323
use crate::interpret::{self,
2424
PlaceTy, MPlaceTy, MemPlace, OpTy, ImmTy, Immediate, Scalar, Pointer,
2525
RawConst, ConstValue,
26-
EvalResult, EvalError, EvalErrorKind, GlobalId, InterpretCx, StackPopCleanup,
26+
EvalResult, EvalError, InterpError, GlobalId, InterpretCx, StackPopCleanup,
2727
Allocation, AllocId, MemoryKind,
2828
snapshot, RefTracking,
2929
};
@@ -173,7 +173,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
173173

174174
impl<'tcx> Into<EvalError<'tcx>> for ConstEvalError {
175175
fn into(self) -> EvalError<'tcx> {
176-
EvalErrorKind::MachineError(self.to_string()).into()
176+
InterpError::MachineError(self.to_string()).into()
177177
}
178178
}
179179

@@ -351,7 +351,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
351351
Ok(Some(match ecx.load_mir(instance.def) {
352352
Ok(mir) => mir,
353353
Err(err) => {
354-
if let EvalErrorKind::NoMirFor(ref path) = err.kind {
354+
if let InterpError::NoMirFor(ref path) = err.kind {
355355
return Err(
356356
ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
357357
.into(),
@@ -679,7 +679,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
679679
// any other kind of error will be reported to the user as a deny-by-default lint
680680
_ => if let Some(p) = cid.promoted {
681681
let span = tcx.optimized_mir(def_id).promoted[p].span;
682-
if let EvalErrorKind::ReferencedConstant = err.error {
682+
if let InterpError::ReferencedConstant = err.error {
683683
err.report_as_error(
684684
tcx.at(span),
685685
"evaluation of constant expression failed",

src/librustc_mir/interpret/cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy};
44

55
use rustc_apfloat::ieee::{Single, Double};
66
use rustc::mir::interpret::{
7-
Scalar, EvalResult, Pointer, PointerArithmetic, EvalErrorKind, truncate
7+
Scalar, EvalResult, Pointer, PointerArithmetic, InterpError, truncate
88
};
99
use rustc::mir::CastKind;
1010
use rustc_apfloat::Float;
@@ -85,7 +85,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
8585
self.param_env,
8686
def_id,
8787
substs,
88-
).ok_or_else(|| EvalErrorKind::TooGeneric.into());
88+
).ok_or_else(|| InterpError::TooGeneric.into());
8989
let fn_ptr = self.memory.create_fn_alloc(instance?).with_default_tag();
9090
self.write_scalar(Scalar::Ptr(fn_ptr.into()), dest)?;
9191
}

src/librustc_mir/interpret/eval_context.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_data_structures::indexed_vec::IndexVec;
1616
use rustc::mir::interpret::{
1717
ErrorHandled,
1818
GlobalId, Scalar, FrameInfo, AllocId,
19-
EvalResult, EvalErrorKind,
19+
EvalResult, InterpError,
2020
truncate, sign_extend,
2121
};
2222
use rustc_data_structures::fx::FxHashMap;
@@ -167,7 +167,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf
167167
#[inline]
168168
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
169169
self.tcx.layout_of(self.param_env.and(ty))
170-
.map_err(|layout| EvalErrorKind::Layout(layout).into())
170+
.map_err(|layout| InterpError::Layout(layout).into())
171171
}
172172
}
173173

@@ -255,7 +255,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
255255
self.param_env,
256256
def_id,
257257
substs,
258-
).ok_or_else(|| EvalErrorKind::TooGeneric.into())
258+
).ok_or_else(|| InterpError::TooGeneric.into())
259259
}
260260

261261
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
@@ -647,8 +647,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
647647
// `Memory::get_static_alloc` which has to use `const_eval_raw` to avoid cycles.
648648
let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| {
649649
match err {
650-
ErrorHandled::Reported => EvalErrorKind::ReferencedConstant,
651-
ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric,
650+
ErrorHandled::Reported => InterpError::ReferencedConstant,
651+
ErrorHandled::TooGeneric => InterpError::TooGeneric,
652652
}
653653
})?;
654654
self.raw_const_to_mplace(val)
@@ -670,7 +670,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
670670

671671
match self.stack[frame].locals[local].access() {
672672
Err(err) => {
673-
if let EvalErrorKind::DeadLocal = err.kind {
673+
if let InterpError::DeadLocal = err.kind {
674674
write!(msg, " is dead").unwrap();
675675
} else {
676676
panic!("Failed to access local: {:?}", err);

src/librustc_mir/interpret/intrinsics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::ty;
77
use rustc::ty::layout::{LayoutOf, Primitive, Size};
88
use rustc::mir::BinOp;
99
use rustc::mir::interpret::{
10-
EvalResult, EvalErrorKind, Scalar,
10+
EvalResult, InterpError, Scalar,
1111
};
1212

1313
use super::{
@@ -87,7 +87,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
8787
let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?;
8888
let kind = match layout_of.abi {
8989
ty::layout::Abi::Scalar(ref scalar) => scalar.value,
90-
_ => Err(::rustc::mir::interpret::EvalErrorKind::TypeNotPrimitive(ty))?,
90+
_ => Err(::rustc::mir::interpret::InterpError::TypeNotPrimitive(ty))?,
9191
};
9292
let out_val = if intrinsic_name.ends_with("_nonzero") {
9393
if bits == 0 {
@@ -248,7 +248,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
248248
let file = Symbol::intern(self.read_str(file_place)?);
249249
let line = self.read_scalar(line.into())?.to_u32()?;
250250
let col = self.read_scalar(col.into())?.to_u32()?;
251-
return Err(EvalErrorKind::Panic { msg, file, line, col }.into());
251+
return Err(InterpError::Panic { msg, file, line, col }.into());
252252
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
253253
assert!(args.len() == 2);
254254
// &'static str, &(&'static str, u32, u32)
@@ -266,7 +266,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
266266
let file = Symbol::intern(self.read_str(file_place)?);
267267
let line = self.read_scalar(line.into())?.to_u32()?;
268268
let col = self.read_scalar(col.into())?.to_u32()?;
269-
return Err(EvalErrorKind::Panic { msg, file, line, col }.into());
269+
return Err(InterpError::Panic { msg, file, line, col }.into());
270270
} else {
271271
return Ok(false);
272272
}

0 commit comments

Comments
 (0)