diff options
-rw-r--r-- | gcc/rust/ast/rust-item.h | 9 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.h | 36 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.h | 36 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.h | 4 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-stmt.h | 4 |
5 files changed, 38 insertions, 51 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index e319d74..16a9108 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -1975,15 +1975,6 @@ public: std::vector<StructField> &get_fields () { return fields; } const std::vector<StructField> &get_fields () const { return fields; } - void iterate (std::function<bool (StructField &)> 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 d4c0306..2a8c9bb 100644 --- a/gcc/rust/hir/rust-ast-lower-item.h +++ b/gcc/rust/hir/rust-ast-lower-item.h @@ -215,28 +215,28 @@ public: bool is_unit = struct_decl.is_unit_struct (); std::vector<HIR::StructField> fields; - struct_decl.iterate ([&] (AST::StructField &field) mutable -> bool { - HIR::Visibility vis = HIR::Visibility::create_public (); - HIR::Type *type - = ASTLoweringType::translate (field.get_field_type ().get ()); + for (AST::StructField &field : struct_decl.get_fields ()) + { + 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)); + 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::StructField translated_field (mapping, field.get_field_name (), - std::unique_ptr<HIR::Type> (type), vis, - field.get_locus (), - field.get_outer_attrs ()); + HIR::StructField translated_field (mapping, field.get_field_name (), + std::unique_ptr<HIR::Type> (type), + vis, field.get_locus (), + field.get_outer_attrs ()); - if (struct_field_name_exists (fields, translated_field)) - return false; + if (struct_field_name_exists (fields, translated_field)) + break; - fields.push_back (std::move (translated_field)); - return true; - }); + 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 b617991..237c635 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.h +++ b/gcc/rust/hir/rust-ast-lower-stmt.h @@ -203,28 +203,28 @@ public: bool is_unit = struct_decl.is_unit_struct (); std::vector<HIR::StructField> fields; - struct_decl.iterate ([&] (AST::StructField &field) mutable -> bool { - HIR::Visibility vis = HIR::Visibility::create_public (); - HIR::Type *type - = ASTLoweringType::translate (field.get_field_type ().get ()); + for (AST::StructField &field : struct_decl.get_fields ()) + { + 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)); + 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::StructField translated_field (mapping, field.get_field_name (), - std::unique_ptr<HIR::Type> (type), vis, - field.get_locus (), - field.get_outer_attrs ()); + HIR::StructField translated_field (mapping, field.get_field_name (), + std::unique_ptr<HIR::Type> (type), + vis, field.get_locus (), + field.get_outer_attrs ()); - if (struct_field_name_exists (fields, translated_field)) - return false; + if (struct_field_name_exists (fields, translated_field)) + break; - fields.push_back (std::move (translated_field)); - return true; - }); + 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 e697f1c..e8e6b8d 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -308,11 +308,9 @@ public: if (struct_decl.has_where_clause ()) ResolveWhereClause::Resolve (struct_decl.get_where_clause ()); - struct_decl.iterate ([&] (AST::StructField &field) mutable -> bool { + for (AST::StructField &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 a404365..16f5b9a 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -237,11 +237,9 @@ public: } } - struct_decl.iterate ([&] (AST::StructField &field) mutable -> bool { + for (AST::StructField &field : struct_decl.get_fields ()) ResolveType::go (field.get_field_type ().get (), struct_decl.get_node_id ()); - return true; - }); resolver->get_type_scope ().pop (); } |