diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-07 11:38:03 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-07 11:38:03 +0800 |
commit | 57df16360d231f60d2030f490c1e73149b47857d (patch) | |
tree | ab9d5051f96822fd33e49efd3b5a096b37199832 /src/ast/crate.cpp | |
parent | 93f6933b3b0493644e40be87de9b1955457c7da4 (diff) | |
download | mrust-57df16360d231f60d2030f490c1e73149b47857d.tar.gz |
LoadCrates - Better error reporting
Diffstat (limited to 'src/ast/crate.cpp')
-rw-r--r-- | src/ast/crate.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index fe084b54..49f9242f 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -50,21 +50,28 @@ void Crate::load_externs() const auto& name = c.name; if( check_item_cfg(it.data.attrs) ) { - load_extern_crate( name ); + load_extern_crate( it.data.span, name ); } ) } }; iterate_module(m_root_module, cb); } -void Crate::load_extern_crate(const ::std::string& name) +void Crate::load_extern_crate(Span sp, const ::std::string& name) { - m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, "output/lib"+name+".hir" } )); + DEBUG("Loading crate '" << name << "'"); + // TODO: Search a list of load paths for the crate + ::std::string path = "output/lib"+name+".hir"; + if( !::std::ifstream(path).good() ) { + ERROR(sp, E0000, "Unable to locate crate '" << name << "'"); + } + m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, path } )); } ExternCrate::ExternCrate(const ::std::string& name, const ::std::string& path): m_name(name) { + TRACE_FUNCTION_F("name=" << name << ", path='" << path << "'"); m_hir = HIR_Deserialise(path, name); m_hir->post_load_update(name); |