@@ -142,7 +142,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
142142 InterpError :: InvalidProgram ( Layout ( LayoutError :: Unknown ( _) ) ) |
143143 InterpError :: InvalidProgram ( TooGeneric ) =>
144144 return Err ( ErrorHandled :: TooGeneric ) ,
145- InterpError :: Layout ( LayoutError :: SizeOverflow ( _) ) |
145+ InterpError :: InvalidProgram ( Layout ( LayoutError :: SizeOverflow ( _) ) ) |
146146 InterpError :: InvalidProgram ( TypeckError ) =>
147147 return Err ( ErrorHandled :: Reported ) ,
148148 _ => { } ,
@@ -325,16 +325,47 @@ pub enum InvalidProgramInfo<'tcx> {
325325 Layout ( layout:: LayoutError < ' tcx > ) ,
326326}
327327
328+ impl fmt:: Debug for InvalidProgramInfo < ' tcx > {
329+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
330+ use InvalidProgramInfo :: * ;
331+ match self {
332+ TooGeneric =>
333+ write ! ( f, "encountered overly generic constant" ) ,
334+ ReferencedConstant =>
335+ write ! ( f, "referenced constant has errors" ) ,
336+ TypeckError =>
337+ write ! ( f, "encountered constants with type errors, stopping evaluation" ) ,
338+ Layout ( ref err) =>
339+ write ! ( f, "rustc layout computation failed: {:?}" , err) ,
340+ }
341+ }
342+ }
343+
328344#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
329345pub enum UndefinedBehaviourInfo {
330- /// Handle cases which for which we do not have a fixed variant
346+ /// Handle cases which for which we do not have a fixed variant.
331347 Ub ( String ) ,
348+ /// Unreachable code was executed.
332349 Unreachable ,
333350}
334351
352+ impl fmt:: Debug for UndefinedBehaviourInfo {
353+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
354+ use UndefinedBehaviourInfo :: * ;
355+ match self {
356+ Ub ( ref msg) =>
357+ write ! ( f, "{}" , msg) ,
358+ Unreachable =>
359+ write ! ( f, "entered unreachable code" ) ,
360+ }
361+ }
362+ }
363+
335364#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
336365pub enum UnsupportedInfo < ' tcx > {
337366 Unimplemented ( String ) ,
367+
368+ // -- Everything below is not classified yet --
338369 FunctionAbiMismatch ( Abi , Abi ) ,
339370 FunctionArgMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
340371 FunctionRetMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
@@ -400,6 +431,19 @@ pub enum ResourceExhaustionInfo {
400431 InfiniteLoop ,
401432}
402433
434+ impl fmt:: Debug for ResourceExhaustionInfo {
435+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
436+ use ResourceExhaustionInfo :: * ;
437+ match self {
438+ StackFrameLimitReached =>
439+ write ! ( f, "reached the configured maximum number of stack frames" ) ,
440+ InfiniteLoop =>
441+ write ! ( f, "duplicate interpreter state observed here, const evaluation will never \
442+ terminate") ,
443+ }
444+ }
445+ }
446+
403447#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
404448pub enum InterpError < ' tcx > {
405449 /// The program panicked.
@@ -431,139 +475,131 @@ impl fmt::Display for InterpError<'_> {
431475impl fmt:: Debug for InterpError < ' _ > {
432476 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
433477 use InterpError :: * ;
478+ use UnsupportedInfo :: * ;
434479 match * self {
435- PointerOutOfBounds { ptr, msg, allocation_size } => {
480+ Unsupported ( PointerOutOfBounds { ptr, msg, allocation_size } ) => {
436481 write ! ( f, "{} failed: pointer must be in-bounds at offset {}, \
437482 but is outside bounds of allocation {} which has size {}",
438483 msg, ptr. offset. bytes( ) , ptr. alloc_id, allocation_size. bytes( ) )
439484 } ,
440- ValidationFailure ( ref err) => {
485+ Unsupported ( ValidationFailure ( ref err) ) => {
441486 write ! ( f, "type validation failed: {}" , err)
442487 }
443- NoMirFor ( ref func) => write ! ( f, "no mir for `{}`" , func) ,
444- FunctionAbiMismatch ( caller_abi, callee_abi) =>
488+ Unsupported ( NoMirFor ( ref func) ) => write ! ( f, "no mir for `{}`" , func) ,
489+ Unsupported ( FunctionAbiMismatch ( caller_abi, callee_abi) ) =>
445490 write ! ( f, "tried to call a function with ABI {:?} using caller ABI {:?}" ,
446491 callee_abi, caller_abi) ,
447- FunctionArgMismatch ( caller_ty, callee_ty) =>
492+ Unsupported ( FunctionArgMismatch ( caller_ty, callee_ty) ) =>
448493 write ! ( f, "tried to call a function with argument of type {:?} \
449494 passing data of type {:?}",
450495 callee_ty, caller_ty) ,
451- FunctionRetMismatch ( caller_ty, callee_ty) =>
496+ Unsupported ( FunctionRetMismatch ( caller_ty, callee_ty) ) =>
452497 write ! ( f, "tried to call a function with return type {:?} \
453498 passing return place of type {:?}",
454499 callee_ty, caller_ty) ,
455- FunctionArgCountMismatch =>
500+ Unsupported ( FunctionArgCountMismatch ) =>
456501 write ! ( f, "tried to call a function with incorrect number of arguments" ) ,
457- ReallocatedWrongMemoryKind ( ref old, ref new) =>
502+ Unsupported ( ReallocatedWrongMemoryKind ( ref old, ref new) ) =>
458503 write ! ( f, "tried to reallocate memory from {} to {}" , old, new) ,
459- DeallocatedWrongMemoryKind ( ref old, ref new) =>
504+ Unsupported ( DeallocatedWrongMemoryKind ( ref old, ref new) ) =>
460505 write ! ( f, "tried to deallocate {} memory but gave {} as the kind" , old, new) ,
461- InvalidChar ( c) =>
506+ Unsupported ( InvalidChar ( c) ) =>
462507 write ! ( f, "tried to interpret an invalid 32-bit value as a char: {}" , c) ,
463- AlignmentCheckFailed { required, has } =>
508+ Unsupported ( AlignmentCheckFailed { required, has } ) =>
464509 write ! ( f, "tried to access memory with alignment {}, but alignment {} is required" ,
465510 has. bytes( ) , required. bytes( ) ) ,
466- TypeNotPrimitive ( ty) =>
511+ Unsupported ( TypeNotPrimitive ( ty) ) =>
467512 write ! ( f, "expected primitive type, got {}" , ty) ,
468- Layout ( ref err) =>
469- write ! ( f, "rustc layout computation failed: {:?}" , err) ,
470- PathNotFound ( ref path) =>
513+ Unsupported ( PathNotFound ( ref path) ) =>
471514 write ! ( f, "Cannot find path {:?}" , path) ,
472- IncorrectAllocationInformation ( size, size2, align, align2) =>
515+ Unsupported ( IncorrectAllocationInformation ( size, size2, align, align2) ) =>
473516 write ! ( f, "incorrect alloc info: expected size {} and align {}, \
474517 got size {} and align {}",
475518 size. bytes( ) , align. bytes( ) , size2. bytes( ) , align2. bytes( ) ) ,
476- InvalidDiscriminant ( val) =>
519+ Unsupported ( InvalidDiscriminant ( val) ) =>
477520 write ! ( f, "encountered invalid enum discriminant {}" , val) ,
478- Exit ( code) =>
479- write ! ( f, "exited with status code {}" , code) ,
480- InvalidMemoryAccess =>
521+ Unsupported ( InvalidMemoryAccess ) =>
481522 write ! ( f, "tried to access memory through an invalid pointer" ) ,
482- DanglingPointerDeref =>
523+ Unsupported ( DanglingPointerDeref ) =>
483524 write ! ( f, "dangling pointer was dereferenced" ) ,
484- DoubleFree =>
525+ Unsupported ( DoubleFree ) =>
485526 write ! ( f, "tried to deallocate dangling pointer" ) ,
486- InvalidFunctionPointer =>
527+ Unsupported ( InvalidFunctionPointer ) =>
487528 write ! ( f, "tried to use a function pointer after offsetting it" ) ,
488- InvalidBool =>
529+ Unsupported ( InvalidBool ) =>
489530 write ! ( f, "invalid boolean value read" ) ,
490- InvalidNullPointerUsage =>
531+ Unsupported ( InvalidNullPointerUsage ) =>
491532 write ! ( f, "invalid use of NULL pointer" ) ,
492- ReadPointerAsBytes =>
533+ Unsupported ( ReadPointerAsBytes ) =>
493534 write ! ( f, "a raw memory access tried to access part of a pointer value as raw \
494535 bytes") ,
495- ReadBytesAsPointer =>
536+ Unsupported ( ReadBytesAsPointer ) =>
496537 write ! ( f, "a memory access tried to interpret some bytes as a pointer" ) ,
497- ReadForeignStatic =>
538+ Unsupported ( ReadForeignStatic ) =>
498539 write ! ( f, "tried to read from foreign (extern) static" ) ,
499- InvalidPointerMath =>
540+ Unsupported ( InvalidPointerMath ) =>
500541 write ! ( f, "attempted to do invalid arithmetic on pointers that would leak base \
501542 addresses, e.g., comparing pointers into different allocations") ,
502- DeadLocal =>
543+ Unsupported ( DeadLocal ) =>
503544 write ! ( f, "tried to access a dead local variable" ) ,
504- DerefFunctionPointer =>
545+ Unsupported ( DerefFunctionPointer ) =>
505546 write ! ( f, "tried to dereference a function pointer" ) ,
506- ExecuteMemory =>
547+ Unsupported ( ExecuteMemory ) =>
507548 write ! ( f, "tried to treat a memory pointer as a function pointer" ) ,
508- StackFrameLimitReached =>
509- write ! ( f, "reached the configured maximum number of stack frames" ) ,
510- OutOfTls =>
549+ Unsupported ( OutOfTls ) =>
511550 write ! ( f, "reached the maximum number of representable TLS keys" ) ,
512- TlsOutOfBounds =>
551+ Unsupported ( TlsOutOfBounds ) =>
513552 write ! ( f, "accessed an invalid (unallocated) TLS key" ) ,
514- CalledClosureAsFunction =>
553+ Unsupported ( CalledClosureAsFunction ) =>
515554 write ! ( f, "tried to call a closure through a function pointer" ) ,
516- VtableForArgumentlessMethod =>
555+ Unsupported ( VtableForArgumentlessMethod ) =>
517556 write ! ( f, "tried to call a vtable function without arguments" ) ,
518- ModifiedConstantMemory =>
557+ Unsupported ( ModifiedConstantMemory ) =>
519558 write ! ( f, "tried to modify constant memory" ) ,
520- ModifiedStatic =>
559+ Unsupported ( ModifiedStatic ) =>
521560 write ! ( f, "tried to modify a static's initial value from another static's \
522561 initializer") ,
523- AssumptionNotHeld =>
562+ Unsupported ( AssumptionNotHeld ) =>
524563 write ! ( f, "`assume` argument was false" ) ,
525- InlineAsm =>
564+ Unsupported ( InlineAsm ) =>
526565 write ! ( f, "miri does not support inline assembly" ) ,
527- ReallocateNonBasePtr =>
566+ Unsupported ( ReallocateNonBasePtr ) =>
528567 write ! ( f, "tried to reallocate with a pointer not to the beginning of an \
529568 existing object") ,
530- DeallocateNonBasePtr =>
569+ Unsupported ( DeallocateNonBasePtr ) =>
531570 write ! ( f, "tried to deallocate with a pointer not to the beginning of an \
532571 existing object") ,
533- HeapAllocZeroBytes =>
572+ Unsupported ( HeapAllocZeroBytes ) =>
534573 write ! ( f, "tried to re-, de- or allocate zero bytes on the heap" ) ,
535- Unreachable =>
536- write ! ( f, "entered unreachable code" ) ,
537- ReadFromReturnPointer =>
574+ Unsupported ( ReadFromReturnPointer ) =>
538575 write ! ( f, "tried to read from the return pointer" ) ,
539- UnimplementedTraitSelection =>
576+ Unsupported ( UnimplementedTraitSelection ) =>
540577 write ! ( f, "there were unresolved type arguments during trait selection" ) ,
541- TypeckError =>
542- write ! ( f, "encountered constants with type errors, stopping evaluation" ) ,
543- TooGeneric =>
544- write ! ( f, "encountered overly generic constant" ) ,
545- ReferencedConstant =>
546- write ! ( f, "referenced constant has errors" ) ,
547- InfiniteLoop =>
548- write ! ( f, "duplicate interpreter state observed here, const evaluation will never \
549- terminate") ,
550- InvalidBoolOp ( _) =>
578+ Unsupported ( InvalidBoolOp ( _) ) =>
551579 write ! ( f, "invalid boolean operation" ) ,
552- UnterminatedCString ( _) =>
580+ Unsupported ( UnterminatedCString ( _) ) =>
553581 write ! ( f, "attempted to get length of a null terminated string, but no null \
554582 found before end of allocation") ,
555- ReadUndefBytes ( _) =>
583+ Unsupported ( ReadUndefBytes ( _) ) =>
556584 write ! ( f, "attempted to read undefined bytes" ) ,
557- HeapAllocNonPowerOfTwoAlignment ( _) =>
585+ Unsupported ( HeapAllocNonPowerOfTwoAlignment ( _) ) =>
558586 write ! ( f, "tried to re-, de-, or allocate heap memory with alignment that is \
559587 not a power of two") ,
560- MachineError ( ref msg) |
561- Unimplemented ( ref msg) |
562- AbiViolation ( ref msg) |
563- Intrinsic ( ref msg) =>
588+ Unsupported ( MachineError ( ref msg) ) |
589+ Unsupported ( Unimplemented ( ref msg) ) |
590+ Unsupported ( AbiViolation ( ref msg) ) |
591+ Unsupported ( Intrinsic ( ref msg) ) =>
564592 write ! ( f, "{}" , msg) ,
593+ InvalidProgram ( ref msg) =>
594+ write ! ( f, "{:?}" , msg) ,
595+ UndefinedBehaviour ( ref msg) =>
596+ write ! ( f, "{:?}" , msg) ,
597+ ResourceExhaustion ( ref msg) =>
598+ write ! ( f, "{:?}" , msg) ,
565599 Panic ( ref msg) =>
566600 write ! ( f, "{:?}" , msg) ,
601+ Exit ( code) =>
602+ write ! ( f, "exited with status code {}" , code) ,
567603 }
568604 }
569605}
0 commit comments