diff options
Diffstat (limited to 'gcc/rust/resolve/rust-early-name-resolver.cc')
-rw-r--r-- | gcc/rust/resolve/rust-early-name-resolver.cc | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index ce427dd..fc9a26c 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -17,7 +17,7 @@ // <http://www.gnu.org/licenses/>. #include "rust-early-name-resolver.h" -#include "rust-ast-full.h" +#include "rust-pattern.h" #include "rust-name-resolver.h" #include "rust-macro-builtins.h" #include "rust-attribute-values.h" @@ -53,7 +53,7 @@ EarlyNameResolver::accumulate_escaped_macros (AST::Module &module) scoped (module.get_node_id (), [&module, &escaped_macros, this] { for (auto &item : module.get_items ()) { - if (item->get_ast_kind () == AST::Kind::MODULE) + if (item->get_item_kind () == AST::Item::Kind::Module) { auto &module = *static_cast<AST::Module *> (item.get ()); auto new_macros = accumulate_escaped_macros (module); @@ -64,7 +64,7 @@ EarlyNameResolver::accumulate_escaped_macros (AST::Module &module) continue; } - if (item->get_ast_kind () == AST::Kind::MACRO_RULES_DEFINITION) + if (item->get_item_kind () == AST::Item::Kind::MacroRulesDefinition) escaped_macros.emplace_back (item->clone_item ()); } }); @@ -113,7 +113,7 @@ EarlyNameResolver::visit (AST::Crate &crate) { auto new_macros = std::vector<std::unique_ptr<AST::Item>> (); - if (item->get_ast_kind () == AST::Kind::MODULE) + if (item->get_item_kind () == AST::Item::Kind::Module) new_macros = accumulate_escaped_macros ( *static_cast<AST::Module *> (item.get ())); @@ -156,9 +156,10 @@ EarlyNameResolver::visit (AST::ConstGenericParam &) void EarlyNameResolver::visit (AST::PathInExpression &path) { - for (auto &segment : path.get_segments ()) - if (segment.has_generic_args ()) - resolve_generic_args (segment.get_generic_args ()); + if (!path.is_lang_item ()) + for (auto &segment : path.get_segments ()) + if (segment.has_generic_args ()) + resolve_generic_args (segment.get_generic_args ()); } void @@ -300,7 +301,7 @@ EarlyNameResolver::visit (AST::Module &module) { auto new_macros = std::vector<std::unique_ptr<AST::Item>> (); - if (item->get_ast_kind () == AST::Kind::MODULE) + if (item->get_item_kind () == AST::Item::Kind::Module) new_macros = accumulate_escaped_macros ( *static_cast<AST::Module *> (item.get ())); @@ -353,6 +354,8 @@ EarlyNameResolver::visit (AST::TraitItemType &) void EarlyNameResolver::visit (AST::Trait &trait) { + // shouldn't need to visit trait.get_implicit_self () + for (auto &generic : trait.get_generic_params ()) generic->accept_vis (*this); @@ -474,7 +477,8 @@ EarlyNameResolver::visit (AST::MacroInvocation &invoc) bool found = resolver.get_macro_scope ().lookup (seg, &resolved_node); if (!found) { - rust_error_at (invoc.get_locus (), "unknown macro: [%s]", + rust_error_at (invoc.get_locus (), ErrorCode::E0433, + "could not resolve macro invocation %qs", seg.get ().c_str ()); return; } @@ -558,30 +562,6 @@ EarlyNameResolver::visit (AST::TupleStructPattern &pattern) } void -EarlyNameResolver::visit (AST::TraitBound &) -{} - -void -EarlyNameResolver::visit (AST::ImplTraitType &) -{} - -void -EarlyNameResolver::visit (AST::TraitObjectType &) -{} - -void -EarlyNameResolver::visit (AST::ParenthesisedType &) -{} - -void -EarlyNameResolver::visit (AST::ImplTraitTypeOneBound &) -{} - -void -EarlyNameResolver::visit (AST::TraitObjectTypeOneBound &) -{} - -void EarlyNameResolver::visit (AST::TupleType &) {} |