From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 79B493842AD6; Wed, 29 Jun 2022 10:27:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79B493842AD6 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] refactor away from helper utility methods and just use the constructor directly X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 31e63dd6c2b4753d035496b9145e34b7b7d168c0 X-Git-Newrev: da2dda70637ecd42a9ba3fba976a5f280e880852 Message-Id: <20220629102735.79B493842AD6@sourceware.org> Date: Wed, 29 Jun 2022 10:27:35 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 10:27:35 -0000 https://gcc.gnu.org/g:da2dda70637ecd42a9ba3fba976a5f280e880852 commit da2dda70637ecd42a9ba3fba976a5f280e880852 Author: Philip Herron Date: Mon Jun 27 17:48:55 2022 +0100 refactor away from helper utility methods and just use the constructor directly Diff: --- gcc/rust/resolve/rust-ast-resolve-implitem.h | 22 ++++++--- gcc/rust/resolve/rust-ast-resolve-item.cc | 22 ++++++--- gcc/rust/resolve/rust-ast-resolve-stmt.h | 6 ++- gcc/rust/resolve/rust-ast-resolve-toplevel.h | 6 ++- gcc/rust/resolve/rust-ast-resolve-type.h | 70 ---------------------------- 5 files changed, 38 insertions(+), 88 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index c0cb3a7a311..192ecaf42e6 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -66,7 +66,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -80,7 +81,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -94,7 +96,8 @@ public: void visit (AST::Method &method) override { - auto decl = ResolveMethodItemToCanonicalPath::resolve (method); + auto decl = CanonicalPath::new_seg (method.get_node_id (), + method.get_method_name ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -130,7 +133,9 @@ public: void visit (AST::TraitItemFunc &function) override { - auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg ( + function.get_node_id (), + function.get_trait_function_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -148,7 +153,8 @@ public: void visit (AST::TraitItemMethod &method) override { - auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (method); + auto decl = CanonicalPath::new_seg ( + method.get_node_id (), method.get_trait_method_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -166,7 +172,8 @@ public: void visit (AST::TraitItemConst &constant) override { - auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -184,7 +191,8 @@ public: void visit (AST::TraitItemType &type) override { - auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type); + auto decl + = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 7b0c31b2edc..0c9536ff38d 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -42,7 +42,8 @@ ResolveTraitItems::go (AST::TraitItem *item, const CanonicalPath &prefix, void ResolveTraitItems::visit (AST::TraitItemType &type) { - auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type); + auto decl + = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -55,7 +56,8 @@ ResolveTraitItems::visit (AST::TraitItemType &type) void ResolveTraitItems::visit (AST::TraitItemFunc &func) { - auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (func); + auto decl = CanonicalPath::new_seg ( + func.get_node_id (), func.get_trait_function_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -102,7 +104,9 @@ ResolveTraitItems::visit (AST::TraitItemFunc &func) void ResolveTraitItems::visit (AST::TraitItemMethod &func) { - auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (func); + auto decl + = CanonicalPath::new_seg (func.get_node_id (), + func.get_trait_method_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -166,7 +170,8 @@ ResolveTraitItems::visit (AST::TraitItemMethod &func) void ResolveTraitItems::visit (AST::TraitItemConst &constant) { - auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -486,7 +491,8 @@ ResolveItem::visit (AST::StaticItem &var) void ResolveItem::visit (AST::ConstantItem &constant) { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -501,7 +507,8 @@ ResolveItem::visit (AST::ConstantItem &constant) void ResolveItem::visit (AST::Function &function) { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -638,7 +645,8 @@ ResolveItem::visit (AST::InherentImpl &impl_block) void ResolveItem::visit (AST::Method &method) { - auto decl = ResolveMethodItemToCanonicalPath::resolve (method); + auto decl + = CanonicalPath::new_seg (method.get_node_id (), method.get_method_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index 95c25a5ad77..1d2ecd35207 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -56,7 +56,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = decl; // this ensures we have the correct relative resolution auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -330,7 +331,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = decl; // this ensures we have the correct relative resolution auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index c495786f6f8..aed8565c8d5 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -283,7 +283,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -303,7 +304,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h index aab6a1afd7d..b8ad6d1756a 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.h +++ b/gcc/rust/resolve/rust-ast-resolve-type.h @@ -25,76 +25,6 @@ namespace Rust { namespace Resolver { -class ResolveConstantItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::ConstantItem &constant) - { - return CanonicalPath::new_seg (constant.get_node_id (), - constant.get_identifier ()); - } -}; - -class ResolveFunctionItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::Function &function) - { - return CanonicalPath::new_seg (function.get_node_id (), - function.get_function_name ()); - } -}; - -class ResolveMethodItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::Method &method) - { - return CanonicalPath::new_seg (method.get_node_id (), - method.get_method_name ()); - } -}; - -class ResolveTraitItemFunctionToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemFunc &function) - { - return CanonicalPath::new_seg ( - function.get_node_id (), - function.get_trait_function_decl ().get_identifier ()); - } -}; - -class ResolveTraitItemMethodToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemMethod &method) - { - return CanonicalPath::new_seg ( - method.get_node_id (), method.get_trait_method_decl ().get_identifier ()); - } -}; - -class ResolveTraitItemConstToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemConst &constant) - { - return CanonicalPath::new_seg (constant.get_node_id (), - constant.get_identifier ()); - } -}; - -class ResolveTraitItemTypeToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemType &type) - { - return CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); - } -}; - class ResolveTypeToCanonicalPath : public ResolverBase { protected: