]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Unit struct constructor shall be resolved
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 24 Jan 2024 16:04:51 +0000 (17:04 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Tue, 26 Mar 2024 17:35:02 +0000 (17:35 +0000)
Unit struct have a special constructor that should be added to the struct
namespace in order to be resolved later when called. As it is a function
it should be added in the value namespace.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Add the struct constructor when the struct is a unit.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc

index 4134b9a46202f6c7b34b66e15bed1bad99f5aa73..75d9bb82131ff6d72c9ec591a472b7b9843b771a 100644 (file)
@@ -68,8 +68,13 @@ void
 GlobbingVisitor::visit (AST::StructStruct &struct_item)
 {
   if (struct_item.get_visibility ().is_public ())
-    ctx.insert_shadowable (struct_item.get_identifier (),
-                          struct_item.get_node_id (), Namespace::Values);
+    {
+      ctx.insert_shadowable (struct_item.get_identifier (),
+                            struct_item.get_node_id (), Namespace::Types);
+      if (struct_item.is_unit_struct ())
+       ctx.insert_shadowable (struct_item.get_identifier (),
+                              struct_item.get_node_id (), Namespace::Values);
+    }
 }
 
 void