summaryrefslogtreecommitdiff
path: root/src/trans/codegen.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-11-01 20:46:36 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-11-01 20:46:36 +0800
commitcb271f8ea98d1a5c65a5e636a0e73a85710027b4 (patch)
tree9694427c074c0e0d581cde6e01b6167016e0f844 /src/trans/codegen.cpp
parent8306f43ccdf0414b48891aa5eb04d8901899c052 (diff)
downloadmrust-cb271f8ea98d1a5c65a5e636a0e73a85710027b4.tar.gz
HIR - Refactor enums to only embed a single field (and give variants types)
Diffstat (limited to 'src/trans/codegen.cpp')
-rw-r--r--src/trans/codegen.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/trans/codegen.cpp b/src/trans/codegen.cpp
index e7cea40d..e95ff08e 100644
--- a/src/trans/codegen.cpp
+++ b/src/trans/codegen.cpp
@@ -65,8 +65,7 @@ void Trans_Codegen(const ::std::string& outfile, const TransOptions& opt, const
const auto& nse = crate.get_typeitem_by_path(sp, path.m_path, false, true);
if(const auto* e = nse.opt_Enum())
{
- auto it = ::std::find_if(e->m_variants.begin(), e->m_variants.end(), [&](const auto& x){ return x.first == path.m_path.m_components.back(); });
- auto var_idx = it - e->m_variants.begin();
+ auto var_idx = e->find_variant(path.m_path.m_components.back());
codegen->emit_constructor_enum(sp, path, *e, var_idx);
continue ;
}