summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-12-22 20:38:38 +0800
committerJohn Hodge <tpg@mutabah.net>2018-12-22 20:38:38 +0800
commit48c0451b76c6f91ee467d8cac0e0c7fd475c8b46 (patch)
tree247cf29504f5557aef5c3796c95f93460dc40a4a
parent52cd5e2947f634df8bfa7da89ee33eee82134ff7 (diff)
downloadmrust-48c0451b76c6f91ee467d8cac0e0c7fd475c8b46.tar.gz
Resolve Use - Support glob from external module
-rw-r--r--src/resolve/use.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index 23f7e70c..db942641 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -428,28 +428,36 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
//out_path = imp_data.path;
}
- TU_MATCH_DEF(::AST::PathBinding, (*binding), (e),
- (
- BUG(sp2, "Wildcard import expanded to an invalid item class - " << binding->tag_str());
- ),
- (Crate,
+ TU_MATCH_HDR( (*binding), {)
+ TU_ARM(*binding, Crate, e) {
assert(e.crate_);
const ::HIR::Module& hmod = e.crate_->m_hir->m_root_module;
auto rv = Resolve_Use_GetBinding__ext(sp2, crate, AST::Path("", { AST::PathNode(des_item_name,{}) }), hmod, 0, allow);
if( ! rv.is_Unbound() ) {
return mv$(rv);
}
- ),
- (Module,
+ }
+ TU_ARM(*binding, Module, e) {
auto allow_inner = (allow == Lookup::Any ? Lookup::AnyOpt : allow);
- assert(e.module_);
- // TODO: Prevent infinite recursion?
- auto rv = Resolve_Use_GetBinding_Mod(span, crate, *e.module_, des_item_name, {}, allow_inner);
- if( ! rv.is_Unbound() ) {
- return mv$(rv);
+ if( e.module_ ) {
+ // TODO: Prevent infinite recursion?
+ auto rv = Resolve_Use_GetBinding_Mod(span, crate, *e.module_, des_item_name, {}, allow_inner);
+ if( ! rv.is_Unbound() ) {
+ return mv$(rv);
+ }
}
- ),
- (Enum,
+ else if( e.hir ) {
+ const ::HIR::Module& hmod = *e.hir;
+ auto rv = Resolve_Use_GetBinding__ext(sp2, crate, AST::Path("", { AST::PathNode(des_item_name,{}) }), hmod, 0, allow);
+ if( ! rv.is_Unbound() ) {
+ return mv$(rv);
+ }
+ }
+ else {
+ BUG(span, "NULL module for binding on glob of " << imp_data.path);
+ }
+ }
+ TU_ARM(*binding, Enum, e) {
assert(e.enum_ || e.hir);
if( e.enum_ ) {
const auto& enm = *e.enum_;
@@ -470,8 +478,11 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
return ::AST::PathBinding::make_EnumVar({ nullptr, static_cast<unsigned>(idx), &enm });
}
}
- )
- )
+ } break;
+ default:
+ BUG(sp2, "Wildcard import expanded to an invalid item class - " << binding->tag_str());
+ break;
+ }
}
}