Skip to content

Commit 3f2d5a7

Browse files
committed
Got rid of lambda in TyTy::FnPtr iterate_params
Fixes issue #734 1)Removed iterate_params function 2)Created a get_params function which returns std::vector& params Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
1 parent 10de9cf commit 3f2d5a7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

gcc/rust/backend/rust-compile-type.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ TyTyResolveCompile::visit (const TyTy::FnPtr &type)
148148
tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ());
149149

150150
std::vector<tree> parameters;
151-
type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool {
152-
tree pty = TyTyResolveCompile::compile (ctx, p);
153-
parameters.push_back (pty);
154-
return true;
155-
});
151+
152+
auto &params = type.get_params ();
153+
for (auto &p : params)
154+
{
155+
tree pty = TyTyResolveCompile::compile (ctx, p.get_tyty ());
156+
parameters.push_back (pty);
157+
}
156158

157159
translated = ctx->get_backend ()->function_ptr_type (result_type, parameters,
158160
type.get_ident ().locus);

gcc/rust/typecheck/rust-tyty.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,13 @@ std::string
12941294
FnPtr::as_string () const
12951295
{
12961296
std::string params_str;
1297-
iterate_params ([&] (BaseType *p) mutable -> bool {
1298-
params_str += p->as_string () + " ,";
1299-
return true;
1300-
});
1297+
1298+
auto &params = get_params ();
1299+
for (auto &p : params)
1300+
{
1301+
params_str += p.get_tyty ()->as_string () + " ,";
1302+
}
1303+
13011304
return "fnptr (" + params_str + ") -> " + get_return_type ()->as_string ();
13021305
}
13031306

gcc/rust/typecheck/rust-tyty.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,9 @@ class FnPtr : public BaseType
15261526
}
15271527
}
15281528

1529+
std::vector<TyVar> &get_params () { return params; }
1530+
const std::vector<TyVar> &get_params () const { return params; }
1531+
15291532
bool is_concrete () const override final
15301533
{
15311534
for (auto &p : params)

0 commit comments

Comments
 (0)