diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-30 22:06:28 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-30 22:16:53 +0800 |
commit | eefa619b01e161ce59ff39e8e0c8a17a8fa1701a (patch) | |
tree | 6fdd43f2ff2929f505712a664aeea571548fe348 /src/resolve | |
parent | eeb4c4a16a98bf6896af97c57aa6ccda5aa2de40 (diff) | |
download | mrust-eefa619b01e161ce59ff39e8e0c8a17a8fa1701a.tar.gz |
Resolve use - Handle variant imports
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/use.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index b5afcbc3..9c5bf090 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -565,8 +565,14 @@ namespace { const auto* item_ptr = &it->second->ent; if( item_ptr->is_Import() ) { const auto& e = item_ptr->as_Import(); - // This doesn't need to recurse - it can just do a single layer (as no Import should refer to another) const auto& ec = crate.m_extern_crates.at( e.path.m_crate_name ); + // This doesn't need to recurse - it can just do a single layer (as no Import should refer to another) + if( e.is_variant ) { + auto p = e.path; + p.m_components.pop_back(); + const auto& enm = ec.m_hir->get_typeitem_by_path(span, p, true).as_Enum(); + return ::AST::PathBinding::make_EnumVar({ nullptr, e.idx, &enm }); + } item_ptr = &ec.m_hir->get_typeitem_by_path(span, e.path, true); // ignore_crate_name=true } TU_MATCHA( (*item_ptr), (e), @@ -600,6 +606,12 @@ namespace { const auto& e = item_ptr->as_Import(); // This doesn't need to recurse - it can just do a single layer (as no Import should refer to another) const auto& ec = crate.m_extern_crates.at( e.path.m_crate_name ); + if( e.is_variant ) { + auto p = e.path; + p.m_components.pop_back(); + const auto& enm = ec.m_hir->get_typeitem_by_path(span, p, true).as_Enum(); + return ::AST::PathBinding::make_EnumVar({ nullptr, e.idx, &enm }); + } item_ptr = &ec.m_hir->get_valitem_by_path(span, e.path, true); // ignore_crate_name=true } TU_MATCHA( (*item_ptr), (e), |