public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Get rid of lambdas within AST::TupleStruct
@ 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:946069f506afba2ac03b00ad8244f1f42e0c03f1
commit 946069f506afba2ac03b00ad8244f1f42e0c03f1
Author: David Faust <david.faust@oracle.com>
Date: Mon Dec 13 13:20:02 2021 -0800
Get rid of lambdas within AST::TupleStruct
These constructs make working with the IR needlessly complicated for
static analysis. Replace with simple for loops, and delete the old
TupleStruct::iterate () method.
Fixes: #715
Diff:
---
gcc/rust/ast/rust-item.h | 9 ---------
gcc/rust/hir/rust-ast-lower-item.h | 34 ++++++++++++++++----------------
gcc/rust/hir/rust-ast-lower-stmt.h | 34 ++++++++++++++++----------------
gcc/rust/resolve/rust-ast-resolve-item.h | 4 +---
gcc/rust/resolve/rust-ast-resolve-stmt.h | 4 +---
5 files changed, 36 insertions(+), 49 deletions(-)
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index f952dccf3b1..e319d743794 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -2110,15 +2110,6 @@ public:
std::vector<TupleField> &get_fields () { return fields; }
const std::vector<TupleField> &get_fields () const { return fields; }
- void iterate (std::function<bool (TupleField &)> cb)
- {
- for (auto &field : fields)
- {
- if (!cb (field))
- return;
- }
- }
-
protected:
/* Use covariance to implement clone function as returning this object
* rather than base */
diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h
index 697e98a3cbd..d4c0306f343 100644
--- a/gcc/rust/hir/rust-ast-lower-item.h
+++ b/gcc/rust/hir/rust-ast-lower-item.h
@@ -154,24 +154,24 @@ public:
HIR::Visibility vis = HIR::Visibility::create_public ();
std::vector<HIR::TupleField> fields;
- struct_decl.iterate ([&] (AST::TupleField &field) mutable -> bool {
- HIR::Visibility vis = HIR::Visibility::create_public ();
- HIR::Type *type
- = ASTLoweringType::translate (field.get_field_type ().get ());
-
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
- mappings->get_next_hir_id (crate_num),
- mappings->get_next_localdef_id (
- crate_num));
+ for (AST::TupleField &field : struct_decl.get_fields ())
+ {
+ HIR::Visibility vis = HIR::Visibility::create_public ();
+ HIR::Type *type
+ = ASTLoweringType::translate (field.get_field_type ().get ());
- HIR::TupleField translated_field (mapping,
- std::unique_ptr<HIR::Type> (type), vis,
- field.get_locus (),
- field.get_outer_attrs ());
- fields.push_back (std::move (translated_field));
- return true;
- });
+ auto crate_num = mappings->get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
+ mappings->get_next_hir_id (crate_num),
+ mappings->get_next_localdef_id (
+ crate_num));
+
+ HIR::TupleField translated_field (mapping,
+ std::unique_ptr<HIR::Type> (type),
+ vis, field.get_locus (),
+ field.get_outer_attrs ());
+ fields.push_back (std::move (translated_field));
+ }
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (),
diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h
index eab0922ca7d..b617991d928 100644
--- a/gcc/rust/hir/rust-ast-lower-stmt.h
+++ b/gcc/rust/hir/rust-ast-lower-stmt.h
@@ -151,24 +151,24 @@ public:
HIR::Visibility vis = HIR::Visibility::create_public ();
std::vector<HIR::TupleField> fields;
- struct_decl.iterate ([&] (AST::TupleField &field) mutable -> bool {
- HIR::Visibility vis = HIR::Visibility::create_public ();
- HIR::Type *type
- = ASTLoweringType::translate (field.get_field_type ().get ());
-
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
- mappings->get_next_hir_id (crate_num),
- mappings->get_next_localdef_id (
- crate_num));
+ for (AST::TupleField &field : struct_decl.get_fields ())
+ {
+ HIR::Visibility vis = HIR::Visibility::create_public ();
+ HIR::Type *type
+ = ASTLoweringType::translate (field.get_field_type ().get ());
- HIR::TupleField translated_field (mapping,
- std::unique_ptr<HIR::Type> (type), vis,
- field.get_locus (),
- field.get_outer_attrs ());
- fields.push_back (std::move (translated_field));
- return true;
- });
+ auto crate_num = mappings->get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
+ mappings->get_next_hir_id (crate_num),
+ mappings->get_next_localdef_id (
+ crate_num));
+
+ HIR::TupleField translated_field (mapping,
+ std::unique_ptr<HIR::Type> (type),
+ vis, field.get_locus (),
+ field.get_outer_attrs ());
+ fields.push_back (std::move (translated_field));
+ }
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (),
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index a4bf2619d40..e697f1c53b4 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -245,11 +245,9 @@ public:
if (struct_decl.has_where_clause ())
ResolveWhereClause::Resolve (struct_decl.get_where_clause ());
- struct_decl.iterate ([&] (AST::TupleField &field) mutable -> bool {
+ for (AST::TupleField &field : struct_decl.get_fields ())
ResolveType::go (field.get_field_type ().get (),
struct_decl.get_node_id ());
- return true;
- });
resolver->get_type_scope ().pop ();
}
diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h
index 98fcaf2eda5..a4043656441 100644
--- a/gcc/rust/resolve/rust-ast-resolve-stmt.h
+++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h
@@ -115,11 +115,9 @@ public:
}
}
- struct_decl.iterate ([&] (AST::TupleField &field) mutable -> bool {
+ for (AST::TupleField &field : struct_decl.get_fields ())
ResolveType::go (field.get_field_type ().get (),
struct_decl.get_node_id ());
- return true;
- });
resolver->get_type_scope ().pop ();
}
^ 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 within AST::TupleStruct 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).