diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-11 16:46:50 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-11 16:46:50 +0800 |
commit | 3052add7837b1a22ac3141a80bc367d08e1d3c19 (patch) | |
tree | 9d218efebba492bfdb13b2e558d84a3296ad3539 | |
parent | 4027602be710a7fb321486c68d5722480976713a (diff) | |
download | mrust-3052add7837b1a22ac3141a80bc367d08e1d3c19.tar.gz |
Resolve Use - Support HIR::ValueItem::Import
-rw-r--r-- | src/resolve/use.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 91e3ad84..4b22d9a6 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -449,9 +449,16 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path { auto it2 = hmod->m_value_items.find(nodes.back().name()); if( it2 != hmod->m_value_items.end() ) { - TU_MATCHA( (it2->second->ent), (e), + const auto* item_ptr = &it2->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.m_crate_name ); + item_ptr = &ec.m_hir->get_valitem_by_path(span, e, true); // ignore_crate_name=true + } + TU_MATCHA( (*item_ptr), (e), (Import, - TODO(span, "Recurse to get binding for an import - " << path << " = " << e); + BUG(span, "Recursive import in " << path << " - " << it2->second->ent.as_Import() << " -> " << e); ), (Constant, return ::AST::PathBinding::make_Static({ nullptr }); |