]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: remove visitor which is not needed here
authorPhilip Herron <herron.philip@googlemail.com>
Tue, 18 Feb 2025 17:44:05 +0000 (17:44 +0000)
committerPhilip Herron <philip.herron@embecosm.com>
Fri, 14 Mar 2025 16:36:36 +0000 (16:36 +0000)
Just a small refactor to remove a visitor which is not needed.

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc (ResolvePathRef::Compile): remove visitor
(ResolvePathRef::ResolvePathRef): likewise
(ResolvePathRef::visit): likewise
* backend/rust-compile-resolve-path.h (class ResolvePathRef): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-compile-resolve-path.cc
gcc/rust/backend/rust-compile-resolve-path.h

index 1b9dee69a1081a79d4ecebf021ac7ab4c6b89b71..9423951962f1b1019b81d6814faeb68db0331eab 100644 (file)
 namespace Rust {
 namespace Compile {
 
+tree
+ResolvePathRef::Compile (HIR::QualifiedPathInExpression &expr, Context *ctx)
+{
+  ResolvePathRef resolver (ctx);
+  return resolver.resolve_path_like (expr);
+}
+
+tree
+ResolvePathRef::Compile (HIR::PathInExpression &expr, Context *ctx)
+{
+  ResolvePathRef resolver (ctx);
+  return resolver.resolve_path_like (expr);
+}
+
+ResolvePathRef::ResolvePathRef (Context *ctx) : HIRCompileBase (ctx) {}
+
 template <typename T>
 tree
 ResolvePathRef::resolve_path_like (T &expr)
@@ -53,18 +69,6 @@ ResolvePathRef::resolve_path_like (T &expr)
                  expr.get_mappings (), expr.get_locus (), true);
 }
 
-void
-ResolvePathRef::visit (HIR::QualifiedPathInExpression &expr)
-{
-  resolved = resolve_path_like (expr);
-}
-
-void
-ResolvePathRef::visit (HIR::PathInExpression &expr)
-{
-  resolved = resolve_path_like (expr);
-}
-
 tree
 ResolvePathRef::attempt_constructor_expression_lookup (
   TyTy::BaseType *lookup, Context *ctx, const Analysis::NodeMapping &mappings,
index 4eb0e224ba78cf08b9f2c78e12b7448d10965f8f..b0713ab4104ed34ffdbcd0b48f80f79ae285beb4 100644 (file)
 #define RUST_COMPILE_RESOLVE_PATH
 
 #include "rust-compile-base.h"
-#include "rust-hir-visitor.h"
 
 namespace Rust {
 namespace Compile {
 
-class ResolvePathRef : public HIRCompileBase, public HIR::HIRPatternVisitor
+class ResolvePathRef : public HIRCompileBase
 {
 public:
-  static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx)
-  {
-    ResolvePathRef resolver (ctx);
-    expr.accept_vis (resolver);
-    return resolver.resolved;
-  }
+  static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx);
 
-  static tree Compile (HIR::PathInExpression &expr, Context *ctx)
-  {
-    ResolvePathRef resolver (ctx);
-    expr.accept_vis (resolver);
-    return resolver.resolved;
-  }
+  static tree Compile (HIR::PathInExpression &expr, Context *ctx);
 
-  void visit (HIR::PathInExpression &expr) override;
-  void visit (HIR::QualifiedPathInExpression &expr) override;
-
-  // Empty visit for unused Pattern HIR nodes.
-  void visit (HIR::IdentifierPattern &) override {}
-  void visit (HIR::LiteralPattern &) override {}
-  void visit (HIR::RangePattern &) override {}
-  void visit (HIR::ReferencePattern &) override {}
-  void visit (HIR::SlicePattern &) override {}
-  void visit (HIR::AltPattern &) override {}
-  void visit (HIR::StructPattern &) override {}
-  void visit (HIR::TuplePattern &) override {}
-  void visit (HIR::TupleStructPattern &) override {}
-  void visit (HIR::WildcardPattern &) override {}
-
-  ResolvePathRef (Context *ctx)
-    : HIRCompileBase (ctx), resolved (error_mark_node)
-  {}
+  ResolvePathRef (Context *ctx);
 
   /**
    * Generic visitor for both PathInExpression and QualifiedPathInExpression
@@ -81,8 +53,6 @@ public:
                const Analysis::NodeMapping &mappings, location_t locus,
                bool is_qualified_path);
 
-  tree resolved;
-
 private:
   tree
   attempt_constructor_expression_lookup (TyTy::BaseType *lookup, Context *ctx,