Skip to content

Commit

Permalink
Do not visit subitems for unit structs
Browse files Browse the repository at this point in the history
Unit structs don't have any sub items to visit and therefore do not
require their own scope.

gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Prevent new
	scope creation for unit structs.
	* 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 7b2d548
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 7b2d548

Please sign in to comment.