From 66832f312a7db436110a3b08ff51eac349d5fdbf Mon Sep 17 00:00:00 2001 From: Kadoi Takemaru Date: Sun, 31 Oct 2021 22:22:21 +0900 Subject: 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 --- gcc/rust/hir/rust-ast-lower-type.h | 26 ++++++++++++-------------- gcc/rust/hir/rust-ast-lower.cc | 26 ++++++++++++-------------- 2 files changed, 24 insertions(+), 28 deletions(-) (limited to 'gcc/rust/hir') diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h index f44825c..c667932 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 3aa27b6..5f269b1 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)); -- cgit v1.1