@@ -245,7 +245,7 @@ fn print_backtrace(backtrace: &mut Backtrace) {
245245 eprintln ! ( "\n \n An error occurred in miri:\n {:?}" , backtrace) ;
246246}
247247
248- impl From < ErrorHandled > for InterpErrorInfo < ' tcx > {
248+ impl From < ErrorHandled > for InterpErrorInfo < ' _ > {
249249 fn from ( err : ErrorHandled ) -> Self {
250250 match err {
251251 ErrorHandled :: Reported => err_inval ! ( ReferencedConstant ) ,
@@ -291,7 +291,7 @@ pub enum InvalidProgramInfo<'tcx> {
291291 Layout ( layout:: LayoutError < ' tcx > ) ,
292292}
293293
294- impl fmt:: Debug for InvalidProgramInfo < ' tcx > {
294+ impl fmt:: Debug for InvalidProgramInfo < ' _ > {
295295 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
296296 use InvalidProgramInfo :: * ;
297297 match self {
@@ -321,6 +321,8 @@ pub enum UndefinedBehaviorInfo {
321321 RemainderByZero ,
322322 /// Overflowing inbounds pointer arithmetic.
323323 PointerArithOverflow ,
324+ /// Invalid metadata in a wide pointer (using `str` to avoid allocations).
325+ InvalidMeta ( & ' static str ) ,
324326}
325327
326328impl fmt:: Debug for UndefinedBehaviorInfo {
@@ -338,6 +340,7 @@ impl fmt::Debug for UndefinedBehaviorInfo {
338340 DivisionByZero => write ! ( f, "dividing by zero" ) ,
339341 RemainderByZero => write ! ( f, "calculating the remainder with a divisor of zero" ) ,
340342 PointerArithOverflow => write ! ( f, "overflowing in-bounds pointer arithmetic" ) ,
343+ InvalidMeta ( msg) => write ! ( f, "invalid metadata in wide pointer: {}" , msg) ,
341344 }
342345 }
343346}
@@ -354,8 +357,8 @@ pub enum UnsupportedOpInfo<'tcx> {
354357 Unsupported ( String ) ,
355358
356359 /// When const-prop encounters a situation it does not support, it raises this error.
357- /// This must not allocate for performance reasons.
358- ConstPropUnsupported ( & ' tcx str ) ,
360+ /// This must not allocate for performance reasons (hence `str`, not `String`) .
361+ ConstPropUnsupported ( & ' static str ) ,
359362
360363 // -- Everything below is not categorized yet --
361364 FunctionAbiMismatch ( Abi , Abi ) ,
@@ -612,3 +615,19 @@ impl fmt::Debug for InterpError<'_> {
612615 }
613616 }
614617}
618+
619+ impl InterpError < ' _ > {
620+ /// Some errors allocate to be created as they contain free-form strings.
621+ /// And sometimes we want to be sure that did not happen as it is a
622+ /// waste of resources.
623+ pub fn allocates ( & self ) -> bool {
624+ match self {
625+ InterpError :: MachineStop ( _)
626+ | InterpError :: Unsupported ( UnsupportedOpInfo :: Unsupported ( _) )
627+ | InterpError :: Unsupported ( UnsupportedOpInfo :: ValidationFailure ( _) )
628+ | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: Ub ( _) )
629+ | InterpError :: UndefinedBehavior ( UndefinedBehaviorInfo :: UbExperimental ( _) ) => true ,
630+ _ => false ,
631+ }
632+ }
633+ }
0 commit comments