Skip to content

Commit

Permalink
Do not visit subitems in a scope for unit struct
Browse files Browse the repository at this point in the history
There is no sub-items in unit struct since those are empty.

gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Prevent
	insertion of a new scope for unit struct.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
	Likewise.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Dec 10, 2024
1 parent 4c4a569 commit 3edeca7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gcc/rust/resolve/rust-late-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ void
Late::visit (AST::StructStruct &s)
{
auto s_vis = [this, &s] () { AST::DefaultASTVisitor::visit (s); };
ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis);
if (!s.is_unit_struct ())
ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis);
}

void
Expand Down
3 changes: 2 additions & 1 deletion gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ TopLevel::visit (AST::StructStruct &struct_item)
}
};

ctx.scoped (Rib::Kind::Item, struct_item.get_node_id (), generic_vis);
if (!struct_item.is_unit_struct ())
ctx.scoped (Rib::Kind::Item, struct_item.get_node_id (), generic_vis);

insert_or_error_out (struct_item.get_struct_name (), struct_item,
Namespace::Types);
Expand Down

0 comments on commit 3edeca7

Please sign in to comment.