diff options
| author | John Hodge <tpg@ucc.asn.au> | 2017-11-18 09:54:03 +0800 | 
|---|---|---|
| committer | John Hodge <tpg@ucc.asn.au> | 2017-11-18 17:47:12 +0800 | 
| commit | 2134d5f477bdb45de99aeb758b1f36a1009446f8 (patch) | |
| tree | 93c66aa6ae145966a554a174ff859417b5531855 | |
| parent | d26ff40497e9468f45612f19a14a415146e6334d (diff) | |
| download | mrust-2134d5f477bdb45de99aeb758b1f36a1009446f8.tar.gz | |
Expand - Import macros from parent crates
| -rw-r--r-- | src/expand/mod.cpp | 17 | 
1 files changed, 16 insertions, 1 deletions
| diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 9c9693cf..a88aa3df 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -981,10 +981,25 @@ void Expand_ImplDef(::AST::Crate& crate, LList<const AST::Module*> modstack, ::A  void Expand_Mod(::AST::Crate& crate, LList<const AST::Module*> modstack, ::AST::Path modpath, ::AST::Module& mod, unsigned int first_item)  { -    TRACE_FUNCTION_F("modpath = " << modpath); +    TRACE_FUNCTION_F("modpath = " << modpath << ", first_item=" << first_item);      for( const auto& mi: mod.macro_imports_res() )          DEBUG("- Imports '" << mi.name << "'"); +    // Import all macros from parent module. +    if( first_item == 0 ) +    { +        for( const auto& mi: mod.macro_imports_res() ) +            DEBUG("- Imports '" << mi.name << "'"); +        if( modstack.m_prev ) +        { +            for(const auto& mac : modstack.m_prev->m_item->m_macro_imports) +            { +                mod.m_macro_imports.push_back(mac); +            } +        } +        for( const auto& mi: mod.m_macro_imports ) +            DEBUG("- Imports '" << mi.first << "'"); +    }      // Insert prelude if: Enabled for this module, present for the crate, and this module is not an anon      if( crate.m_prelude_path != AST::Path() ) | 
