]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/mir/interpret/error.rs
Remove duplication using single variant for error
[rust.git] / src / librustc / mir / interpret / error.rs
index 93543bc361643587f39cace61ac8bdbc79354a6b..6ff1eee593b59e2e6271fb402e120c5d4d550ba0 100644 (file)
@@ -13,7 +13,7 @@
 use rustc_target::spec::abi::Abi;
 use syntax_pos::{Pos, Span};
 use syntax::symbol::Symbol;
-
+use hir::GeneratorKind;
 use std::{fmt, env};
 
 use rustc_error_codes::*;
@@ -264,10 +264,8 @@ pub enum PanicInfo<O> {
     OverflowNeg,
     DivisionByZero,
     RemainderByZero,
-    GeneratorResumedAfterReturn,
-    GeneratorResumedAfterPanic,
-    AsyncResumedAfterReturn,
-    AsyncResumedAfterPanic,
+    ResumedAfterReturn(GeneratorKind),
+    ResumedAfterPanic(GeneratorKind),
 }
 
 /// Type for MIR `Assert` terminator error messages.
@@ -302,14 +300,16 @@ pub fn description(&self) -> &'static str {
                 "attempt to divide by zero",
             RemainderByZero =>
                 "attempt to calculate the remainder with a divisor of zero",
-            GeneratorResumedAfterReturn =>
+            ResumedAfterReturn(GeneratorKind::Gen) =>
                 "generator resumed after completion",
-            GeneratorResumedAfterPanic =>
-                "generator resumed after panicking",
-            AsyncResumedAfterReturn =>
+            // FIXME: Do we want a separate message for each Async variant (Block, Closure, Fn)?
+            ResumedAfterReturn(GeneratorKind::Async(_)) =>
                 "`async fn` resumed after completion",
-            AsyncResumedAfterPanic =>
-                "`async fn` resumed after panic",
+            ResumedAfterPanic(GeneratorKind::Gen) =>
+                "generator resumed after panicking",
+            // FIXME: Do we want a separate message for each Async variant (Block, Closure, Fn)?
+            ResumedAfterPanic(GeneratorKind::Async(_)) =>
+                "`async fn` resumed after panicking",
             Panic { .. } | BoundsCheck { .. } =>
                 bug!("Unexpected PanicInfo"),
         }