Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
50840ee
Delay bug; this sidesteps ICE'ing when compiler is just doing error-r…
pnkfelix Jul 9, 2019
837fe7b
Regression test.
pnkfelix Jul 9, 2019
d73c23d
explain how to search without owned data
RalfJung Jul 13, 2019
3f77f2c
better comments
RalfJung Jul 14, 2019
589f6a7
tries to refactor InterpError in mir
saleemjaffer Jul 18, 2019
469b7a9
rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 18, 2019
c6735a6
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
10d4159
Revert "Disable stack probing for gnux32."
crlf0710 Jul 19, 2019
f5b2859
Handle more cases of typos misinterpreted as type ascription
estebank Jul 17, 2019
9dbe2e7
review comments
estebank Jul 19, 2019
b361864
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
c6e027d
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
2641bed
Tweak span for variant not found error
estebank Jul 20, 2019
fd352b0
alters the panic variant of InterpError
saleemjaffer Jul 20, 2019
18dceab
Add tests for issue-58887
JohnTitor Jul 21, 2019
e63fe15
move unescape module to rustc_lexer
matklad Jul 21, 2019
e75ae15
Move into existential-type dir
JohnTitor Jul 21, 2019
795d96d
Place::as_place_ref is now Place::as_ref
spastorino Jul 21, 2019
27b703d
add rustc_private as a proper language feature gate
matklad Jul 22, 2019
1a7127b
normalize use of backticks in compiler messages for librustc_allocator
Jul 22, 2019
4e02a1f
Change "OSX" to "macOS"
atouchet Jul 22, 2019
1ed375c
Update stage0.txt
git-iso Jul 23, 2019
7e612c1
Update src/librustc_lexer/src/lib.rs
matklad Jul 23, 2019
90426ed
moving some variants from InterpError to EvalErrorPanic
saleemjaffer Jul 20, 2019
3730ed9
renames EvalErrorPanic to PanicMessage
saleemjaffer Jul 23, 2019
f48ee09
Update stage0.txt
git-iso Jul 23, 2019
52e9e44
Rollup merge of #60951 - saleemjaffer:mir_better_error_enum, r=oli-obk
Mark-Simulacrum Jul 23, 2019
ad57597
Rollup merge of #62523 - pnkfelix:delay-bug-to-resolve-issue-62203-ic…
Mark-Simulacrum Jul 23, 2019
4264f83
Rollup merge of #62656 - RalfJung:contains-no-own, r=Dylan-DPC
Mark-Simulacrum Jul 23, 2019
ab7149b
Rollup merge of #62791 - estebank:type-ascription, r=petrochenkov
Mark-Simulacrum Jul 23, 2019
13775d2
Rollup merge of #62804 - lundibundi:help-infer-const-static, r=eddyb
Mark-Simulacrum Jul 23, 2019
66c2965
Rollup merge of #62808 - crlf0710:gnux32_stack_probe, r=nikic
Mark-Simulacrum Jul 23, 2019
24a8065
Rollup merge of #62817 - estebank:variant-sp, r=matthewjasper
Mark-Simulacrum Jul 23, 2019
8afc53c
Rollup merge of #62842 - JohnTitor:test-for-58887, r=alexreg
Mark-Simulacrum Jul 23, 2019
4cb3586
Rollup merge of #62851 - matklad:unescape, r=petrochenkov
Mark-Simulacrum Jul 23, 2019
b2155dd
Rollup merge of #62859 - spastorino:rename-to-as-ref, r=Centril
Mark-Simulacrum Jul 23, 2019
f11ffd3
Rollup merge of #62869 - matklad:feature-gate, r=Mark-Simulacrum
Mark-Simulacrum Jul 23, 2019
32e5f98
Rollup merge of #62880 - fakenine:normalize_use_of_backticks_compiler…
Mark-Simulacrum Jul 23, 2019
f1b267b
Rollup merge of #62885 - atouchet:macos, r=alexcrichton
Mark-Simulacrum Jul 23, 2019
c939db7
Rollup merge of #62889 - git-iso:patch-1, r=jonas-schievink
Mark-Simulacrum Jul 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 47 additions & 28 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {

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

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum PanicMessage<O> {
Panic {
msg: Symbol,
line: u32,
col: u32,
file: Symbol,
},
BoundsCheck {
len: O,
index: O,
},
Overflow(mir::BinOp),
OverflowNeg,
DivisionByZero,
RemainderByZero,
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum InterpError<'tcx, O> {
/// This variant is used by machines to signal their own errors that do not
Expand Down Expand Up @@ -266,11 +284,6 @@ pub enum InterpError<'tcx, O> {
Unimplemented(String),
DerefFunctionPointer,
ExecuteMemory,
BoundsCheck { len: O, index: O },
Overflow(mir::BinOp),
OverflowNeg,
DivisionByZero,
RemainderByZero,
Intrinsic(String),
InvalidChar(u128),
StackFrameLimitReached,
Expand Down Expand Up @@ -298,12 +311,7 @@ pub enum InterpError<'tcx, O> {
HeapAllocZeroBytes,
HeapAllocNonPowerOfTwoAlignment(u64),
Unreachable,
Panic {
msg: Symbol,
line: u32,
col: u32,
file: Symbol,
},
Panic(PanicMessage<O>),
ReadFromReturnPointer,
PathNotFound(Vec<String>),
UnimplementedTraitSelection,
Expand Down Expand Up @@ -369,8 +377,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
"tried to dereference a function pointer",
ExecuteMemory =>
"tried to treat a memory pointer as a function pointer",
BoundsCheck{..} =>
"array index out of bounds",
Intrinsic(..) =>
"intrinsic failed",
NoMirFor(..) =>
Expand Down Expand Up @@ -422,8 +428,32 @@ impl<'tcx, O> InterpError<'tcx, O> {
two",
Unreachable =>
"entered unreachable code",
Panic { .. } =>
Panic(PanicMessage::Panic{..}) =>
"the evaluated program panicked",
Panic(PanicMessage::BoundsCheck{..}) =>
"array index out of bounds",
Panic(PanicMessage::Overflow(mir::BinOp::Add)) =>
"attempt to add with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Sub)) =>
"attempt to subtract with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Mul)) =>
"attempt to multiply with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Div)) =>
"attempt to divide with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Rem)) =>
"attempt to calculate the remainder with overflow",
Panic(PanicMessage::OverflowNeg) =>
"attempt to negate with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Shr)) =>
"attempt to shift right with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Shl)) =>
"attempt to shift left with overflow",
Panic(PanicMessage::Overflow(op)) =>
bug!("{:?} cannot overflow", op),
Panic(PanicMessage::DivisionByZero) =>
"attempt to divide by zero",
Panic(PanicMessage::RemainderByZero) =>
"attempt to calculate the remainder with a divisor of zero",
ReadFromReturnPointer =>
"tried to read from the return pointer",
PathNotFound(_) =>
Expand All @@ -436,17 +466,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
"encountered overly generic constant",
ReferencedConstant =>
"referenced constant has errors",
Overflow(mir::BinOp::Add) => "attempt to add with overflow",
Overflow(mir::BinOp::Sub) => "attempt to subtract with overflow",
Overflow(mir::BinOp::Mul) => "attempt to multiply with overflow",
Overflow(mir::BinOp::Div) => "attempt to divide with overflow",
Overflow(mir::BinOp::Rem) => "attempt to calculate the remainder with overflow",
OverflowNeg => "attempt to negate with overflow",
Overflow(mir::BinOp::Shr) => "attempt to shift right with overflow",
Overflow(mir::BinOp::Shl) => "attempt to shift left with overflow",
Overflow(op) => bug!("{:?} cannot overflow", op),
DivisionByZero => "attempt to divide by zero",
RemainderByZero => "attempt to calculate the remainder with a divisor of zero",
GeneratorResumedAfterReturn => "generator resumed after completion",
GeneratorResumedAfterPanic => "generator resumed after panicking",
InfiniteLoop =>
Expand Down Expand Up @@ -493,8 +512,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
callee_ty, caller_ty),
FunctionArgCountMismatch =>
write!(f, "tried to call a function with incorrect number of arguments"),
BoundsCheck { ref len, ref index } =>
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
ReallocatedWrongMemoryKind(ref old, ref new) =>
write!(f, "tried to reallocate memory from {} to {}", old, new),
DeallocatedWrongMemoryKind(ref old, ref new) =>
Expand All @@ -518,8 +535,10 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
write!(f, "incorrect alloc info: expected size {} and align {}, \
got size {} and align {}",
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
Panic { ref msg, line, col, ref file } =>
Panic(PanicMessage::Panic { ref msg, line, col, ref file }) =>
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
Panic(PanicMessage::BoundsCheck { ref len, ref index }) =>
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
InvalidDiscriminant(val) =>
write!(f, "encountered invalid enum discriminant {}", val),
Exit(code) =>
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod pointer;

pub use self::error::{
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicMessage
};

pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ty::layout::{self, HasDataLayout, Size};
use rustc_macros::HashStable;

use super::{
AllocId, InterpResult,
AllocId, InterpResult, PanicMessage
};

/// Used by `check_in_alloc` to indicate context of check
Expand Down Expand Up @@ -76,13 +76,13 @@ pub trait PointerArithmetic: layout::HasDataLayout {
#[inline]
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_offset(val, i);
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
}

#[inline]
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_signed_offset(val, i128::from(i));
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::hir::def::{CtorKind, Namespace};
use crate::hir::def_id::DefId;
use crate::hir::{self, InlineAsm as HirInlineAsm};
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
use crate::mir::interpret::{ConstValue, PanicMessage, InterpError::Panic, Scalar};
use crate::mir::visit::MirVisitable;
use crate::rustc_serialize as serialize;
use crate::ty::adjustment::PointerCast;
Expand Down Expand Up @@ -3152,11 +3152,11 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
}
}
Assert { ref cond, expected, ref msg, target, cleanup } => {
let msg = if let InterpError::BoundsCheck { ref len, ref index } = *msg {
InterpError::BoundsCheck {
let msg = if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
Panic(PanicMessage::BoundsCheck {
len: len.fold_with(folder),
index: index.fold_with(folder),
}
})
} else {
msg.clone()
};
Expand Down Expand Up @@ -3197,7 +3197,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
}
Assert { ref cond, ref msg, .. } => {
if cond.visit_with(visitor) {
if let InterpError::BoundsCheck { ref len, ref index } = *msg {
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
len.visit_with(visitor) || index.visit_with(visitor)
} else {
false
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ macro_rules! make_mir_visitor {
msg: & $($mutability)? AssertMessage<'tcx>,
location: Location) {
use crate::mir::interpret::InterpError::*;
if let BoundsCheck { len, index } = msg {
use crate::mir::interpret::PanicMessage::BoundsCheck;
if let Panic(BoundsCheck { len, index }) = msg {
self.visit_operand(len, location);
self.visit_operand(index, location);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc::middle::lang_items;
use rustc::ty::{self, Ty, TypeFoldable, Instance};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
use rustc::mir::interpret::InterpError;
use rustc::mir::interpret::{InterpError, PanicMessage};
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
use rustc_target::spec::abi::Abi;
use crate::base;
Expand Down Expand Up @@ -368,7 +368,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// checked operation, just a comparison with the minimum
// value, so we have to check for the assert message.
if !bx.check_overflow() {
if let mir::interpret::InterpError::OverflowNeg = *msg {
if let InterpError::Panic(PanicMessage::OverflowNeg) = *msg {
const_cond = Some(expected);
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

// Put together the arguments to the panic entry point.
let (lang_item, args) = match *msg {
InterpError::BoundsCheck { ref len, ref index } => {
InterpError::Panic(PanicMessage::BoundsCheck { ref len, ref index }) => {
let len = self.codegen_operand(&mut bx, len).immediate();
let index = self.codegen_operand(&mut bx, index).immediate();

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
cleanup: _,
} => {
self.consume_operand(loc, (cond, span), flow_state);
use rustc::mir::interpret::InterpError::BoundsCheck;
if let BoundsCheck { ref len, ref index } = *msg {
use rustc::mir::interpret::{InterpError::Panic, PanicMessage};
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
self.consume_operand(loc, (len, span), flow_state);
self.consume_operand(loc, (index, span), flow_state);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
cleanup: _,
} => {
self.consume_operand(location, cond);
use rustc::mir::interpret::InterpError::BoundsCheck;
if let BoundsCheck { ref len, ref index } = *msg {
use rustc::mir::interpret::{InterpError::Panic, PanicMessage::BoundsCheck};
if let Panic(BoundsCheck { ref len, ref index }) = *msg {
self.consume_operand(location, len);
self.consume_operand(location, index);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc::infer::canonical::QueryRegionConstraints;
use rustc::infer::outlives::env::RegionBoundPairs;
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc::mir::interpret::{InterpError::BoundsCheck, ConstValue};
use rustc::mir::interpret::{InterpError::Panic, ConstValue, PanicMessage};
use rustc::mir::tcx::PlaceTy;
use rustc::mir::visit::{PlaceContext, Visitor, NonMutatingUseContext};
use rustc::mir::*;
Expand Down Expand Up @@ -1606,7 +1606,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
}

if let BoundsCheck { ref len, ref index } = *msg {
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
if len.ty(body, tcx) != tcx.types.usize {
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::build::expr::category::Category;
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use rustc::mir::interpret::InterpError::BoundsCheck;
use rustc::mir::interpret::{InterpError::Panic, PanicMessage::BoundsCheck};
use rustc::mir::*;
use rustc::ty::{CanonicalUserTypeAnnotation, Variance};

Expand Down Expand Up @@ -105,10 +105,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
),
);

let msg = BoundsCheck {
let msg = Panic(BoundsCheck {
len: Operand::Move(len),
index: Operand::Copy(Place::from(idx)),
};
});
let success = this.assert(block, Operand::Move(lt), true, msg, expr_span);
success.and(slice.index(idx))
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use rustc::middle::region;
use rustc::mir::interpret::InterpError;
use rustc::mir::interpret::{InterpError::Panic, PanicMessage};
use rustc::mir::*;
use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty, UpvarSubsts};
use syntax_pos::Span;
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block,
Operand::Move(is_min),
false,
InterpError::OverflowNeg,
Panic(PanicMessage::OverflowNeg),
expr_span,
);
}
Expand Down Expand Up @@ -401,7 +401,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let val = result_value.clone().field(val_fld, ty);
let of = result_value.field(of_fld, bool_ty);

let err = InterpError::Overflow(op);
let err = Panic(PanicMessage::Overflow(op));

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

Expand All @@ -412,9 +412,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// and 2. there are two possible failure cases, divide-by-zero and overflow.

let (zero_err, overflow_err) = if op == BinOp::Div {
(InterpError::DivisionByZero, InterpError::Overflow(op))
(Panic(PanicMessage::DivisionByZero), Panic(PanicMessage::Overflow(op)))
} else {
(InterpError::RemainderByZero, InterpError::Overflow(op))
(Panic(PanicMessage::RemainderByZero), Panic(PanicMessage::Overflow(op)))
};

// Check for / 0
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc::ty;
use rustc::ty::layout::{LayoutOf, Primitive, Size};
use rustc::mir::BinOp;
use rustc::mir::interpret::{
InterpResult, InterpError, Scalar,
InterpResult, InterpError, Scalar, PanicMessage,
};

use super::{
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
return Err(InterpError::Panic { msg, file, line, col }.into());
return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
} else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() {
assert!(args.len() == 2);
// &'static str, &(&'static str, u32, u32)
Expand All @@ -279,7 +279,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let file = Symbol::intern(self.read_str(file_place)?);
let line = self.read_scalar(line.into())?.to_u32()?;
let col = self.read_scalar(col.into())?.to_u32()?;
return Err(InterpError::Panic { msg, file, line, col }.into());
return Err(InterpError::Panic(PanicMessage::Panic { msg, file, line, col }).into());
} else {
return Ok(false);
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc::mir;
use rustc::ty::{self, layout::TyLayout};
use syntax::ast::FloatTy;
use rustc_apfloat::Float;
use rustc::mir::interpret::{InterpResult, Scalar};
use rustc::mir::interpret::{InterpResult, PanicMessage, Scalar};

use super::{InterpCx, PlaceTy, Immediate, Machine, ImmTy};

Expand Down Expand Up @@ -173,8 +173,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
return Ok((Scalar::from_bool(op(&l, &r)), false));
}
let op: Option<fn(i128, i128) -> (i128, bool)> = match bin_op {
Div if r == 0 => return err!(DivisionByZero),
Rem if r == 0 => return err!(RemainderByZero),
Div if r == 0 => return err!(Panic(PanicMessage::DivisionByZero)),
Rem if r == 0 => return err!(Panic(PanicMessage::RemainderByZero)),
Div => Some(i128::overflowing_div),
Rem => Some(i128::overflowing_rem),
Add => Some(i128::overflowing_add),
Expand Down Expand Up @@ -231,8 +231,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Add => u128::overflowing_add,
Sub => u128::overflowing_sub,
Mul => u128::overflowing_mul,
Div if r == 0 => return err!(DivisionByZero),
Rem if r == 0 => return err!(RemainderByZero),
Div if r == 0 => return err!(Panic(PanicMessage::DivisionByZero)),
Rem if r == 0 => return err!(Panic(PanicMessage::RemainderByZero)),
Div => u128::overflowing_div,
Rem => u128::overflowing_rem,
_ => bug!(),
Expand Down
Loading