gccrs: Replace AST::Method with existing AST::Function
commit6b8365a990df346a4cc0e4fa545e5259de20edc9
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 28 Oct 2023 05:04:19 +0000 (28 01:04 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:13:12 +0000 (16 19:13 +0100)
tree938a350d68a7c78bb7ad7cc7afbd9004c5467d60
parent0df14bb1f3d944ea7281979d03c812a8d2c09ce7
gccrs: Replace AST::Method with existing AST::Function

gcc/rust/ChangeLog:

* ast/rust-item.h
(class Method): Remove.
(Function::self_param): New.
(Function::has_self_param): New.
(Function::Function): Initialize self_param.
(Function::operator=): Likewise.
(Function::get_self_param): New.
* ast/rust-ast.cc
(Method::as_string): Remove.
(Method::accept_vis): Remove.

* ast/rust-ast-collector.cc
(TokenCollector::visit):
Remove AST::Method visitor, handle self_param in AST::Function visitor.
* ast/rust-ast-collector.h
(TokenCollector::visit): Remove AST::Method visitor.
* ast/rust-ast-full-decls.h (class Method): Remove.

* ast/rust-ast-visitor.h
(ASTVisitor::visit): Remove AST::Method visitor.
(DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit):
Remove AST::Method visitor, handle self_param in AST::Function visitor.

* checks/errors/rust-feature-gate.cc
(FeatureGate::visit): Remove AST::Method visitor.
* checks/errors/rust-feature-gate.h
(FeatureGate::visit): Likewise..

* expand/rust-cfg-strip.cc
(CfgStrip::visit):
Remove AST::Method visitor, handle self_param in AST::Function visitor.
* expand/rust-cfg-strip.h
(CfgStrip::visit): Remove AST::Method visitor.

* expand/rust-derive-clone.cc
(DeriveClone::clone_fn): Return AST::Function instead of AST::Method.
* expand/rust-derive.h (DeriveVisitor::visit): Remove AST::Method visitor.

* expand/rust-expand-visitor.cc
(ExpandVisitor::visit):
Remove AST::Method visitor, handle self_param in AST::Function visitor.
* expand/rust-expand-visitor.h:
(ExpandVisitor::visit): Remove AST::Method visitor.

* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h (ASTLoweringBase::visit): Likewise.

* hir/rust-ast-lower-implitem.h
(ASTLowerImplItem::visit):
Remove AST::Method visitor, handle self_param in AST::Function visitor.

* parse/rust-parse-impl.h: Include optional.h.
(Parser::parse_function): Adjust AST::Function construction.
(Parser::parse_inherent_impl_function_or_method):
Construct AST::Function instead of AST::Method,
adjust AST::Function construction.
(Parser::parse_trait_impl_function_or_method): Likewise.
(Parser::parse_method):
Return std::unique_ptr<AST::Function> instead of AST::Method.

* parse/rust-parse.h
(Parser::parse_method): Likewise.

* resolve/rust-ast-resolve-base.cc
(ResolverBase::visit): Remove AST::Method visitor.
* resolve/rust-ast-resolve-base.h
(ResolverBase::visit): Likewise.

* resolve/rust-ast-resolve-implitem.h
(ResolveToplevelImplItem::visit): Likewise.

* resolve/rust-ast-resolve-item.cc
(ResolveItem::visit): Remove AST::Method visitor,
handle self_param in AST::Function visitor.
* resolve/rust-ast-resolve-item.h
(ResolveItem::visit): Remove AST::Method visitor.

* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Remove AST::Method visitor.
* resolve/rust-default-resolver.h
(DefaultResolver::visit): Likewise.

* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Remove AST::Method visitor,
handle self_param in AST::Function visitor.
* resolve/rust-early-name-resolver.h
(EarlyNameResolver::visit): Remove AST::Method visitor.

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::visit): Likewise.

* util/rust-attributes.cc
(AttributeChecker::visit): Likewise.
* util/rust-attributes.h
(AttributeChecker::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
33 files changed:
gcc/rust/ast/rust-ast-collector.cc
gcc/rust/ast/rust-ast-collector.h
gcc/rust/ast/rust-ast-full-decls.h
gcc/rust/ast/rust-ast-visitor.cc
gcc/rust/ast/rust-ast-visitor.h
gcc/rust/ast/rust-ast.cc
gcc/rust/ast/rust-item.h
gcc/rust/checks/errors/rust-feature-gate.cc
gcc/rust/checks/errors/rust-feature-gate.h
gcc/rust/expand/rust-cfg-strip.cc
gcc/rust/expand/rust-cfg-strip.h
gcc/rust/expand/rust-derive-clone.cc
gcc/rust/expand/rust-derive.h
gcc/rust/expand/rust-expand-visitor.cc
gcc/rust/expand/rust-expand-visitor.h
gcc/rust/hir/rust-ast-lower-base.cc
gcc/rust/hir/rust-ast-lower-base.h
gcc/rust/hir/rust-ast-lower-implitem.h
gcc/rust/parse/rust-parse-impl.h
gcc/rust/parse/rust-parse.h
gcc/rust/resolve/rust-ast-resolve-base.cc
gcc/rust/resolve/rust-ast-resolve-base.h
gcc/rust/resolve/rust-ast-resolve-implitem.h
gcc/rust/resolve/rust-ast-resolve-item.cc
gcc/rust/resolve/rust-ast-resolve-item.h
gcc/rust/resolve/rust-default-resolver.cc
gcc/rust/resolve/rust-default-resolver.h
gcc/rust/resolve/rust-early-name-resolver.cc
gcc/rust/resolve/rust-early-name-resolver.h
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
gcc/rust/util/rust-attributes.cc
gcc/rust/util/rust-attributes.h