summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-28 18:42:51 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-28 18:42:51 +0800
commit8c8869627ed1373f4e8e5af8550f37d07bdd71c1 (patch)
treed7eb288227bcb6140c0e5958e7f9440cd5fe001f /src
parent9a1bacab4fdb2a98ffe1e7a32a5b00effc8bd01a (diff)
downloadmrust-8c8869627ed1373f4e8e5af8550f37d07bdd71c1.tar.gz
HIR From AST - Handle missing anon modules
Diffstat (limited to 'src')
-rw-r--r--src/hir/from_ast.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 22477926..4dd6fe92 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1021,10 +1021,14 @@ void _add_mod_val_item(::HIR::Module& mod, ::std::string name, bool is_pub, ::H
for( unsigned int i = 0; i < ast_mod.anon_mods().size(); i ++ )
{
- auto& submod = *ast_mod.anon_mods()[i];
- ::std::string name = FMT("#" << i);
- auto item_path = ::HIR::ItemPath(path, name.c_str());
- _add_mod_ns_item( mod, mv$(name), false, ::HIR::TypeItem::make_Module( LowerHIR_Module(submod, item_path, mod.m_traits) ) );
+ const auto& submod_ptr = ast_mod.anon_mods()[i];
+ if( submod_ptr )
+ {
+ auto& submod = *submod_ptr;
+ ::std::string name = FMT("#" << i);
+ auto item_path = ::HIR::ItemPath(path, name.c_str());
+ _add_mod_ns_item( mod, mv$(name), false, ::HIR::TypeItem::make_Module( LowerHIR_Module(submod, item_path, mod.m_traits) ) );
+ }
}
for( const auto& item : ast_mod.items() )
@@ -1132,7 +1136,9 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat
}
for( const auto& submod_ptr : ast_mod.anon_mods() )
{
- LowerHIR_Module_Impls(*submod_ptr, hir_crate);
+ if( submod_ptr ) {
+ LowerHIR_Module_Impls(*submod_ptr, hir_crate);
+ }
}
//