Skip to content

Commit

Permalink
Improve handling of struct expressions in nr2.0
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Handle StructExprStruct and use
	ForeverStack::resolve_path instead of ForeverStack::get to
	resolve struct expression paths.
	* resolve/rust-late-name-resolver-2.0.h
	(Late::visit): Handle StructExprStruct.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and P-E-P committed Nov 4, 2024
1 parent d3968ea commit efcf4d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,19 @@ Late::visit (AST::StructStruct &s)
ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis);
}

void
Late::visit (AST::StructExprStruct &s)
{
auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ());

ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()),
Definition (resolved->get_node_id ()));
}

void
Late::visit (AST::StructExprStructBase &s)
{
auto resolved = ctx.types.get (s.get_struct_name ().as_string ());
auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ());

ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()),
Definition (resolved->get_node_id ()));
Expand All @@ -285,7 +294,7 @@ Late::visit (AST::StructExprStructBase &s)
void
Late::visit (AST::StructExprStructFields &s)
{
auto resolved = ctx.types.get (s.get_struct_name ().as_string ());
auto resolved = ctx.types.resolve_path (s.get_struct_name ().get_segments ());

ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()),
Definition (resolved->get_node_id ()));
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/resolve/rust-late-name-resolver-2.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Late : public DefaultResolver
void visit (AST::IdentifierExpr &) override;
void visit (AST::PathInExpression &) override;
void visit (AST::TypePath &) override;
void visit (AST::StructExprStruct &) override;
void visit (AST::StructExprStructBase &) override;
void visit (AST::StructExprStructFields &) override;
void visit (AST::StructStruct &) override;
Expand Down

0 comments on commit efcf4d4

Please sign in to comment.