Skip to content

Commit

Permalink
Labels shall be pushed withing label namespace
Browse files Browse the repository at this point in the history
Labels were using the wrong namespace.

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Change label
	push function from type rib to label rib.
	* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
	Likewise.
	(ResolveItem::visit): Likewise.
	(ResolveExternItem::visit): Likewise.
	* resolve/rust-ast-resolve-stmt.h: Likewise.
	* resolve/rust-ast-resolve.cc (NameResolution::go): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Dec 11, 2024
1 parent 4c4a569 commit 9d29160
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions gcc/rust/resolve/rust-ast-resolve-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ ResolveExpr::visit (AST::IfLetExpr &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// We know expr.get_patterns () has one pattern at most
// so there's no reason to handle it like an AltPattern.
Expand Down Expand Up @@ -278,7 +278,7 @@ ResolveExpr::visit (AST::IfLetExprConseqElse &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// We know expr.get_patterns () has one pattern at most
// so there's no reason to handle it like an AltPattern.
Expand Down Expand Up @@ -307,7 +307,7 @@ ResolveExpr::visit (AST::BlockExpr &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

if (expr.has_label ())
{
Expand Down Expand Up @@ -615,7 +615,7 @@ ResolveExpr::visit (AST::ForLoopExpr &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// resolve the expression
PatternDeclaration::go (expr.get_pattern (), Rib::ItemType::Var);
Expand Down Expand Up @@ -681,7 +681,7 @@ ResolveExpr::visit (AST::MatchExpr &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// resolve
AST::MatchArm &arm = match_case.get_arm ();
Expand Down Expand Up @@ -750,7 +750,7 @@ ResolveExpr::visit (AST::ClosureExprInner &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

std::vector<PatternBinding> bindings
= {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())};
Expand Down Expand Up @@ -780,7 +780,7 @@ ResolveExpr::visit (AST::ClosureExprInnerTyped &expr)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

std::vector<PatternBinding> bindings
= {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())};
Expand Down
10 changes: 5 additions & 5 deletions gcc/rust/resolve/rust-ast-resolve-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ResolveTraitItems::visit (AST::Function &function)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

if (function.has_generics ())
for (auto &generic : function.get_generic_params ())
Expand Down Expand Up @@ -216,7 +216,7 @@ ResolveItem::visit (AST::Module &module)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// FIXME: Should we reinsert a child here? Any reason we ResolveTopLevel::go
// in ResolveTopLevel::visit (AST::Module) as well as here?
Expand Down Expand Up @@ -473,7 +473,7 @@ ResolveItem::visit (AST::Function &function)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

if (function.has_generics ())
for (auto &generic : function.get_generic_params ())
Expand Down Expand Up @@ -641,7 +641,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

if (impl_block.has_generics ())
for (auto &generic : impl_block.get_generic_params ())
Expand Down Expand Up @@ -1019,7 +1019,7 @@ ResolveExternItem::visit (AST::Function &function)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// resolve the generics
if (function.has_generics ())
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/resolve/rust-ast-resolve-stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ResolveStmt : public ResolverBase
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

if (function.has_generics ())
for (auto &generic : function.get_generic_params ())
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/resolve/rust-ast-resolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ NameResolution::go (AST::Crate &crate)
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 ());
resolver->push_new_label_rib (resolver->get_label_scope ().peek ());

// get the root segment
CanonicalPath crate_prefix
Expand Down

0 comments on commit 9d29160

Please sign in to comment.