Skip to content

Commit 01859bb

Browse files
committed
grouping the variants of InterpError
1 parent 0aa9658 commit 01859bb

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/librustc/mir/interpret/error.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ impl<'tcx> ConstEvalErr<'tcx> {
139139
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
140140
match self.error {
141141
InterpError::Layout(LayoutError::Unknown(_)) |
142-
InterpError::TooGeneric => return Err(ErrorHandled::TooGeneric),
142+
InterpError::InvalidProgram(InvalidProgramMessage::TooGeneric) =>
143+
return Err(ErrorHandled::TooGeneric),
143144
InterpError::Layout(LayoutError::SizeOverflow(_)) |
144-
InterpError::TypeckError => return Err(ErrorHandled::Reported),
145+
InterpError::InvalidProgram(InvalidProgramMessage::TypeckError) =>
146+
return Err(ErrorHandled::Reported),
145147
_ => {},
146148
}
147149
trace!("reporting const eval failure at {:?}", self.span);
@@ -310,7 +312,7 @@ impl<O: fmt::Debug> fmt::Debug for PanicMessage<O> {
310312
}
311313

312314
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
313-
pub enum InvalidProgramMessage<'tcx> {
315+
pub enum InvalidProgramMessage {
314316
/// Resolution can fail if we are in a too generic context
315317
TooGeneric,
316318
/// Cannot compute this constant because it depends on another one
@@ -320,19 +322,35 @@ pub enum InvalidProgramMessage<'tcx> {
320322
TypeckError,
321323
}
322324

325+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
326+
pub enum UndefinedBehaviourMessage {
327+
}
328+
329+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
330+
pub enum UnsupportedMessage {
331+
}
332+
333+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
334+
pub enum ResourceExhaustionMessage {
335+
}
336+
323337
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
324338
pub enum InterpError<'tcx> {
339+
/// The program panicked.
340+
Panic(PanicMessage<u64>),
325341
/// The program caused undefined behavior.
326-
UndefinedBehaviour(UndefinedBehaviourMessage<'tcx>),
342+
UndefinedBehaviour(UndefinedBehaviourMessage),
327343
/// The program did something the interpreter does not support (some of these *might* be UB
328344
/// but the interpreter is not sure).
329-
Unsupported(UnsupportedMessage<'tcx>),
345+
Unsupported(UnsupportedMessage),
330346
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
331-
InvalidProgram(InvalidProgramMessage<'tcx>),
347+
InvalidProgram(InvalidProgramMessage),
332348
/// The program exhausted the interpreter's resources (stack/heap too big,
333349
/// execution takes too long, ..).
334-
ResourceExhaustion(ResourceExhaustionMessage<'tcx>),
335-
350+
ResourceExhaustion(ResourceExhaustionMessage),
351+
352+
/// THe above 5 variants are what we want to group all the remaining InterpError variants into
353+
336354
/// This variant is used by machines to signal their own errors that do not
337355
/// match an existing variant.
338356
MachineError(String),
@@ -396,8 +414,6 @@ pub enum InterpError<'tcx> {
396414
HeapAllocZeroBytes,
397415
HeapAllocNonPowerOfTwoAlignment(u64),
398416
Unreachable,
399-
/// The program panicked.
400-
Panic(PanicMessage<u64>),
401417
ReadFromReturnPointer,
402418
PathNotFound(Vec<String>),
403419
UnimplementedTraitSelection,

0 commit comments

Comments
 (0)