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
7 changes: 1 addition & 6 deletions gcc/rust/expand/rust-derive-clone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ DeriveClone::clone_call (std::unique_ptr<Expr> &&to_clone)

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

auto path = std::unique_ptr<Expr> (
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 +101,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