diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-01 11:52:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 11:52:51 +0000 |
commit | 1be610afab2d1f3fce433be2eeb9b4b8d11bdf0d (patch) | |
tree | 56a34e691457a303c5b987b8d8996e16268d8228 | |
parent | ca0b06f86fd44bd6067563dcbf4a2c021f2a79a5 (diff) | |
parent | 66832f312a7db436110a3b08ff51eac349d5fdbf (diff) | |
download | gcc-1be610afab2d1f3fce433be2eeb9b4b8d11bdf0d.zip gcc-1be610afab2d1f3fce433be2eeb9b4b8d11bdf0d.tar.gz gcc-1be610afab2d1f3fce433be2eeb9b4b8d11bdf0d.tar.bz2 |
Merge #783
783: Get rid of lambda within `AST::TypePath` and provide a method to return a reference r=philberty a=diohabara
## Related issue
This PR will fix <https://github.com/Rust-GCC/gccrs/issues/718>
- \[x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- \[x] Read contributing guidlines
- \[x] `make check-rust` passes locally
- \[x] Run `clang-format`
- \[x] Added any relevant test cases to `gcc/testsuite/rust/`
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
Co-authored-by: Kadoi Takemaru <diohabara@gmail.com>
-rw-r--r-- | gcc/rust/ast/rust-path.h | 18 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-type.h | 26 | ||||
-rw-r--r-- | 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 cc2721d..4c437cc 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<bool (TypePathSegment *)> 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<bool (TypePathSegment *)> 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 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<std::unique_ptr<HIR::TypePathSegment>> 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<HIR::TypePathSegment> (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<HIR::TypePathSegment> (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<HIR::TypePathSegment> associated_segment (translated_segment); std::vector<std::unique_ptr<HIR::TypePathSegment> > 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<HIR::TypePathSegment> (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<HIR::TypePathSegment> (translated_segment)); + } Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid, mappings->get_next_localdef_id (crate_num)); |