]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Insert static items into the value namespace
authorOwen Avery <powerboat9.gamer@gmail.com>
Fri, 11 Oct 2024 05:24:14 +0000 (01:24 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:17 +0000 (15:32 +0100)
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>
gcc/rust/backend/rust-compile-item.cc
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
gcc/testsuite/rust/compile/nr2/exclude

index c0cac686e8d9b6f5e9981046f652b1cce4705c77..08787163c2a5caf7ce2e3a89b4e14d900b3b2126 100644 (file)
@@ -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 ();
index b0e0c1b52dcecd47e63aec985ca7e18bbacfc87c..d3a3c5d78bc9081e3bb7a62bfb3922dc951dc635 100644 (file)
@@ -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
index 1faa7b53622ed0489aa0ef21ea22844ddc382f09..166977e7bacc1a280d88833b5a2844645145d94b 100644 (file)
@@ -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