public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Get rid of lambdas with AST::ArrayElemsValues
@ 2022-06-08 11:55 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:55 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e43a784dc89030941b0cc43309541970c59a723c

commit e43a784dc89030941b0cc43309541970c59a723c
Author: David Faust <david.faust@oracle.com>
Date:   Mon Dec 13 12:53:26 2021 -0800

    Get rid of lambdas with AST::ArrayElemsValues
    
    These constructs make working with the IR needlessly complicated for
    static analysis. Replace with simple for loops, and delete the old
    ArrayElemsValues::iterate () method.
    
    Fixes: #720

Diff:
---
 gcc/rust/ast/rust-expr.h                 |  9 ---------
 gcc/rust/hir/rust-ast-lower-expr.h       | 10 +++++-----
 gcc/rust/resolve/rust-ast-resolve-expr.h |  6 ++----
 3 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 3463f5a2f1c..7f6714a736a 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -996,15 +996,6 @@ public:
 
   size_t get_num_values () const { return values.size (); }
 
-  void iterate (std::function<bool (Expr *)> cb)
-  {
-    for (auto it = values.begin (); it != values.end (); it++)
-      {
-	if (!cb ((*it).get ()))
-	  return;
-      }
-  }
-
 protected:
   ArrayElemsValues *clone_array_elems_impl () const override
   {
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h
index f36096b44ef..d6e21946d11 100644
--- a/gcc/rust/hir/rust-ast-lower-expr.h
+++ b/gcc/rust/hir/rust-ast-lower-expr.h
@@ -303,11 +303,11 @@ public:
   void visit (AST::ArrayElemsValues &elems) override
   {
     std::vector<std::unique_ptr<HIR::Expr> > elements;
-    elems.iterate ([&] (AST::Expr *elem) mutable -> bool {
-      HIR::Expr *translated_elem = ASTLoweringExpr::translate (elem);
-      elements.push_back (std::unique_ptr<HIR::Expr> (translated_elem));
-      return true;
-    });
+    for (auto &elem : elems.get_values ())
+      {
+	HIR::Expr *translated_elem = ASTLoweringExpr::translate (elem.get ());
+	elements.push_back (std::unique_ptr<HIR::Expr> (translated_elem));
+      }
 
     translated_array_elems = new HIR::ArrayElemsValues (std::move (elements));
   }
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.h b/gcc/rust/resolve/rust-ast-resolve-expr.h
index 12a4f8ca9c7..05d116f2539 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.h
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.h
@@ -224,10 +224,8 @@ public:
 
   void visit (AST::ArrayElemsValues &elems) override
   {
-    elems.iterate ([&] (AST::Expr *elem) mutable -> bool {
-      ResolveExpr::go (elem, elems.get_node_id ());
-      return true;
-    });
+    for (auto &elem : elems.get_values ())
+      ResolveExpr::go (elem.get (), elems.get_node_id ());
   }
 
   void visit (AST::ArrayExpr &expr) override


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:55 [gcc/devel/rust/master] Get rid of lambdas with AST::ArrayElemsValues Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).