Skip to content

Commit

Permalink
Implement name resolution for the IfLet expression.
Browse files Browse the repository at this point in the history
Addresses Rust-GCC#1177.
  • Loading branch information
antego committed May 10, 2022
1 parent 03c21a0 commit 4bb5de6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gcc/rust/resolve/rust-ast-resolve-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,31 @@ ResolveExpr::visit (AST::IfExprConseqIf &expr)
resolve_expr (expr.get_conseq_if_expr ().get (), expr.get_node_id ());
}

void
ResolveExpr::visit (AST::IfLetExpr &expr)
{
resolve_expr (expr.get_value_expr().get (), expr.get_node_id ());

NodeId scope_node_id = expr.get_node_id ();
resolver->get_name_scope ().push (scope_node_id);
resolver->get_type_scope ().push (scope_node_id);
resolver->get_label_scope ().push (scope_node_id);
resolver->push_new_name_rib (resolver->get_name_scope ().peek ());
resolver->push_new_type_rib (resolver->get_type_scope ().peek ());
resolver->push_new_label_rib (resolver->get_type_scope ().peek ());

for (auto &pattern : expr.get_patterns ())
{
PatternDeclaration::go (pattern.get (), expr.get_node_id ());
}

resolve_expr (expr.get_if_block().get (), expr.get_node_id ());

resolver->get_name_scope ().pop ();
resolver->get_type_scope ().pop ();
resolver->get_label_scope ().pop ();
}

void
ResolveExpr::visit (AST::BlockExpr &expr)
{
Expand Down
2 changes: 2 additions & 0 deletions gcc/rust/resolve/rust-ast-resolve-expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class ResolveExpr : public ResolverBase

void visit (AST::IfExprConseqIf &expr) override;

void visit (AST::IfLetExpr &expr) override;

void visit (AST::BlockExpr &expr) override;

void visit (AST::UnsafeBlockExpr &expr) override;
Expand Down

0 comments on commit 4bb5de6

Please sign in to comment.