diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-11 18:07:43 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-11 18:07:43 +0800 |
commit | a98cb27dedfe3b5005ac2d7b6d876ced4b4b6fc7 (patch) | |
tree | 02e4f8c2d52ad011f6a3c1532f6d7fcf99011f4a /src/resolve/index.cpp | |
parent | d1edb6f8e5b9085ca3ad36d4c85d3bab810b19bc (diff) | |
download | mrust-a98cb27dedfe3b5005ac2d7b6d876ced4b4b6fc7.tar.gz |
Resolve - Include binding for struct constructors/values
Diffstat (limited to 'src/resolve/index.cpp')
-rw-r--r-- | src/resolve/index.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp index 70c25187..4e1766c6 100644 --- a/src/resolve/index.cpp +++ b/src/resolve/index.cpp @@ -172,10 +172,17 @@ void Resolve_Index_Module_Base(const AST::Crate& crate, AST::Module& mod) (Struct, _add_item_type(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); - // TODO: Items from extern crates don't populate e.struct_ correctly // - If the struct is a tuple-like struct, it presents in the value namespace - if( e.struct_ && e.struct_->m_data.is_Tuple() ) { - _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + assert(e.struct_ || e.hir); + if( e.struct_ ) { + if( e.struct_->m_data.is_Tuple() ) { + _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + } + } + else { + if( ! e.hir->m_data.is_Named() ) { + _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + } } ), (Static , _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); ), @@ -282,10 +289,10 @@ void Resolve_Index_Module_Wildcard(AST::Crate& crate, AST::Module& mod, bool han p.bind( ::AST::PathBinding::make_Module({nullptr, &e}) ); ), (Trait, - p.bind( ::AST::PathBinding::make_Trait({nullptr/*, &e*/}) ); + p.bind( ::AST::PathBinding::make_Trait({nullptr, &e}) ); ), (Struct, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({nullptr, &e}) ); ), (Enum, p.bind( ::AST::PathBinding::make_Enum({nullptr}) ); @@ -337,11 +344,12 @@ void Resolve_Index_Module_Wildcard(AST::Crate& crate, AST::Module& mod, bool han (Static, p.bind( ::AST::PathBinding::make_Static({nullptr}) ); ), + // TODO: What if these refer to an enum variant? (StructConstant, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({ nullptr, &crate.m_extern_crates.at(e.ty.m_crate_name).m_hir->get_typeitem_by_path(sp, e.ty, true).as_Struct() }) ); ), (StructConstructor, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({ nullptr, &crate.m_extern_crates.at(e.ty.m_crate_name).m_hir->get_typeitem_by_path(sp, e.ty, true).as_Struct() }) ); ), (Function, p.bind( ::AST::PathBinding::make_Function({nullptr}) ); |