From: Saleem Jaffer Date: Wed, 31 Jul 2019 07:18:54 +0000 (+0530) Subject: code review fixes X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=152f0d347e9b3b661adfcc0289412badfa45ab5a;p=rust.git code review fixes --- diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 7108f69d39e..8d41b019c22 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -137,13 +137,12 @@ fn struct_generic( message: &str, lint_root: Option, ) -> Result, ErrorHandled> { - use InvalidProgramInfo::*; match self.error { - InterpError::InvalidProgram(Layout(LayoutError::Unknown(_))) | - InterpError::InvalidProgram(TooGeneric) => + err_inval!(Layout(LayoutError::Unknown(_))) | + err_inval!(TooGeneric) => return Err(ErrorHandled::TooGeneric), - InterpError::InvalidProgram(Layout(LayoutError::SizeOverflow(_))) | - InterpError::InvalidProgram(TypeckError) => + err_inval!(Layout(LayoutError::SizeOverflow(_))) | + err_inval!(TypeckError) => return Err(ErrorHandled::Reported), _ => {}, } @@ -549,7 +548,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum ResourceExhaustionInfo { + /// The stack grew too big. StackFrameLimitReached, + /// The program ran into an infinite loop. InfiniteLoop, } diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index ad18e2779ba..8feb04ffe88 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -21,20 +21,12 @@ macro_rules! throw_ub { #[macro_export] macro_rules! throw_panic { - ($($tt:tt)*) => { - return Err($crate::mir::interpret::InterpError::Panic( - $crate::mir::interpret::PanicInfo::$($tt)* - ).into()) - }; + ($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) }; } #[macro_export] macro_rules! throw_exhaust { - ($($tt:tt)*) => { - return Err($crate::mir::interpret::InterpError::ResourceExhaustion( - $crate::mir::interpret::ResourceExhaustionInfo::$($tt)* - ).into()) - }; + ($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) }; } #[macro_export] @@ -55,6 +47,24 @@ macro_rules! err_unsup { }; } +#[macro_export] +macro_rules! err_exhaust { + ($($tt:tt)*) => { + $crate::mir::interpret::InterpError::ResourceExhaustion( + $crate::mir::interpret::ResourceExhaustionInfo::$($tt)* + ) + }; +} + +#[macro_export] +macro_rules! err_panic { + ($($tt:tt)*) => { + $crate::mir::interpret::InterpError::Panic( + $crate::mir::interpret::PanicInfo::$($tt)* + ) + }; +} + mod error; mod value; mod allocation; diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 75186b5fcf0..1b92e4992ff 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -22,9 +22,9 @@ use crate::interpret::{self, PlaceTy, MPlaceTy, OpTy, ImmTy, Immediate, Scalar, RawConst, ConstValue, - InterpResult, InterpErrorInfo, InterpError, GlobalId, InterpCx, StackPopCleanup, + InterpResult, InterpErrorInfo, GlobalId, InterpCx, StackPopCleanup, Allocation, AllocId, MemoryKind, - snapshot, RefTracking, intern_const_alloc_recursive, UnsupportedOpInfo, + snapshot, RefTracking, intern_const_alloc_recursive, }; /// Number of steps until the detector even starts doing anything. @@ -183,7 +183,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( impl<'tcx> Into> for ConstEvalError { fn into(self) -> InterpErrorInfo<'tcx> { - InterpError::Unsupported(UnsupportedOpInfo::MachineError(self.to_string())).into() + err_unsup!(MachineError(self.to_string())).into() } } @@ -360,7 +360,7 @@ fn find_fn( Ok(Some(match ecx.load_mir(instance.def) { Ok(body) => body, Err(err) => { - if let InterpError::Unsupported(UnsupportedOpInfo::NoMirFor(ref path)) = err.kind { + if let err_unsup!(NoMirFor(ref path)) = err.kind { return Err( ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path)) .into(), @@ -697,9 +697,8 @@ pub fn const_eval_raw_provider<'tcx>( // promoting runtime code is only allowed to error if it references broken constants // any other kind of error will be reported to the user as a deny-by-default lint _ => if let Some(p) = cid.promoted { - use crate::interpret::InvalidProgramInfo::ReferencedConstant; let span = tcx.promoted_mir(def_id)[p].span; - if let InterpError::InvalidProgram(ReferencedConstant) = err.error { + if let err_inval!(ReferencedConstant) = err.error { err.report_as_error( tcx.at(span), "evaluation of constant expression failed", diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index cd057e059d5..7ab99976b40 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -16,8 +16,7 @@ use rustc::mir::interpret::{ ErrorHandled, GlobalId, Scalar, Pointer, FrameInfo, AllocId, - InterpResult, InterpError, - truncate, sign_extend, InvalidProgramInfo, + InterpResult, truncate, sign_extend, }; use rustc_data_structures::fx::FxHashMap; @@ -193,7 +192,7 @@ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { self.tcx .layout_of(self.param_env.and(ty)) .map_err(|layout| { - InterpError::InvalidProgram(InvalidProgramInfo::Layout(layout)).into() + err_inval!(Layout(layout)).into() }) } } @@ -698,9 +697,9 @@ pub fn const_eval_raw( let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| { match err { ErrorHandled::Reported => - InterpError::InvalidProgram(InvalidProgramInfo::ReferencedConstant), + err_inval!(ReferencedConstant), ErrorHandled::TooGeneric => - InterpError::InvalidProgram(InvalidProgramInfo::TooGeneric), + err_inval!(TooGeneric), } })?; self.raw_const_to_mplace(val) diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 1cc409d7a9b..e9bba788911 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -4,9 +4,7 @@ //! memory, we need to extract all memory allocations to the global memory pool so they stay around. use rustc::ty::{Ty, TyCtxt, ParamEnv, self}; -use rustc::mir::interpret::{ - InterpResult, ErrorHandled, UnsupportedOpInfo, -}; +use rustc::mir::interpret::{InterpResult, ErrorHandled}; use rustc::hir; use rustc::hir::def_id::DefId; use super::validity::RefTracking; @@ -16,7 +14,7 @@ use syntax_pos::Span; use super::{ - ValueVisitor, MemoryKind, Pointer, AllocId, MPlaceTy, InterpError, Scalar, + ValueVisitor, MemoryKind, Pointer, AllocId, MPlaceTy, Scalar, }; use crate::const_eval::{CompileTimeInterpreter, CompileTimeEvalContext}; @@ -293,7 +291,7 @@ pub fn intern_const_alloc_recursive( if let Err(error) = interned { // This can happen when e.g. the tag of an enum is not a valid discriminant. We do have // to read enum discriminants in order to find references in enum variant fields. - if let InterpError::Unsupported(UnsupportedOpInfo::ValidationFailure(_)) = error.kind { + if let err_unsup!(ValidationFailure(_)) = error.kind { let err = crate::const_eval::error_to_const_error(&ecx, error); match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") { Ok(mut diag) => { diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index e5af9d86cb3..97866adcfa3 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -6,9 +6,7 @@ use rustc::ty; use rustc::ty::layout::{LayoutOf, Primitive, Size}; use rustc::mir::BinOp; -use rustc::mir::interpret::{ - InterpResult, InterpError, Scalar, PanicInfo, UnsupportedOpInfo, -}; +use rustc::mir::interpret::{InterpResult, Scalar}; use super::{ Machine, PlaceTy, OpTy, InterpCx, Immediate, @@ -100,7 +98,7 @@ pub fn emulate_intrinsic( let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?; let kind = match layout_of.abi { ty::layout::Abi::Scalar(ref scalar) => scalar.value, - _ => Err(InterpError::Unsupported(UnsupportedOpInfo::TypeNotPrimitive(ty)))?, + _ => Err(err_unsup!(TypeNotPrimitive(ty)))?, }; let out_val = if intrinsic_name.ends_with("_nonzero") { if bits == 0 { @@ -250,7 +248,7 @@ pub fn hook_fn( 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(PanicInfo::Panic { msg, file, line, col }).into()); + throw_panic!(Panic { msg, file, line, col }) } else if Some(def_id) == self.tcx.lang_items().begin_panic_fn() { assert!(args.len() == 2); // &'static str, &(&'static str, u32, u32) @@ -268,7 +266,7 @@ pub fn hook_fn( 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(PanicInfo::Panic { msg, file, line, col }).into()); + throw_panic!(Panic { msg, file, line, col }) } else { return Ok(false); } diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 2e7e2ad93d4..78902b10166 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -10,8 +10,8 @@ use rustc::ty::{self, TyCtxt}; use super::{ - Allocation, AllocId, InterpResult, InterpError, Scalar, AllocationExtra, - InterpCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory, UnsupportedOpInfo, + Allocation, AllocId, InterpResult, Scalar, AllocationExtra, + InterpCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory, }; /// Whether this kind of memory is allowed to leak @@ -240,9 +240,9 @@ fn int_to_ptr( int: u64, ) -> InterpResult<'tcx, Pointer> { Err((if int == 0 { - InterpError::Unsupported(UnsupportedOpInfo::InvalidNullPointerUsage) + err_unsup!(InvalidNullPointerUsage) } else { - InterpError::Unsupported(UnsupportedOpInfo::ReadBytesAsPointer) + err_unsup!(ReadBytesAsPointer) }).into()) } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 949f9194d9e..85ed3b3efd6 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -18,8 +18,8 @@ use super::{ Pointer, AllocId, Allocation, GlobalId, AllocationExtra, - InterpResult, Scalar, InterpError, GlobalAlloc, PointerArithmetic, - Machine, AllocMap, MayLeak, ErrorHandled, CheckInAllocMsg, InvalidProgramInfo, + InterpResult, Scalar, GlobalAlloc, PointerArithmetic, + Machine, AllocMap, MayLeak, ErrorHandled, CheckInAllocMsg, }; #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] @@ -250,18 +250,17 @@ pub fn deallocate( Some(alloc) => alloc, None => { // Deallocating static memory -- always an error - match self.tcx.alloc_map.lock().get(ptr.alloc_id) { - Some(GlobalAlloc::Function(..)) => throw_unsup!(DeallocatedWrongMemoryKind( + return Err(match self.tcx.alloc_map.lock().get(ptr.alloc_id) { + Some(GlobalAlloc::Function(..)) => err_unsup!(DeallocatedWrongMemoryKind( "function".to_string(), format!("{:?}", kind), )), - Some(GlobalAlloc::Static(..)) | - Some(GlobalAlloc::Memory(..)) => throw_unsup!(DeallocatedWrongMemoryKind( - "static".to_string(), - format!("{:?}", kind), - )), - None => throw_unsup!(DoubleFree) + Some(GlobalAlloc::Static(..)) | Some(GlobalAlloc::Memory(..)) => err_unsup!( + DeallocatedWrongMemoryKind("static".to_string(), format!("{:?}", kind)) + ), + None => err_unsup!(DoubleFree), } + .into()); } }; @@ -437,11 +436,9 @@ fn get_static_alloc( assert!(tcx.is_static(def_id)); match err { ErrorHandled::Reported => - InterpError::InvalidProgram( - InvalidProgramInfo::ReferencedConstant - ), + err_inval!(ReferencedConstant), ErrorHandled::TooGeneric => - InterpError::InvalidProgram(InvalidProgramInfo::TooGeneric), + err_inval!(TooGeneric), } })?; // Make sure we use the ID of the resolved memory, not the lazy one! diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 402a9a5c5ce..e64a474b4ca 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -11,8 +11,7 @@ use rustc::mir::interpret::{ GlobalId, AllocId, ConstValue, Pointer, Scalar, - InterpResult, InterpError, - sign_extend, truncate, UnsupportedOpInfo, + InterpResult, sign_extend, truncate, }; use super::{ InterpCx, Machine, @@ -332,7 +331,7 @@ pub fn read_str( let len = mplace.len(self)?; let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len as u64))?; let str = ::std::str::from_utf8(bytes).map_err(|err| { - InterpError::Unsupported(UnsupportedOpInfo::ValidationFailure(err.to_string())) + err_unsup!(ValidationFailure(err.to_string())) })?; Ok(str) } @@ -604,7 +603,6 @@ pub fn read_discriminant( let raw_discr = discr_val.to_scalar_or_undef(); trace!("discr value: {:?}", raw_discr); // post-process - use rustc::mir::interpret::UnsupportedOpInfo::InvalidDiscriminant; Ok(match *discr_kind { layout::DiscriminantKind::Tag => { let bits_discr = match raw_discr.to_bits(discr_val.layout.size) { @@ -649,7 +647,7 @@ pub fn read_discriminant( let variants_start = niche_variants.start().as_u32() as u128; let variants_end = niche_variants.end().as_u32() as u128; let raw_discr = raw_discr.not_undef().map_err(|_| { - InterpError::Unsupported(InvalidDiscriminant(ScalarMaybeUndef::Undef)) + err_unsup!(InvalidDiscriminant(ScalarMaybeUndef::Undef)) })?; match raw_discr.to_bits_or_ptr(discr_val.layout.size, self) { Err(ptr) => { diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index ebf7dd3b662..70a297c8662 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -11,8 +11,7 @@ use rustc::mir; use rustc::mir::interpret::{ AllocId, Pointer, Scalar, - Relocations, Allocation, UndefMask, - InterpResult, InterpError, ResourceExhaustionInfo, + Relocations, Allocation, UndefMask, InterpResult, }; use rustc::ty::{self, TyCtxt}; @@ -77,7 +76,7 @@ pub fn observe_and_analyze( } // Second cycle - Err(InterpError::ResourceExhaustion(ResourceExhaustionInfo::InfiniteLoop).into()) + throw_exhaust!(InfiniteLoop) } } diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index aa06922fb95..d4bc8f460e8 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -136,31 +136,29 @@ pub(super) fn eval_terminator( } else { // Compute error message use rustc::mir::interpret::PanicInfo::*; - match msg { + return Err(match msg { BoundsCheck { ref len, ref index } => { - let len = self.read_immediate(self.eval_operand(len, None)?) - .expect("can't eval len").to_scalar()? + let len = self + .read_immediate(self.eval_operand(len, None)?) + .expect("can't eval len") + .to_scalar()? .to_bits(self.memory().pointer_size())? as u64; - let index = self.read_immediate(self.eval_operand(index, None)?) - .expect("can't eval index").to_scalar()? + let index = self + .read_immediate(self.eval_operand(index, None)?) + .expect("can't eval index") + .to_scalar()? .to_bits(self.memory().pointer_size())? as u64; - throw_panic!(BoundsCheck { len, index }) + err_panic!(BoundsCheck { len, index }) } - Overflow(op) => - throw_panic!(Overflow(*op)), - OverflowNeg => - throw_panic!(OverflowNeg), - DivisionByZero => - throw_panic!(DivisionByZero), - RemainderByZero => - throw_panic!(RemainderByZero), - GeneratorResumedAfterReturn => - throw_panic!(GeneratorResumedAfterReturn), - GeneratorResumedAfterPanic => - throw_panic!(GeneratorResumedAfterPanic), - Panic { .. } => - bug!("`Panic` variant cannot occur in MIR"), - }; + Overflow(op) => err_panic!(Overflow(*op)), + OverflowNeg => err_panic!(OverflowNeg), + DivisionByZero => err_panic!(DivisionByZero), + RemainderByZero => err_panic!(RemainderByZero), + GeneratorResumedAfterReturn => err_panic!(GeneratorResumedAfterReturn), + GeneratorResumedAfterPanic => err_panic!(GeneratorResumedAfterPanic), + Panic { .. } => bug!("`Panic` variant cannot occur in MIR"), + } + .into()); } } diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index aa246172964..072c9afc50a 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -10,11 +10,11 @@ use std::hash::Hash; use super::{ - GlobalAlloc, InterpResult, InterpError, - OpTy, Machine, InterpCx, ValueVisitor, MPlaceTy, UnsupportedOpInfo, + GlobalAlloc, InterpResult, + OpTy, Machine, InterpCx, ValueVisitor, MPlaceTy, }; -macro_rules! validation_failure { +macro_rules! throw_validation_failure { ($what:expr, $where:expr, $details:expr) => {{ let where_ = path_format(&$where); let where_ = if where_.is_empty() { @@ -45,14 +45,14 @@ macro_rules! try_validation { ($e:expr, $what:expr, $where:expr, $details:expr) => {{ match $e { Ok(x) => x, - Err(_) => validation_failure!($what, $where, $details), + Err(_) => throw_validation_failure!($what, $where, $details), } }}; ($e:expr, $what:expr, $where:expr) => {{ match $e { Ok(x) => x, - Err(_) => validation_failure!($what, $where), + Err(_) => throw_validation_failure!($what, $where), } }} } @@ -297,12 +297,12 @@ fn visit_value(&mut self, op: OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx> match self.walk_value(op) { Ok(()) => Ok(()), Err(err) => match err.kind { - InterpError::Unsupported(UnsupportedOpInfo::InvalidDiscriminant(val)) => - validation_failure!( + err_unsup!(InvalidDiscriminant(val)) => + throw_validation_failure!( val, self.path, "a valid enum discriminant" ), - InterpError::Unsupported(UnsupportedOpInfo::ReadPointerAsBytes) => - validation_failure!( + err_unsup!(ReadPointerAsBytes) => + throw_validation_failure!( "a pointer", self.path, "plain (non-pointer) bytes" ), _ => Err(err), @@ -405,21 +405,20 @@ fn visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> InterpResult< "{:?} did not pass access check for size {:?}, align {:?}", ptr, size, align ); - use super::UnsupportedOpInfo::*; match err.kind { - InterpError::Unsupported(InvalidNullPointerUsage) => - validation_failure!("NULL reference", self.path), - InterpError::Unsupported(AlignmentCheckFailed { required, has }) => - validation_failure!(format!("unaligned reference \ + err_unsup!(InvalidNullPointerUsage) => + throw_validation_failure!("NULL reference", self.path), + err_unsup!(AlignmentCheckFailed { required, has }) => + throw_validation_failure!(format!("unaligned reference \ (required {} byte alignment but found {})", required.bytes(), has.bytes()), self.path), - InterpError::Unsupported(ReadBytesAsPointer) => - validation_failure!( + err_unsup!(ReadBytesAsPointer) => + throw_validation_failure!( "dangling reference (created from integer)", self.path ), _ => - validation_failure!( + throw_validation_failure!( "dangling reference (not entirely in bounds)", self.path ), @@ -479,7 +478,7 @@ fn visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> InterpResult< fn visit_uninhabited(&mut self) -> InterpResult<'tcx> { - validation_failure!("a value of an uninhabited type", self.path) + throw_validation_failure!("a value of an uninhabited type", self.path) } fn visit_scalar( @@ -512,7 +511,7 @@ fn visit_scalar( if lo == 1 && hi == max_hi { // Only NULL is the niche. So make sure the ptr is NOT NULL. if self.ecx.memory.ptr_may_be_null(ptr) { - validation_failure!( + throw_validation_failure!( "a potentially NULL pointer", self.path, format!( @@ -525,7 +524,7 @@ fn visit_scalar( } else { // Conservatively, we reject, because the pointer *could* have a bad // value. - validation_failure!( + throw_validation_failure!( "a pointer", self.path, format!( @@ -542,7 +541,7 @@ fn visit_scalar( if wrapping_range_contains(&layout.valid_range, bits) { Ok(()) } else { - validation_failure!( + throw_validation_failure!( bits, self.path, format!("something {}", wrapping_range_format(&layout.valid_range, max_hi)) @@ -609,14 +608,14 @@ fn visit_aggregate( Err(err) => { // For some errors we might be able to provide extra information match err.kind { - InterpError::Unsupported(UnsupportedOpInfo::ReadUndefBytes(offset)) => { + err_unsup!(ReadUndefBytes(offset)) => { // Some byte was undefined, determine which // element that byte belongs to so we can // provide an index. let i = (offset.bytes() / ty_size.bytes()) as usize; self.path.push(PathElem::ArrayElem(i)); - validation_failure!("undefined bytes", self.path) + throw_validation_failure!("undefined bytes", self.path) }, // Other errors shouldn't be possible _ => return Err(err), diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 807a7e88498..164a268004d 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -13,7 +13,7 @@ use rustc::mir::visit::{ Visitor, PlaceContext, MutatingUseContext, MutVisitor, NonMutatingUseContext, }; -use rustc::mir::interpret::{Scalar, GlobalId, InterpResult, InterpError, PanicInfo}; +use rustc::mir::interpret::{Scalar, GlobalId, InterpResult, PanicInfo}; use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt}; use syntax_pos::{Span, DUMMY_SP}; use rustc::ty::subst::InternalSubsts; @@ -519,7 +519,7 @@ fn const_prop( ) } else { if overflow { - let err = InterpError::Panic(PanicInfo::Overflow(op)).into(); + let err = err_panic!(Overflow(op)).into(); let _: Option<()> = self.use_ecx(source_info, |_| Err(err)); return None; }