Skip to content

Commit

Permalink
Add unit struct to name namespace in old resolver
Browse files Browse the repository at this point in the history
We missed the name namespace for unit struct in the old resolver.

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-toplevel.h: Add struct to name namespace.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Dec 11, 2024
1 parent 6e9f06c commit 1ad6863
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions gcc/rust/resolve/rust-ast-resolve-toplevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,21 @@ class ResolveTopLevel : public ResolverBase
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);

resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
});
auto duplicate_item
= [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
rich_location r (line_table, struct_decl.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
};

resolver->get_type_scope ().insert (path, struct_decl.get_node_id (),
struct_decl.get_locus (), false,
Rib::ItemType::Type, duplicate_item);

if (struct_decl.is_unit_struct ())
resolver->get_name_scope ().insert (path, struct_decl.get_node_id (),
struct_decl.get_locus (), false,
Rib::ItemType::Type, duplicate_item);

NodeId current_module = resolver->peek_current_module_scope ();
mappings.insert_module_child_item (current_module, decl);
Expand Down

0 comments on commit 1ad6863

Please sign in to comment.