aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-11-29 12:35:37 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:33:14 +0100
commit89640686a29f8b3f256454b9c53a72c629efbe39 (patch)
tree37acad3e829753d544dbd35e0d7b81d9b3080dad /gcc/rust/resolve
parentc7c6b5f89a39a39322aefb6e8f181c5fc230b162 (diff)
downloadgcc-89640686a29f8b3f256454b9c53a72c629efbe39.zip
gcc-89640686a29f8b3f256454b9c53a72c629efbe39.tar.gz
gcc-89640686a29f8b3f256454b9c53a72c629efbe39.tar.bz2
gccrs: nr2.0: Resolve lang item paths properly.
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): New. * resolve/rust-late-name-resolver-2.0.h: New.
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-late-name-resolver-2.0.cc20
-rw-r--r--gcc/rust/resolve/rust-late-name-resolver-2.0.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index 3af8496..ac5f1c5 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -18,6 +18,7 @@
#include "optional.h"
#include "rust-ast-full.h"
+#include "rust-diagnostics.h"
#include "rust-hir-map.h"
#include "rust-late-name-resolver-2.0.h"
#include "rust-default-resolver.h"
@@ -248,6 +249,25 @@ Late::visit (AST::PathInExpression &expr)
}
void
+Late::visit (AST::LangItemPath &type)
+{
+ auto &mappings = Rust::Analysis::Mappings::get ();
+ auto lang_item = mappings.lookup_lang_item_node (type.get_lang_item_kind ());
+
+ if (!lang_item)
+ {
+ rust_fatal_error (
+ type.get_locus (), "use of undeclared lang item %qs",
+ LangItem::ToString (type.get_lang_item_kind ()).c_str ());
+ return;
+ }
+
+ ctx.map_usage (Usage (type.get_node_id ()), Definition (lang_item.value ()));
+
+ DefaultResolver::visit (type);
+}
+
+void
Late::visit (AST::TypePath &type)
{
// should we add type path resolution in `ForeverStack` directly? Since it's
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
index 79572fb..6f11916 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
@@ -46,6 +46,7 @@ public:
// resolutions
void visit (AST::IdentifierExpr &) override;
void visit (AST::PathInExpression &) override;
+ void visit (AST::LangItemPath &) override;
void visit (AST::TypePath &) override;
void visit (AST::StructExprStruct &) override;
void visit (AST::StructExprStructBase &) override;