diff options
Diffstat (limited to 'src/ast/crate.cpp')
-rw-r--r-- | src/ast/crate.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index 49f9242f..fc93a809 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -56,6 +56,29 @@ void Crate::load_externs() } }; iterate_module(m_root_module, cb); + + // Check for no_std or no_core, and load libstd/libcore + // - Duplicates some of the logic in "Expand", but also helps keep crate loading separate to most of expand + bool no_std = false; + bool no_core = false; + + for( const auto& a : this->m_attrs.m_items ) + { + if( a.name() == "no_std" ) + no_std = true; + if( a.name() == "no_core" ) + no_core = true; + } + + if( no_core ) { + // Don't load anything + } + else if( no_std ) { + this->load_extern_crate(Span(), "core"); + } + else { + this->load_extern_crate(Span(), "std"); + } } void Crate::load_extern_crate(Span sp, const ::std::string& name) { |