Skip to content

Commit d7df9ae

Browse files
committed
derive: Implement make_qualified_call helper
This patch implements the make_qualified_call helper function as requested by the TODO in rust-derive-clone.cc. It refactors DeriveClone::clone_call to use this new helper, simplifying the construction of qualified paths for function calls. Fixes #4393 gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (make_qualified_call): New helper function. (DeriveClone::clone_call): Use make_qualified_call. Signed-off-by: Jayant Chauhan <[email protected]>
1 parent 23de527 commit d7df9ae

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

gcc/rust/expand/rust-derive-clone.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
namespace Rust {
2828
namespace AST {
2929

30+
static std::unique_ptr<Expr>
31+
make_qualified_call (Builder &builder, std::vector<std::string> segments,
32+
std::vector<std::unique_ptr<Expr>> args)
33+
{
34+
auto path = std::unique_ptr<Expr> (
35+
new PathInExpression (builder.path_in_expression (std::move (segments))));
36+
37+
return builder.call (std::move (path), std::move (args));
38+
}
39+
3040
std::unique_ptr<Expr>
3141
DeriveClone::clone_call (std::unique_ptr<Expr> &&to_clone)
3242
{
@@ -42,13 +52,10 @@ DeriveClone::clone_call (std::unique_ptr<Expr> &&to_clone)
4252

4353
// Not sure how to call it properly in the meantime...
4454

45-
auto path = std::unique_ptr<Expr> (
46-
new PathInExpression (builder.path_in_expression ({"Clone", "clone"})));
47-
4855
auto args = std::vector<std::unique_ptr<Expr>> ();
4956
args.emplace_back (std::move (to_clone));
5057

51-
return builder.call (std::move (path), std::move (args));
58+
return make_qualified_call (builder, {"Clone", "clone"}, std::move (args));
5259
}
5360

5461
/**
@@ -104,8 +111,6 @@ DeriveClone::clone_impl (
104111
std::move (generics.impl));
105112
}
106113

107-
// TODO: Create new `make_qualified_call` helper function
108-
109114
DeriveClone::DeriveClone (location_t loc)
110115
: DeriveVisitor (loc), expanded (nullptr)
111116
{}

0 commit comments

Comments
 (0)