@@ -137,12 +137,13 @@ impl<'tcx> ConstEvalErr<'tcx> {
137
137
message : & str ,
138
138
lint_root : Option < hir:: HirId > ,
139
139
) -> Result < DiagnosticBuilder < ' tcx > , ErrorHandled > {
140
+ use InvalidProgramInfo :: * ;
140
141
match self . error {
141
- InterpError :: Layout ( LayoutError :: Unknown ( _) ) |
142
- InterpError :: InvalidProgram ( InvalidProgramMessage :: TooGeneric ) =>
142
+ InterpError :: InvalidProgram ( Layout ( LayoutError :: Unknown ( _) ) ) |
143
+ InterpError :: InvalidProgram ( TooGeneric ) =>
143
144
return Err ( ErrorHandled :: TooGeneric ) ,
144
145
InterpError :: Layout ( LayoutError :: SizeOverflow ( _) ) |
145
- InterpError :: InvalidProgram ( InvalidProgramMessage :: TypeckError ) =>
146
+ InterpError :: InvalidProgram ( TypeckError ) =>
146
147
return Err ( ErrorHandled :: Reported ) ,
147
148
_ => { } ,
148
149
}
@@ -312,42 +313,74 @@ impl<O: fmt::Debug> fmt::Debug for PanicMessage<O> {
312
313
}
313
314
314
315
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
315
- pub enum InvalidProgramMessage {
316
+ pub enum InvalidProgramInfo < ' tcx > {
316
317
/// Resolution can fail if we are in a too generic context
317
318
TooGeneric ,
318
319
/// Cannot compute this constant because it depends on another one
319
320
/// which already produced an error
320
321
ReferencedConstant ,
321
322
/// Abort in case type errors are reached
322
323
TypeckError ,
324
+ Layout ( layout:: LayoutError < ' tcx > ) ,
323
325
}
324
326
325
327
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
326
- pub enum UndefinedBehaviourMessage {
328
+ pub enum UndefinedBehaviourInfo {
329
+ Unreachable ,
327
330
}
328
331
329
332
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
330
- pub enum UnsupportedMessage {
333
+ pub enum UnsupportedInfo < ' tcx > {
334
+ FunctionAbiMismatch ( Abi , Abi ) ,
335
+ FunctionArgMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
336
+ FunctionRetMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
337
+ FunctionArgCountMismatch ,
338
+ UnterminatedCString ( Pointer ) ,
339
+ DanglingPointerDeref ,
340
+ DoubleFree ,
341
+ InvalidMemoryAccess ,
342
+ InvalidFunctionPointer ,
343
+ InvalidBool ,
344
+ InvalidDiscriminant ( ScalarMaybeUndef ) ,
345
+ PointerOutOfBounds {
346
+ ptr : Pointer ,
347
+ msg : CheckInAllocMsg ,
348
+ allocation_size : Size ,
349
+ } ,
350
+ InvalidNullPointerUsage ,
351
+ ReadPointerAsBytes ,
352
+ ReadBytesAsPointer ,
353
+ ReadForeignStatic ,
354
+ InvalidPointerMath ,
355
+ ReadUndefBytes ( Size ) ,
356
+ DeadLocal ,
357
+ InvalidBoolOp ( mir:: BinOp ) ,
358
+ InlineAsm ,
359
+ UnimplementedTraitSelection ,
360
+ CalledClosureAsFunction ,
361
+ NoMirFor ( String ) ,
331
362
}
332
363
333
364
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
334
- pub enum ResourceExhaustionMessage {
365
+ pub enum ResourceExhaustionInfo {
366
+ StackFrameLimitReached ,
367
+ InfiniteLoop ,
335
368
}
336
369
337
370
#[ derive( Clone , RustcEncodable , RustcDecodable , HashStable ) ]
338
371
pub enum InterpError < ' tcx > {
339
372
/// The program panicked.
340
373
Panic ( PanicMessage < u64 > ) ,
341
374
/// The program caused undefined behavior.
342
- UndefinedBehaviour ( UndefinedBehaviourMessage ) ,
375
+ UndefinedBehaviour ( UndefinedBehaviourInfo ) ,
343
376
/// The program did something the interpreter does not support (some of these *might* be UB
344
377
/// but the interpreter is not sure).
345
- Unsupported ( UnsupportedMessage ) ,
378
+ Unsupported ( UnsupportedInfo < ' tcx > ) ,
346
379
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
347
- InvalidProgram ( InvalidProgramMessage ) ,
380
+ InvalidProgram ( InvalidProgramInfo < ' tcx > ) ,
348
381
/// The program exhausted the interpreter's resources (stack/heap too big,
349
382
/// execution takes too long, ..).
350
- ResourceExhaustion ( ResourceExhaustionMessage ) ,
383
+ ResourceExhaustion ( ResourceExhaustionInfo ) ,
351
384
352
385
/// THe above 5 variants are what we want to group all the remaining InterpError variants into
353
386
@@ -359,37 +392,11 @@ pub enum InterpError<'tcx> {
359
392
/// with the given status code. Used by Miri, but not by CTFE.
360
393
Exit ( i32 ) ,
361
394
362
- FunctionAbiMismatch ( Abi , Abi ) ,
363
- FunctionArgMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
364
- FunctionRetMismatch ( Ty < ' tcx > , Ty < ' tcx > ) ,
365
- FunctionArgCountMismatch ,
366
- NoMirFor ( String ) ,
367
- UnterminatedCString ( Pointer ) ,
368
- DanglingPointerDeref ,
369
- DoubleFree ,
370
- InvalidMemoryAccess ,
371
- InvalidFunctionPointer ,
372
- InvalidBool ,
373
- InvalidDiscriminant ( ScalarMaybeUndef ) ,
374
- PointerOutOfBounds {
375
- ptr : Pointer ,
376
- msg : CheckInAllocMsg ,
377
- allocation_size : Size ,
378
- } ,
379
- InvalidNullPointerUsage ,
380
- ReadPointerAsBytes ,
381
- ReadBytesAsPointer ,
382
- ReadForeignStatic ,
383
- InvalidPointerMath ,
384
- ReadUndefBytes ( Size ) ,
385
- DeadLocal ,
386
- InvalidBoolOp ( mir:: BinOp ) ,
387
395
Unimplemented ( String ) ,
388
396
DerefFunctionPointer ,
389
397
ExecuteMemory ,
390
398
Intrinsic ( String ) ,
391
399
InvalidChar ( u128 ) ,
392
- StackFrameLimitReached ,
393
400
OutOfTls ,
394
401
TlsOutOfBounds ,
395
402
AbiViolation ( String ) ,
@@ -398,25 +405,20 @@ pub enum InterpError<'tcx> {
398
405
has : Align ,
399
406
} ,
400
407
ValidationFailure ( String ) ,
401
- CalledClosureAsFunction ,
402
408
VtableForArgumentlessMethod ,
403
409
ModifiedConstantMemory ,
404
410
ModifiedStatic ,
405
411
AssumptionNotHeld ,
406
- InlineAsm ,
407
412
TypeNotPrimitive ( Ty < ' tcx > ) ,
408
413
ReallocatedWrongMemoryKind ( String , String ) ,
409
414
DeallocatedWrongMemoryKind ( String , String ) ,
410
415
ReallocateNonBasePtr ,
411
416
DeallocateNonBasePtr ,
412
417
IncorrectAllocationInformation ( Size , Size , Align , Align ) ,
413
- Layout ( layout:: LayoutError < ' tcx > ) ,
414
418
HeapAllocZeroBytes ,
415
419
HeapAllocNonPowerOfTwoAlignment ( u64 ) ,
416
- Unreachable ,
417
420
ReadFromReturnPointer ,
418
421
PathNotFound ( Vec < String > ) ,
419
- UnimplementedTraitSelection ,
420
422
}
421
423
422
424
pub type InterpResult < ' tcx , T = ( ) > = Result < T , InterpErrorInfo < ' tcx > > ;
0 commit comments