summaryrefslogtreecommitdiff
path: root/src/mir/from_hir_match.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-10 20:17:25 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-10 20:17:25 +0800
commit5c7994fe17d98405a1d533b1d9ac0579767f6a90 (patch)
treef33e9432fad5df73b1a8f173f690a29ae24502d5 /src/mir/from_hir_match.cpp
parentd5f638d90d7f8a65423ed6df15e4ac6cad6d9855 (diff)
downloadmrust-5c7994fe17d98405a1d533b1d9ac0579767f6a90.tar.gz
MIR Match Gen - Fix incorrect arms chosen
Diffstat (limited to 'src/mir/from_hir_match.cpp')
-rw-r--r--src/mir/from_hir_match.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index aea89764..c26dbc41 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -1985,11 +1985,13 @@ void MIR_LowerHIR_Match_DecisionTree( MirBuilder& builder, MirConverter& conv, :
// - Build tree by running each arm's pattern across it
DEBUG("- Building decision tree");
DecisionTreeNode root_node({});
+ unsigned int rule_idx = 0;
for( const auto& arm_rule : arm_rules )
{
auto arm_idx = arm_rule.arm_idx;
DEBUG("(" << arm_idx << ", " << arm_rule.pat_idx << "): " << arm_rule.m_rules);
- root_node.populate_tree_from_rule( node.m_arms[arm_idx].m_code->span(), arm_idx, arm_rule.m_rules.data(), arm_rule.m_rules.size() );
+ root_node.populate_tree_from_rule( node.m_arms[arm_idx].m_code->span(), rule_idx, arm_rule.m_rules.data(), arm_rule.m_rules.size() );
+ rule_idx += 1;
}
DEBUG("root_node = " << root_node);
root_node.simplify();