Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gcc/rust/ast/rust-ast-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,5 +737,15 @@ Builder::new_generic_args (GenericArgs &args)
std::move (binding_args), locus);
}

std::unique_ptr<Expr>
Builder::qualified_call (std::vector<std::string> &&segments,
std::vector<std::unique_ptr<Expr>> &&args) const
{
auto path = std::unique_ptr<Expr> (
new PathInExpression (path_in_expression (std::move (segments))));

return call (std::move (path), std::move (args));
}

} // namespace AST
} // namespace Rust
4 changes: 4 additions & 0 deletions gcc/rust/ast/rust-ast-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class Builder
std::vector<PathExprSegment> &&segments
= {}) const;

std::unique_ptr<Expr>
qualified_call (std::vector<std::string> &&segments,
std::vector<std::unique_ptr<Expr>> &&args) const;

/* Self parameter for a function definition (`&self`) */
std::unique_ptr<Param> self_ref_param (bool mutability = false) const;
/* A regular named function parameter for a definition (`a: type`) */
Expand Down
5 changes: 1 addition & 4 deletions gcc/rust/expand/rust-derive-clone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ DeriveClone::clone_call (std::unique_ptr<Expr> &&to_clone)
// able to directly call `::core::clone::Clone::clone()`

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

auto path = std::unique_ptr<Expr> (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this variable still used ?

new PathInExpression (builder.path_in_expression ({"Clone", "clone"})));

auto args = std::vector<std::unique_ptr<Expr>> ();
args.emplace_back (std::move (to_clone));

return builder.call (std::move (path), std::move (args));
return builder.qualified_call ({"Clone", "clone"}, std::move (args));
}

/**
Expand Down Expand Up @@ -104,8 +103,6 @@ DeriveClone::clone_impl (
std::move (generics.impl));
}

// TODO: Create new `make_qualified_call` helper function

DeriveClone::DeriveClone (location_t loc)
: DeriveVisitor (loc), expanded (nullptr)
{}
Expand Down