aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-04 15:14:45 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-12-09 14:46:13 +0000
commitd812c793ef14bcfbb5ab7aa6e8c3837f8e817beb (patch)
tree93b9ad5978376102ef76f3a81573bab7b21a7fdf /gcc
parent3d2f58db04023adb74e5334cef31b67383def449 (diff)
downloadgcc-d812c793ef14bcfbb5ab7aa6e8c3837f8e817beb.zip
gcc-d812c793ef14bcfbb5ab7aa6e8c3837f8e817beb.tar.gz
gcc-d812c793ef14bcfbb5ab7aa6e8c3837f8e817beb.tar.bz2
nr1.0: Resolve lang item paths properly.
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt resolver to lang item paths. * resolve/rust-ast-resolve-type.h: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc30
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.h11
2 files changed, 32 insertions, 9 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 49c0e6f..619efb0 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -678,16 +678,32 @@ ResolveItem::visit (AST::TraitImpl &impl_block)
return;
}
+ bool ok = true;
+
// setup paths
CanonicalPath canonical_trait_type = CanonicalPath::create_empty ();
- bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
- canonical_trait_type);
- if (!ok)
+ if (impl_block.get_trait_path ().get_path_kind ()
+ == AST::Path::Kind::LangItem)
{
- resolver->get_name_scope ().pop ();
- resolver->get_type_scope ().pop ();
- resolver->get_label_scope ().pop ();
- return;
+ auto &lang_item
+ = static_cast<AST::LangItemPath &> (impl_block.get_trait_path ());
+
+ canonical_trait_type
+ = CanonicalPath::new_seg (lang_item.get_node_id (),
+ LangItem::ToString (
+ lang_item.get_lang_item_kind ()));
+ }
+ else
+ {
+ ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
+ canonical_trait_type);
+ if (!ok)
+ {
+ resolver->get_name_scope ().pop ();
+ resolver->get_type_scope ().pop ();
+ resolver->get_label_scope ().pop ();
+ return;
+ }
}
rust_debug ("AST::TraitImpl resolve trait type: {%s}",
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index 47c4e35..e9451d3 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -21,8 +21,10 @@
#include "rust-ast-resolve-base.h"
#include "rust-ast-resolve-expr.h"
+#include "rust-diagnostics.h"
#include "rust-hir-map.h"
#include "rust-path.h"
+#include "util/rust-hir-map.h"
namespace Rust {
namespace Resolver {
@@ -69,9 +71,14 @@ public:
{
auto &type = static_cast<AST::LangItemPath &> (type_path);
- Analysis::Mappings::get_lang_item (type);
+ rust_debug ("[ARTHUR]: lang item kind: %s",
+ LangItem::ToString (type.get_lang_item_kind ()).c_str ());
- type.get_node_id ();
+ auto lang_item = Analysis::Mappings::get ()
+ .lookup_lang_item_node (type.get_lang_item_kind ())
+ .value ();
+
+ return lang_item;
}
rust_assert (type_path.get_path_kind () == AST::Path::Kind::Type);