aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-10-11 01:24:14 -0400
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-10-14 08:15:40 +0000
commit71d2084edcc441c5a1c47d8fe074f183dfafcb48 (patch)
tree0a6c05acc16b9f61ce433bee64f0f6da1886e0b7 /gcc
parent583eb22ce186fc5acbb330e9553af40257951cef (diff)
downloadgcc-71d2084edcc441c5a1c47d8fe074f183dfafcb48.zip
gcc-71d2084edcc441c5a1c47d8fe074f183dfafcb48.tar.gz
gcc-71d2084edcc441c5a1c47d8fe074f183dfafcb48.tar.bz2
Insert static items into the value namespace
gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): Check canonical path of StaticItem properly when name resolution 2.0 is enabled. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert static items into the value namespace. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-item.cc19
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc3
-rw-r--r--gcc/testsuite/rust/compile/nr2/exclude2
3 files changed, 20 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc
index fd92825..5fdc9cd 100644
--- a/gcc/rust/backend/rust-compile-item.cc
+++ b/gcc/rust/backend/rust-compile-item.cc
@@ -42,8 +42,23 @@ CompileItem::visit (HIR::StaticItem &var)
tree type = TyTyResolveCompile::compile (ctx, resolved_type);
- auto canonical_path = ctx->get_mappings ().lookup_canonical_path (
- var.get_mappings ().get_nodeid ());
+ tl::optional<Resolver::CanonicalPath> canonical_path;
+
+ if (flag_name_resolution_2_0)
+ {
+ auto nr_ctx
+ = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ canonical_path
+ = nr_ctx.values.to_canonical_path (var.get_mappings ().get_nodeid ());
+ }
+ else
+ {
+ canonical_path = ctx->get_mappings ().lookup_canonical_path (
+ var.get_mappings ().get_nodeid ());
+ }
+
+ rust_assert (canonical_path.has_value ());
HIR::Expr *const_value_expr = var.get_expr ().get ();
ctx->push_const_context ();
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 72c0425..2bf5ad3 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -248,6 +248,9 @@ TopLevel::visit (AST::StaticItem &static_item)
= [this, &static_item] () { static_item.get_expr ().accept_vis (*this); };
ctx.scoped (Rib::Kind::Item, static_item.get_node_id (), sub_vis);
+
+ insert_or_error_out (static_item.get_identifier ().as_string (), static_item,
+ Namespace::Values);
}
void
diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude
index 1faa7b5..166977e 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -100,8 +100,6 @@ issue-2139.rs
issue-2142.rs
issue-2165.rs
issue-2166.rs
-issue-2178.rs
-issue-2188.rs
issue-2190-1.rs
issue-2190-2.rs
issue-2195.rs