about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_mir/transform/validate.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs
index 7a1393468ce..4039d1b50e8 100644
--- a/src/librustc_mir/transform/validate.rs
+++ b/src/librustc_mir/transform/validate.rs
@@ -90,11 +90,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
             TerminatorKind::Goto { target } => {
                 self.check_bb(terminator.source_info.span, *target);
             }
-            TerminatorKind::SwitchInt { targets, .. } => {
-                if targets.is_empty() {
+            TerminatorKind::SwitchInt { targets, values, .. } => {
+                if targets.len() != values.len() + 1 {
                     self.fail(
                         terminator.source_info.span,
-                        "encountered `SwitchInt` terminator with no target to jump to",
+                        format!(
+                            "encountered `SwitchInt` terminator with {} values, but {} targets (should be values+1)",
+                            values.len(),
+                            targets.len(),
+                        ),
                     );
                 }
                 for target in targets {