Skip to content

Commit fd352b0

Browse files
committed
alters the panic variant of InterpError
1 parent 589f6a7 commit fd352b0

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

src/librustc/mir/interpret/error.rs

+21-38
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,24 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {
228228

229229
pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;
230230

231+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
232+
pub enum EvalErrorPanic<O> {
233+
Panic {
234+
msg: Symbol,
235+
line: u32,
236+
col: u32,
237+
file: Symbol,
238+
},
239+
BoundsCheck {
240+
len: O,
241+
index: O,
242+
},
243+
Overflow(mir::BinOp),
244+
OverflowNeg,
245+
DivisionByZero,
246+
RemainderByZero,
247+
}
248+
231249
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
232250
pub enum InterpError<'tcx, O> {
233251
/// This variant is used by machines to signal their own errors that do not
@@ -247,7 +265,6 @@ pub enum InterpError<'tcx, O> {
247265
DanglingPointerDeref,
248266
DoubleFree,
249267
InvalidMemoryAccess,
250-
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
251268
InvalidFunctionPointer,
252269
InvalidBool,
253270
InvalidDiscriminant(ScalarMaybeUndef),
@@ -267,13 +284,11 @@ pub enum InterpError<'tcx, O> {
267284
Unimplemented(String),
268285
DerefFunctionPointer,
269286
ExecuteMemory,
270-
// asd
271287
BoundsCheck { len: O, index: O },
272288
Overflow(mir::BinOp),
273289
OverflowNeg,
274290
DivisionByZero,
275291
RemainderByZero,
276-
// asd
277292
Intrinsic(String),
278293
InvalidChar(u128),
279294
StackFrameLimitReached,
@@ -284,29 +299,6 @@ pub enum InterpError<'tcx, O> {
284299
required: Align,
285300
has: Align,
286301
},
287-
MemoryLockViolation {
288-
ptr: Pointer,
289-
len: u64,
290-
frame: usize,
291-
access: AccessKind,
292-
lock: Lock,
293-
},
294-
MemoryAcquireConflict {
295-
ptr: Pointer,
296-
len: u64,
297-
kind: AccessKind,
298-
lock: Lock,
299-
},
300-
InvalidMemoryLockRelease {
301-
ptr: Pointer,
302-
len: u64,
303-
frame: usize,
304-
lock: Lock,
305-
},
306-
DeallocatedLockedMemory {
307-
ptr: Pointer,
308-
lock: Lock,
309-
},
310302
ValidationFailure(String),
311303
CalledClosureAsFunction,
312304
VtableForArgumentlessMethod,
@@ -324,7 +316,7 @@ pub enum InterpError<'tcx, O> {
324316
HeapAllocZeroBytes,
325317
HeapAllocNonPowerOfTwoAlignment(u64),
326318
Unreachable,
327-
Panic(EvalErrorPanic<'tcx, O>),
319+
Panic(EvalErrorPanic<O>),
328320
ReadFromReturnPointer,
329321
PathNotFound(Vec<String>),
330322
UnimplementedTraitSelection,
@@ -340,15 +332,6 @@ pub enum InterpError<'tcx, O> {
340332
InfiniteLoop,
341333
}
342334

343-
#[derive(Clone, RustcEncodable, RustcDecodable)]
344-
pub enum EvalErrorPanic<'tcx, O> {
345-
Panic,
346-
BoundsCheck { len: O, index: O },
347-
Overflow(mir::BinOp),
348-
OverflowNeg,
349-
DivisionByZero,
350-
RemainderByZero,
351-
}
352335

353336
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
354337

@@ -549,8 +532,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
549532
write!(f, "incorrect alloc info: expected size {} and align {}, \
550533
got size {} and align {}",
551534
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
552-
Panic { ref msg, line, col, ref file } =>
553-
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
535+
Panic { .. } =>
536+
write!(f, "the evaluated program panicked"),
554537
InvalidDiscriminant(val) =>
555538
write!(f, "encountered invalid enum discriminant {}", val),
556539
Exit(code) =>

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod pointer;
1212

1313
pub use self::error::{
1414
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
15-
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
15+
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, EvalErrorPanic
1616
};
1717

1818
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};

src/librustc_mir/interpret/intrinsics.rs

+3-3
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-
InterpResult, InterpError, Scalar,
10+
InterpResult, InterpError, Scalar, EvalErrorPanic,
1111
};
1212

1313
use super::{
@@ -261,7 +261,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
261261
let file = Symbol::intern(self.read_str(file_place)?);
262262
let line = self.read_scalar(line.into())?.to_u32()?;
263263
let col = self.read_scalar(col.into())?.to_u32()?;
264-
return Err(InterpError::Panic { msg, file, line, col }.into());
264+
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
265265
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
266266
assert!(args.len() == 2);
267267
// &'static str, &(&'static str, u32, u32)
@@ -279,7 +279,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
279279
let file = Symbol::intern(self.read_str(file_place)?);
280280
let line = self.read_scalar(line.into())?.to_u32()?;
281281
let col = self.read_scalar(col.into())?.to_u32()?;
282-
return Err(InterpError::Panic { msg, file, line, col }.into());
282+
return Err(InterpError::Panic(EvalErrorPanic::Panic { msg, file, line, col }).into());
283283
} else {
284284
return Ok(false);
285285
}

0 commit comments

Comments
 (0)