Skip to content

Commit d93efa7

Browse files
committed
gccrs: remove visitor which is not needed here
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 <[email protected]>
1 parent 3621c8d commit d93efa7

File tree

2 files changed

+20
-46
lines changed

2 files changed

+20
-46
lines changed

gcc/rust/backend/rust-compile-resolve-path.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@
3232
namespace Rust {
3333
namespace Compile {
3434

35+
tree
36+
ResolvePathRef::Compile (HIR::QualifiedPathInExpression &expr, Context *ctx)
37+
{
38+
ResolvePathRef resolver (ctx);
39+
return resolver.resolve_path_like (expr);
40+
}
41+
42+
tree
43+
ResolvePathRef::Compile (HIR::PathInExpression &expr, Context *ctx)
44+
{
45+
ResolvePathRef resolver (ctx);
46+
return resolver.resolve_path_like (expr);
47+
}
48+
49+
ResolvePathRef::ResolvePathRef (Context *ctx) : HIRCompileBase (ctx) {}
50+
3551
template <typename T>
3652
tree
3753
ResolvePathRef::resolve_path_like (T &expr)
@@ -53,18 +69,6 @@ ResolvePathRef::resolve_path_like (T &expr)
5369
expr.get_mappings (), expr.get_locus (), true);
5470
}
5571

56-
void
57-
ResolvePathRef::visit (HIR::QualifiedPathInExpression &expr)
58-
{
59-
resolved = resolve_path_like (expr);
60-
}
61-
62-
void
63-
ResolvePathRef::visit (HIR::PathInExpression &expr)
64-
{
65-
resolved = resolve_path_like (expr);
66-
}
67-
6872
tree
6973
ResolvePathRef::attempt_constructor_expression_lookup (
7074
TyTy::BaseType *lookup, Context *ctx, const Analysis::NodeMapping &mappings,

gcc/rust/backend/rust-compile-resolve-path.h

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,18 @@
2020
#define RUST_COMPILE_RESOLVE_PATH
2121

2222
#include "rust-compile-base.h"
23-
#include "rust-hir-visitor.h"
2423

2524
namespace Rust {
2625
namespace Compile {
2726

28-
class ResolvePathRef : public HIRCompileBase, public HIR::HIRPatternVisitor
27+
class ResolvePathRef : public HIRCompileBase
2928
{
3029
public:
31-
static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx)
32-
{
33-
ResolvePathRef resolver (ctx);
34-
expr.accept_vis (resolver);
35-
return resolver.resolved;
36-
}
30+
static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx);
3731

38-
static tree Compile (HIR::PathInExpression &expr, Context *ctx)
39-
{
40-
ResolvePathRef resolver (ctx);
41-
expr.accept_vis (resolver);
42-
return resolver.resolved;
43-
}
32+
static tree Compile (HIR::PathInExpression &expr, Context *ctx);
4433

45-
void visit (HIR::PathInExpression &expr) override;
46-
void visit (HIR::QualifiedPathInExpression &expr) override;
47-
48-
// Empty visit for unused Pattern HIR nodes.
49-
void visit (HIR::IdentifierPattern &) override {}
50-
void visit (HIR::LiteralPattern &) override {}
51-
void visit (HIR::RangePattern &) override {}
52-
void visit (HIR::ReferencePattern &) override {}
53-
void visit (HIR::SlicePattern &) override {}
54-
void visit (HIR::AltPattern &) override {}
55-
void visit (HIR::StructPattern &) override {}
56-
void visit (HIR::TuplePattern &) override {}
57-
void visit (HIR::TupleStructPattern &) override {}
58-
void visit (HIR::WildcardPattern &) override {}
59-
60-
ResolvePathRef (Context *ctx)
61-
: HIRCompileBase (ctx), resolved (error_mark_node)
62-
{}
34+
ResolvePathRef (Context *ctx);
6335

6436
/**
6537
* Generic visitor for both PathInExpression and QualifiedPathInExpression
@@ -81,8 +53,6 @@ class ResolvePathRef : public HIRCompileBase, public HIR::HIRPatternVisitor
8153
const Analysis::NodeMapping &mappings, location_t locus,
8254
bool is_qualified_path);
8355

84-
tree resolved;
85-
8656
private:
8757
tree
8858
attempt_constructor_expression_lookup (TyTy::BaseType *lookup, Context *ctx,

0 commit comments

Comments
 (0)