@@ -142,7 +142,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
142
142
InterpError :: InvalidProgram ( Layout ( LayoutError :: Unknown ( _) ) ) |
143
143
InterpError :: InvalidProgram ( TooGeneric ) =>
144
144
return Err ( ErrorHandled :: TooGeneric ) ,
145
- InterpError :: Layout ( LayoutError :: SizeOverflow ( _) ) |
145
+ InterpError :: InvalidProgram ( Layout ( LayoutError :: SizeOverflow ( _) ) ) |
146
146
InterpError :: InvalidProgram ( TypeckError ) =>
147
147
return Err ( ErrorHandled :: Reported ) ,
148
148
_ => { } ,
@@ -325,16 +325,47 @@ pub enum InvalidProgramInfo<'tcx> {
325
325
Layout ( layout:: LayoutError < ' tcx > ) ,
326
326
}
327
327
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
+
328
344
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
329
345
pub 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.
331
347
Ub ( String ) ,
348
+ /// Unreachable code was executed.
332
349
Unreachable ,
333
350
}
334
351
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
+
335
364
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
336
365
pub enum UnsupportedInfo < ' tcx > {
337
366
Unimplemented ( String ) ,
367
+
368
+ // -- Everything below is not classified yet --
338
369
FunctionAbiMismatch ( Abi , Abi ) ,
339
370
FunctionArgMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
340
371
FunctionRetMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
@@ -400,6 +431,19 @@ pub enum ResourceExhaustionInfo {
400
431
InfiniteLoop ,
401
432
}
402
433
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
+
403
447
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
404
448
pub enum InterpError < ' tcx > {
405
449
/// The program panicked.
@@ -431,139 +475,131 @@ impl fmt::Display for InterpError<'_> {
431
475
impl fmt:: Debug for InterpError < ' _ > {
432
476
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
433
477
use InterpError :: * ;
478
+ use UnsupportedInfo :: * ;
434
479
match * self {
435
- PointerOutOfBounds { ptr, msg, allocation_size } => {
480
+ Unsupported ( PointerOutOfBounds { ptr, msg, allocation_size } ) => {
436
481
write ! ( f, "{} failed: pointer must be in-bounds at offset {}, \
437
482
but is outside bounds of allocation {} which has size {}",
438
483
msg, ptr. offset. bytes( ) , ptr. alloc_id, allocation_size. bytes( ) )
439
484
} ,
440
- ValidationFailure ( ref err) => {
485
+ Unsupported ( ValidationFailure ( ref err) ) => {
441
486
write ! ( f, "type validation failed: {}" , err)
442
487
}
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) ) =>
445
490
write ! ( f, "tried to call a function with ABI {:?} using caller ABI {:?}" ,
446
491
callee_abi, caller_abi) ,
447
- FunctionArgMismatch ( caller_ty, callee_ty) =>
492
+ Unsupported ( FunctionArgMismatch ( caller_ty, callee_ty) ) =>
448
493
write ! ( f, "tried to call a function with argument of type {:?} \
449
494
passing data of type {:?}",
450
495
callee_ty, caller_ty) ,
451
- FunctionRetMismatch ( caller_ty, callee_ty) =>
496
+ Unsupported ( FunctionRetMismatch ( caller_ty, callee_ty) ) =>
452
497
write ! ( f, "tried to call a function with return type {:?} \
453
498
passing return place of type {:?}",
454
499
callee_ty, caller_ty) ,
455
- FunctionArgCountMismatch =>
500
+ Unsupported ( FunctionArgCountMismatch ) =>
456
501
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) ) =>
458
503
write ! ( f, "tried to reallocate memory from {} to {}" , old, new) ,
459
- DeallocatedWrongMemoryKind ( ref old, ref new) =>
504
+ Unsupported ( DeallocatedWrongMemoryKind ( ref old, ref new) ) =>
460
505
write ! ( f, "tried to deallocate {} memory but gave {} as the kind" , old, new) ,
461
- InvalidChar ( c) =>
506
+ Unsupported ( InvalidChar ( c) ) =>
462
507
write ! ( f, "tried to interpret an invalid 32-bit value as a char: {}" , c) ,
463
- AlignmentCheckFailed { required, has } =>
508
+ Unsupported ( AlignmentCheckFailed { required, has } ) =>
464
509
write ! ( f, "tried to access memory with alignment {}, but alignment {} is required" ,
465
510
has. bytes( ) , required. bytes( ) ) ,
466
- TypeNotPrimitive ( ty) =>
511
+ Unsupported ( TypeNotPrimitive ( ty) ) =>
467
512
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) ) =>
471
514
write ! ( f, "Cannot find path {:?}" , path) ,
472
- IncorrectAllocationInformation ( size, size2, align, align2) =>
515
+ Unsupported ( IncorrectAllocationInformation ( size, size2, align, align2) ) =>
473
516
write ! ( f, "incorrect alloc info: expected size {} and align {}, \
474
517
got size {} and align {}",
475
518
size. bytes( ) , align. bytes( ) , size2. bytes( ) , align2. bytes( ) ) ,
476
- InvalidDiscriminant ( val) =>
519
+ Unsupported ( InvalidDiscriminant ( val) ) =>
477
520
write ! ( f, "encountered invalid enum discriminant {}" , val) ,
478
- Exit ( code) =>
479
- write ! ( f, "exited with status code {}" , code) ,
480
- InvalidMemoryAccess =>
521
+ Unsupported ( InvalidMemoryAccess ) =>
481
522
write ! ( f, "tried to access memory through an invalid pointer" ) ,
482
- DanglingPointerDeref =>
523
+ Unsupported ( DanglingPointerDeref ) =>
483
524
write ! ( f, "dangling pointer was dereferenced" ) ,
484
- DoubleFree =>
525
+ Unsupported ( DoubleFree ) =>
485
526
write ! ( f, "tried to deallocate dangling pointer" ) ,
486
- InvalidFunctionPointer =>
527
+ Unsupported ( InvalidFunctionPointer ) =>
487
528
write ! ( f, "tried to use a function pointer after offsetting it" ) ,
488
- InvalidBool =>
529
+ Unsupported ( InvalidBool ) =>
489
530
write ! ( f, "invalid boolean value read" ) ,
490
- InvalidNullPointerUsage =>
531
+ Unsupported ( InvalidNullPointerUsage ) =>
491
532
write ! ( f, "invalid use of NULL pointer" ) ,
492
- ReadPointerAsBytes =>
533
+ Unsupported ( ReadPointerAsBytes ) =>
493
534
write ! ( f, "a raw memory access tried to access part of a pointer value as raw \
494
535
bytes") ,
495
- ReadBytesAsPointer =>
536
+ Unsupported ( ReadBytesAsPointer ) =>
496
537
write ! ( f, "a memory access tried to interpret some bytes as a pointer" ) ,
497
- ReadForeignStatic =>
538
+ Unsupported ( ReadForeignStatic ) =>
498
539
write ! ( f, "tried to read from foreign (extern) static" ) ,
499
- InvalidPointerMath =>
540
+ Unsupported ( InvalidPointerMath ) =>
500
541
write ! ( f, "attempted to do invalid arithmetic on pointers that would leak base \
501
542
addresses, e.g., comparing pointers into different allocations") ,
502
- DeadLocal =>
543
+ Unsupported ( DeadLocal ) =>
503
544
write ! ( f, "tried to access a dead local variable" ) ,
504
- DerefFunctionPointer =>
545
+ Unsupported ( DerefFunctionPointer ) =>
505
546
write ! ( f, "tried to dereference a function pointer" ) ,
506
- ExecuteMemory =>
547
+ Unsupported ( ExecuteMemory ) =>
507
548
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 ) =>
511
550
write ! ( f, "reached the maximum number of representable TLS keys" ) ,
512
- TlsOutOfBounds =>
551
+ Unsupported ( TlsOutOfBounds ) =>
513
552
write ! ( f, "accessed an invalid (unallocated) TLS key" ) ,
514
- CalledClosureAsFunction =>
553
+ Unsupported ( CalledClosureAsFunction ) =>
515
554
write ! ( f, "tried to call a closure through a function pointer" ) ,
516
- VtableForArgumentlessMethod =>
555
+ Unsupported ( VtableForArgumentlessMethod ) =>
517
556
write ! ( f, "tried to call a vtable function without arguments" ) ,
518
- ModifiedConstantMemory =>
557
+ Unsupported ( ModifiedConstantMemory ) =>
519
558
write ! ( f, "tried to modify constant memory" ) ,
520
- ModifiedStatic =>
559
+ Unsupported ( ModifiedStatic ) =>
521
560
write ! ( f, "tried to modify a static's initial value from another static's \
522
561
initializer") ,
523
- AssumptionNotHeld =>
562
+ Unsupported ( AssumptionNotHeld ) =>
524
563
write ! ( f, "`assume` argument was false" ) ,
525
- InlineAsm =>
564
+ Unsupported ( InlineAsm ) =>
526
565
write ! ( f, "miri does not support inline assembly" ) ,
527
- ReallocateNonBasePtr =>
566
+ Unsupported ( ReallocateNonBasePtr ) =>
528
567
write ! ( f, "tried to reallocate with a pointer not to the beginning of an \
529
568
existing object") ,
530
- DeallocateNonBasePtr =>
569
+ Unsupported ( DeallocateNonBasePtr ) =>
531
570
write ! ( f, "tried to deallocate with a pointer not to the beginning of an \
532
571
existing object") ,
533
- HeapAllocZeroBytes =>
572
+ Unsupported ( HeapAllocZeroBytes ) =>
534
573
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 ) =>
538
575
write ! ( f, "tried to read from the return pointer" ) ,
539
- UnimplementedTraitSelection =>
576
+ Unsupported ( UnimplementedTraitSelection ) =>
540
577
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 ( _) ) =>
551
579
write ! ( f, "invalid boolean operation" ) ,
552
- UnterminatedCString ( _) =>
580
+ Unsupported ( UnterminatedCString ( _) ) =>
553
581
write ! ( f, "attempted to get length of a null terminated string, but no null \
554
582
found before end of allocation") ,
555
- ReadUndefBytes ( _) =>
583
+ Unsupported ( ReadUndefBytes ( _) ) =>
556
584
write ! ( f, "attempted to read undefined bytes" ) ,
557
- HeapAllocNonPowerOfTwoAlignment ( _) =>
585
+ Unsupported ( HeapAllocNonPowerOfTwoAlignment ( _) ) =>
558
586
write ! ( f, "tried to re-, de-, or allocate heap memory with alignment that is \
559
587
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) ) =>
564
592
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) ,
565
599
Panic ( ref msg) =>
566
600
write ! ( f, "{:?}" , msg) ,
601
+ Exit ( code) =>
602
+ write ! ( f, "exited with status code {}" , code) ,
567
603
}
568
604
}
569
605
}
0 commit comments