From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id D4D7A3985449; Wed, 8 Jun 2022 11:45:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4D7A3985449 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] Get rid of lambda within AST::TypePath and provide a method to return a reference X-Act-Checkin: gcc X-Git-Author: Kadoi Takemaru X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: ca0b06f86fd44bd6067563dcbf4a2c021f2a79a5 X-Git-Newrev: 66832f312a7db436110a3b08ff51eac349d5fdbf Message-Id: <20220608114543.D4D7A3985449@sourceware.org> Date: Wed, 8 Jun 2022 11:45:43 +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, 08 Jun 2022 11:45:43 -0000 https://gcc.gnu.org/g:66832f312a7db436110a3b08ff51eac349d5fdbf commit 66832f312a7db436110a3b08ff51eac349d5fdbf Author: Kadoi Takemaru Date: Sun Oct 31 22:22:21 2021 +0900 Get rid of lambda within AST::TypePath and provide a method to return a reference Remove lambda expressions within AST::TypePath and use get_segments() to iterate over AST::TypePathSegment Fixes #718 Signed-off-by: Kadoi Takemaru Diff: --- gcc/rust/ast/rust-path.h | 18 ------------------ gcc/rust/hir/rust-ast-lower-type.h | 26 ++++++++++++-------------- gcc/rust/hir/rust-ast-lower.cc | 26 ++++++++++++-------------- 3 files changed, 24 insertions(+), 46 deletions(-) diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index cc2721d1393..4c437cc3646 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -754,15 +754,6 @@ public: } size_t get_num_segments () const { return segments.size (); } - - void iterate_segments (std::function cb) - { - for (auto it = segments.begin (); it != segments.end (); it++) - { - if (!cb ((*it).get ())) - return; - } - } }; struct QualifiedPathType @@ -1029,15 +1020,6 @@ public: } Location get_locus () const override final { return locus; } - - void iterate_segments (std::function cb) - { - for (auto it = segments.begin (); it != segments.end (); it++) - { - if (!cb ((*it).get ())) - return; - } - } }; } // namespace AST } // namespace Rust diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h index f44825c2e63..c6679321e7f 100644 --- a/gcc/rust/hir/rust-ast-lower-type.h +++ b/gcc/rust/hir/rust-ast-lower-type.h @@ -62,20 +62,18 @@ public: { std::vector> translated_segments; - path.iterate_segments ([&] (AST::TypePathSegment *seg) mutable -> bool { - translated_segment = nullptr; - seg->accept_vis (*this); - if (translated_segment == nullptr) - { - rust_fatal_error (seg->get_locus (), - "failed to translate AST TypePathSegment"); - return false; - } - - translated_segments.push_back ( - std::unique_ptr (translated_segment)); - return true; - }); + for (auto &seg : path.get_segments ()) + { + translated_segment = nullptr; + seg->accept_vis (*this); + if (translated_segment == nullptr) + { + rust_fatal_error (seg->get_locus (), + "failed to translate AST TypePathSegment"); + } + translated_segments.push_back ( + std::unique_ptr (translated_segment)); + } auto crate_num = mappings->get_current_crate (); auto hirid = mappings->get_next_hir_id (crate_num); diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 3aa27b62ef2..5f269b14ff6 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -490,20 +490,18 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path) std::unique_ptr associated_segment (translated_segment); std::vector > translated_segments; - path.iterate_segments ([&] (AST::TypePathSegment *seg) mutable -> bool { - translated_segment = nullptr; - seg->accept_vis (*this); - if (translated_segment == nullptr) - { - rust_fatal_error (seg->get_locus (), - "failed to translate AST TypePathSegment"); - return false; - } - - translated_segments.push_back ( - std::unique_ptr (translated_segment)); - return true; - }); + for (auto &seg : path.get_segments ()) + { + translated_segment = nullptr; + seg->accept_vis (*this); + if (translated_segment == nullptr) + { + rust_fatal_error (seg->get_locus (), + "failed to translte AST TypePathSegment"); + } + translated_segments.push_back ( + std::unique_ptr (translated_segment)); + } Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid, mappings->get_next_localdef_id (crate_num));