From 502cc9c8dc1941877b35e45d742a3e36264671ca Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 9 Jun 2016 09:54:57 +0800 Subject: HIR - Save and use paths to #[lang] items --- src/expand/lang_item.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/expand/lang_item.cpp') diff --git a/src/expand/lang_item.cpp b/src/expand/lang_item.cpp index c34642db..6d90370a 100644 --- a/src/expand/lang_item.cpp +++ b/src/expand/lang_item.cpp @@ -11,17 +11,18 @@ #include "../ast/crate.hpp" -void handle_lang_item(AST::Crate& crate, const AST::Path& path, const ::std::string& name, AST::eItemType type) +void handle_lang_item(const Span& sp, AST::Crate& crate, const AST::Path& path, const ::std::string& name, AST::eItemType type) { if(name == "phantom_fn") { - crate.m_lang_item_PhantomFn = AST::Path(path); - crate.m_lang_item_PhantomFn.nodes().back().args().m_types = { TypeRef("A"), TypeRef("B") }; + // - Just save path } else if( name == "send" ) { // Don't care, Send is fully library in mrustc + // - Needed for `static` } else if( name == "sync" ) { // Don't care, Sync is fully library in mrustc + // - Needed for `static` } else if( name == "sized" ) { DEBUG("Bind 'sized' to " << path); @@ -90,10 +91,13 @@ void handle_lang_item(AST::Crate& crate, const AST::Path& path, const ::std::str else if( name == "str_eq" ) { } else { - throw CompileError::Generic(FMT("Unknown lang item '" << name << "'")); + ERROR(sp, E0000, "Unknown language item '" << name << "'"); } - + auto rv = crate.m_lang_items.insert( ::std::make_pair( name, ::AST::Path(path) ) ); + if( !rv.second ) { + ERROR(sp, E0000, "Duplicate definition of language item '" << name << "'"); + } } class Decorator_LangItem: @@ -108,13 +112,13 @@ public: TODO(sp, "Unknown item type with #[lang=\""<