about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Vandel Sillesen <simon.vandel@gmail.com>2020-09-19 23:22:54 +0200
committerSimon Vandel Sillesen <simon.vandel@gmail.com>2020-09-19 23:22:54 +0200
commita875c7a1ea31f86d4a796209f50303564ce15a16 (patch)
tree070a75a2b2da775d5b052601064c886fea3dec93
parent738ed9b5ec62259eb0f2aced549feec2f7e7c75a (diff)
downloadrust-a875c7a1ea31f86d4a796209f50303564ce15a16.tar.gz
rust-a875c7a1ea31f86d4a796209f50303564ce15a16.zip
Add assertion for len of vecs
-rw-r--r--compiler/rustc_mir/src/transform/simplify_try.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_mir/src/transform/simplify_try.rs b/compiler/rustc_mir/src/transform/simplify_try.rs
index bf6fdebb3d3..4935997eb82 100644
--- a/compiler/rustc_mir/src/transform/simplify_try.rs
+++ b/compiler/rustc_mir/src/transform/simplify_try.rs
@@ -568,14 +568,15 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
             .basic_blocks()
             .iter_enumerated()
             .filter_map(|(bb_idx, bb)| {
-                let (discr_switched_on, targets_and_values):(_, Vec<_>) = match &bb.terminator().kind {
+                let (discr_switched_on, targets_and_values) = match &bb.terminator().kind {
                     TerminatorKind::SwitchInt { targets, discr, values, .. } => {
                         // if values.len() == targets.len() - 1, we need to include None where no value is present
                         // such that the zip does not throw away targets. If no `otherwise` case is in targets, the zip will simply throw away the added None
                         let values_extended = values.iter().map(|x|Some(*x)).chain(once(None));
-                        let targets_and_values = targets.iter().zip(values_extended)
-                            .map(|(target, value)| SwitchTargetAndValue{target:*target, value:value})
+                        let targets_and_values:Vec<_> = targets.iter().zip(values_extended)
+                            .map(|(target, value)| SwitchTargetAndValue{target:*target, value})
                             .collect();
+                        assert_eq!(targets.len(), targets_and_values.len());
                         (discr, targets_and_values)},
                     _ => return None,
                 };