Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of struct expressions in nr2.0 #3225

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading