Skip to content

Commit

Permalink
Remove lambdas with Hir::TupleStruct (Rust-GCC#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
dafaust committed Oct 7, 2021
1 parent 431a389 commit c29aca4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
9 changes: 0 additions & 9 deletions gcc/rust/hir/tree/rust-hir-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1603,15 +1603,6 @@ class TupleStruct : public Struct
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 */
Expand Down
18 changes: 8 additions & 10 deletions gcc/rust/typecheck/rust-hir-type-check-stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,15 @@ class TypeCheckStmt : public TypeCheckBase
std::vector<TyTy::StructFieldType *> fields;

size_t idx = 0;
struct_decl.iterate ([&] (HIR::TupleField &field) mutable -> bool {
TyTy::BaseType *field_type
= TypeCheckType::Resolve (field.get_field_type ().get ());
TyTy::StructFieldType *ty_field
= new TyTy::StructFieldType (field.get_mappings ().get_hirid (),
std::to_string (idx), field_type);
fields.push_back (ty_field);
context->insert_type (field.get_mappings (), ty_field->get_field_type ());
for (auto &field : struct_decl.get_fields()) {
TyTy::BaseType *field_type =
TypeCheckType::Resolve(field.get_field_type().get());
TyTy::StructFieldType *ty_field = new TyTy::StructFieldType(
field.get_mappings().get_hirid(), std::to_string(idx), field_type);
fields.push_back(ty_field);
context->insert_type(field.get_mappings(), ty_field->get_field_type());
idx++;
return true;
});
}

TyTy::BaseType *type
= new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (),
Expand Down
18 changes: 8 additions & 10 deletions gcc/rust/typecheck/rust-hir-type-check-toplevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,15 @@ class TypeCheckTopLevel : public TypeCheckBase
std::vector<TyTy::StructFieldType *> fields;

size_t idx = 0;
struct_decl.iterate ([&] (HIR::TupleField &field) mutable -> bool {
TyTy::BaseType *field_type
= TypeCheckType::Resolve (field.get_field_type ().get ());
TyTy::StructFieldType *ty_field
= new TyTy::StructFieldType (field.get_mappings ().get_hirid (),
std::to_string (idx), field_type);
fields.push_back (ty_field);
context->insert_type (field.get_mappings (), ty_field->get_field_type ());
for (auto &field : struct_decl.get_fields()) {
TyTy::BaseType *field_type =
TypeCheckType::Resolve(field.get_field_type().get());
TyTy::StructFieldType *ty_field = new TyTy::StructFieldType(
field.get_mappings().get_hirid(), std::to_string(idx), field_type);
fields.push_back(ty_field);
context->insert_type(field.get_mappings(), ty_field->get_field_type());
idx++;
return true;
});
}

TyTy::BaseType *type
= new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (),
Expand Down

0 comments on commit c29aca4

Please sign in to comment.