[COMMITTED 21/41] gccrs: Remove duplicated visit within early name res

arthur.cohen@embecosm.com arthur.cohen@embecosm.com
Fri Mar 20 17:30:10 GMT 2026


From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Attribute content was checked twice within the early name resolution,
from outside the attribute and then using the default visitor. Remove
the first one visit. Also fix the wrong locus on trait resolution.

gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute):
	Change from attribute locus to trait locus.
	(Early::visit_attributes): Remove function.
	(Early::visit): Remove functions.
	* resolve/rust-early-name-resolver-2.0.h: Remove unused prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
---
 .../resolve/rust-early-name-resolver-2.0.cc   | 24 +------------------
 .../resolve/rust-early-name-resolver-2.0.h    |  4 ----
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 1ee8e4ac19c..a0e31047a2b 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -324,8 +324,7 @@ Early::visit_derive_attribute (AST::Attribute &attr,
       if (!definition.has_value ())
 	{
 	  // FIXME: Change to proper error message
-	  // FIXME: Change locus to trait locus instead of attribute locus
-	  collect_error (Error (attr.get_locus (),
+	  collect_error (Error (trait.get ().get_locus (),
 				"could not resolve trait %qs",
 				trait.get ().as_string ().c_str ()));
 	  continue;
@@ -385,27 +384,6 @@ Early::visit (AST::Attribute &attr)
     }
 }
 
-void
-Early::visit_attributes (std::vector<AST::Attribute> &attrs)
-{
-  for (auto &attr : attrs)
-    visit (attr);
-}
-
-void
-Early::visit (AST::Function &fn)
-{
-  visit_attributes (fn.get_outer_attrs ());
-  DefaultResolver::visit (fn);
-}
-
-void
-Early::visit (AST::StructStruct &s)
-{
-  visit_attributes (s.get_outer_attrs ());
-  DefaultResolver::visit (s);
-}
-
 void
 Early::finalize_simple_import (const Early::ImportPair &mapping)
 {
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
index e2415dd0c6d..bd9ccf66dec 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
@@ -62,8 +62,6 @@ public:
 
   void visit (AST::MacroInvocation &) override;
 
-  void visit (AST::Function &) override;
-  void visit (AST::StructStruct &) override;
   void visit (AST::UseDeclaration &) override;
   void visit (AST::UseTreeList &) override;
 
@@ -174,8 +172,6 @@ public:
   };
 
 private:
-  void visit_attributes (std::vector<AST::Attribute> &attrs);
-
   /**
    * Insert a resolved macro invocation into the mappings once, meaning that we
    * can call this function each time the early name resolution pass is underway
-- 
2.50.1



More information about the Gcc-rust mailing list