]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Labels shall be pushed within label namespace
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 11 Dec 2024 11:04:32 +0000 (12:04 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 29 Jan 2025 10:45:07 +0000 (10:45 +0000)
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 <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-ast-resolve-expr.cc
gcc/rust/resolve/rust-ast-resolve-item.cc
gcc/rust/resolve/rust-ast-resolve-stmt.h
gcc/rust/resolve/rust-ast-resolve.cc

index a7490156031058401f96f4a8e0bd1873561243f2..539eadef52dd8d9ad3d2f01b8def7970c853b75b 100644 (file)
@@ -209,7 +209,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.
@@ -239,7 +239,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.
@@ -268,7 +268,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 ())
     {
@@ -576,7 +576,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);
@@ -642,7 +642,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 ();
@@ -711,7 +711,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> ())};
@@ -741,7 +741,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> ())};
index ca09c2efeb12e74026e32c31dbc326911ae3a41c..b50c158a7a7744e79961da5c38fff099559c2036 100644 (file)
@@ -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 ())
@@ -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?
@@ -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 ())
@@ -648,7 +648,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 ())
@@ -1040,7 +1040,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 ())
index fd9880cc21d2a9af27a5b1809df97da1a7c406d6..700adddcb40eeb7a96c9a9f90a7311d27617001f 100644 (file)
@@ -338,7 +338,7 @@ public:
     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 ())
index df90cff7815c94c041cde0c978c6b1843fe3cf6a..75e01ab2b0ceaf90c5a0ce8111de5e9b35d7c5e2 100644 (file)
@@ -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