summaryrefslogtreecommitdiff
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
parentd5f638d90d7f8a65423ed6df15e4ac6cad6d9855 (diff)
downloadmrust-5c7994fe17d98405a1d533b1d9ac0579767f6a90.tar.gz
MIR Match Gen - Fix incorrect arms chosen
-rw-r--r--src/mir/from_hir_match.cpp4
-rw-r--r--src/mir/optimise.cpp2
-rw-r--r--src/trans/codegen_c.cpp2
3 files changed, 4 insertions, 4 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();
diff --git a/src/mir/optimise.cpp b/src/mir/optimise.cpp
index 72651dd3..d599c07c 100644
--- a/src/mir/optimise.cpp
+++ b/src/mir/optimise.cpp
@@ -74,7 +74,6 @@ void MIR_Optimise(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
)
}
- #if 0
// GC pass on blocks and variables
// - Find unused blocks, then delete and rewrite all references.
{
@@ -173,5 +172,4 @@ void MIR_Optimise(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
}
}
}
- #endif
}
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 1a0ba042..e5a97f85 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -410,7 +410,7 @@ namespace {
emit_lvalue(e.dst);
m_of << " = ";
bool special = false;
- // If the inner value has type [T] or str, just assign.
+ // If the inner value has type [T] or str, create DST based on inner pointer and existing metadata
TU_IFLET(::MIR::LValue, ve.val, Deref, e,
::HIR::TypeRef tmp;
const auto& ty = mir_res.get_lvalue_type(tmp, ve.val); // NOTE: Checks the result of the deref