Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Rust::make_unique #3278

Merged
merged 1 commit into from
Jan 3, 2025
Merged
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
1 change: 0 additions & 1 deletion gcc/rust/ast/rust-ast-builder-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "rust-ast-builder.h"
#include "rust-ast-full.h"
#include "rust-common.h"
#include "rust-make-unique.h"

namespace Rust {
namespace AST {
Expand Down
3 changes: 1 addition & 2 deletions gcc/rust/ast/rust-ast-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "rust-expr.h"
#include "rust-path.h"
#include "rust-token.h"
#include "rust-make-unique.h"

namespace Rust {
namespace AST {
Expand Down Expand Up @@ -73,7 +72,7 @@ Builder::call (std::unique_ptr<Path> &&path, std::unique_ptr<Expr> &&arg) const
std::unique_ptr<Expr>
Builder::array (std::vector<std::unique_ptr<Expr>> &&members) const
{
auto elts = Rust::make_unique<ArrayElemsValues> (std::move (members), loc);
auto elts = std::make_unique<ArrayElemsValues> (std::move (members), loc);

return std::unique_ptr<Expr> (new ArrayExpr (std::move (elts), {}, {}, loc));
}
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/ast/rust-ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ Attribute::get_traits_to_derive ()
case AST::MetaItem::ItemKind::Word: {
auto word = static_cast<AST::MetaWord *> (meta_item);
// Convert current word to path
current
= make_unique<AST::MetaItemPath> (AST::MetaItemPath (
current = std::make_unique<AST::MetaItemPath> (
AST::MetaItemPath (
AST::SimplePath (word->get_ident ())));
auto path
= static_cast<AST::MetaItemPath *> (current.get ());
Expand Down
5 changes: 2 additions & 3 deletions gcc/rust/ast/rust-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "rust-ast-fragment.h"
#include "rust-location.h"
#include "rust-item.h"
#include "rust-make-unique.h"
#include "rust-macro-builtins.h"

namespace Rust {
Expand Down Expand Up @@ -521,7 +520,7 @@ class MacroRulesDefinition : public VisItem
mbe (Identifier rule_name, DelimType delim_type, std::vector<MacroRule> rules,
std::vector<Attribute> outer_attrs, location_t locus)
{
return Rust::make_unique<MacroRulesDefinition> (
return std::make_unique<MacroRulesDefinition> (
MacroRulesDefinition (rule_name, delim_type, rules, outer_attrs, locus,
AST::MacroRulesDefinition::MacroKind::MBE,
AST::Visibility::create_error ()));
Expand All @@ -532,7 +531,7 @@ class MacroRulesDefinition : public VisItem
std::vector<Attribute> outer_attrs, location_t locus,
Visibility vis)
{
return Rust::make_unique<MacroRulesDefinition> (MacroRulesDefinition (
return std::make_unique<MacroRulesDefinition> (MacroRulesDefinition (
rule_name, AST::DelimType::CURLY, rules, outer_attrs, locus,
AST::MacroRulesDefinition::MacroKind::DeclMacro, vis));
}
Expand Down
8 changes: 4 additions & 4 deletions gcc/rust/ast/rust-path.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
: outer_attrs (std::move (outer_attrs)),
has_opening_scope_resolution (has_opening_scope_resolution),
locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ()),
path (Rust::make_unique<RegularPath> (std::move (path_segments), locus,
_node_id)),
path (std::make_unique<RegularPath> (std::move (path_segments), locus,
_node_id)),
marked_for_strip (false)
{}

Expand All @@ -720,7 +720,7 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
: outer_attrs (std::move (outer_attrs)),
has_opening_scope_resolution (false), locus (locus),
_node_id (Analysis::Mappings::get ().get_next_node_id ()),
path (Rust::make_unique<LangItemPath> (lang_item_kind, locus)),
path (std::make_unique<LangItemPath> (lang_item_kind, locus)),
marked_for_strip (false)
{}

Expand Down Expand Up @@ -1439,7 +1439,7 @@ class QualifiedPathInExpression : public Pattern, public ExprWithoutBlock
location_t locus)
: outer_attrs (std::move (outer_attrs)),
path_type (std::move (qual_path_type)),
path (Rust::make_unique<RegularPath> (
path (std::make_unique<RegularPath> (
std::move (path_segments), locus,
Analysis::Mappings::get ().get_next_node_id ()))
{}
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void
CompilePatternCheckExpr::visit (HIR::LiteralPattern &pattern)
{
// Compile the literal
auto litexpr = Rust::make_unique<HIR::LiteralExpr> (
auto litexpr = std::make_unique<HIR::LiteralExpr> (
HIR::LiteralExpr (pattern.get_mappings (), pattern.get_literal (),
pattern.get_locus (), std::vector<AST::Attribute> ()));

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/expand/rust-derive-copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DeriveCopy::copy_impl (
// `$crate::core::marker::Copy` instead
auto segments = std::vector<std::unique_ptr<TypePathSegment>> ();
segments.emplace_back (builder.type_path_segment ("Copy"));
auto copy = Rust::make_unique<LangItemPath> (LangItem::Kind::COPY, loc);
auto copy = std::make_unique<LangItemPath> (LangItem::Kind::COPY, loc);

// we need to build up the generics for this impl block which will be just a
// clone of the types specified ones
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/expand/rust-expand-format-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ expand_format_args (AST::FormatArgs &fmt,
auto pieces = builder.ref (builder.array (std::move (static_pieces)));
auto args_slice = builder.ref (builder.array (std::move (args_array)));

auto final_path = make_unique<AST::PathInExpression> (
auto final_path = std::make_unique<AST::PathInExpression> (
builder.path_in_expression ({"core", "fmt", "Arguments", "new_v1"}));
auto final_args = std::vector<std::unique_ptr<AST::Expr>> ();
final_args.emplace_back (std::move (pieces));
Expand Down
7 changes: 3 additions & 4 deletions gcc/rust/expand/rust-macro-builtins-asm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// <http://www.gnu.org/licenses/>.

#include "expected.h"
#include "rust-make-unique.h"
#include "rust-macro-builtins-asm.h"
#include "rust-ast-fragment.h"
#include "rust-ast.h"
Expand Down Expand Up @@ -858,9 +857,9 @@ parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc,
// properly.
if (semicolon == AST::InvocKind::Semicoloned)
single_vec.emplace_back (AST::SingleASTNode (
Rust::make_unique<AST::ExprStmt> (std::move (node), invoc_locus,
semicolon
== AST::InvocKind::Semicoloned)));
std::make_unique<AST::ExprStmt> (std::move (node), invoc_locus,
semicolon
== AST::InvocKind::Semicoloned)));
else
single_vec.emplace_back (AST::SingleASTNode (std::move (node)));

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/hir/rust-ast-lower-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ ASTLoweringExpr::visit (AST::StructExprStructFields &struct_expr)
HIR::Expr *translated_base = ASTLoweringExpr::translate (
struct_expr.get_struct_base ().get_base_struct ());
base = tl::optional<std::unique_ptr<HIR::StructBase>> (
Rust::make_unique<StructBase> (
std::make_unique<StructBase> (
std::unique_ptr<HIR::Expr> (translated_base)));
}

Expand Down
10 changes: 5 additions & 5 deletions gcc/rust/hir/tree/rust-hir-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@ StructExprStructFields::StructExprStructFields (
StructExprStructFields::StructExprStructFields (
StructExprStructFields const &other)
: StructExprStruct (other),
struct_base (
other.has_struct_base () ? tl::optional<std::unique_ptr<StructBase>> (
Rust::make_unique<StructBase> (*other.struct_base.value ()))
: tl::nullopt),
struct_base (other.has_struct_base ()
? tl::optional<std::unique_ptr<StructBase>> (
std::make_unique<StructBase> (*other.struct_base.value ()))
: tl::nullopt),
union_index (other.union_index)
{
fields.reserve (other.fields.size ());
Expand All @@ -558,7 +558,7 @@ StructExprStructFields::operator= (StructExprStructFields const &other)
StructExprStruct::operator= (other);
struct_base = other.has_struct_base ()
? tl::optional<std::unique_ptr<StructBase>> (
Rust::make_unique<StructBase> (*other.struct_base.value ()))
std::make_unique<StructBase> (*other.struct_base.value ()))
: tl::nullopt;
union_index = other.union_index;

Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/hir/tree/rust-hir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2710,8 +2710,8 @@ TypePath::to_trait_bound (bool in_parens) const
// create clone FIXME is this required? or is copy constructor automatically
// called?
TypePath copy (*this);
return Rust::make_unique<TraitBound> (mappings, std::move (copy),
copy.get_locus (), in_parens);
return std::make_unique<TraitBound> (mappings, std::move (copy),
copy.get_locus (), in_parens);
}

std::string
Expand Down
7 changes: 3 additions & 4 deletions gcc/rust/lex/rust-token.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "rust-system.h"
#include "rust-linemap.h"
#include "rust-make-unique.h"
#include "rust-unicode.h"

namespace Rust {
Expand Down Expand Up @@ -268,7 +267,7 @@ class Token
: token_id (token_id), locus (location), type_hint (CORETYPE_UNKNOWN)
{
// Normalize identifier tokens
str = Rust::make_unique<std::string> (
str = std::make_unique<std::string> (
nfc_normalize_token_string (location, token_id, paramStr));
}

Expand All @@ -285,7 +284,7 @@ class Token
: token_id (token_id), locus (location), type_hint (CORETYPE_UNKNOWN)
{
// Normalize identifier tokens
str = Rust::make_unique<std::string> (
str = std::make_unique<std::string> (
nfc_normalize_token_string (location, token_id,
paramCodepoint.as_string ()));
}
Expand All @@ -296,7 +295,7 @@ class Token
: token_id (token_id), locus (location), type_hint (parType)
{
// Normalize identifier tokens
str = Rust::make_unique<std::string> (
str = std::make_unique<std::string> (
nfc_normalize_token_string (location, token_id, paramStr));
}

Expand Down
5 changes: 2 additions & 3 deletions gcc/rust/metadata/rust-import-archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "rust-system.h"
#include "rust-diagnostics.h"
#include "rust-imports.h"
#include "rust-make-unique.h"

#ifndef O_BINARY
#define O_BINARY 0
Expand Down Expand Up @@ -844,7 +843,7 @@ Import::find_archive_export_data (const std::string &filename, int fd,
if (!afile.initialize ())
return nullptr;

auto ret = Rust::make_unique<Stream_concatenate> ();
auto ret = std::make_unique<Stream_concatenate> ();

bool any_data = false;
bool any_members = false;
Expand Down Expand Up @@ -872,7 +871,7 @@ Import::find_archive_export_data (const std::string &filename, int fd,
if (!any_members)
{
// It's normal to have an empty archive file when using gobuild.
return Rust::make_unique<Stream_from_string> ("");
return std::make_unique<Stream_from_string> ("");
}

if (!any_data)
Expand Down
5 changes: 2 additions & 3 deletions gcc/rust/metadata/rust-imports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "rust-imports.h"
#include "rust-object-export.h"
#include "rust-export-metadata.h"
#include "rust-make-unique.h"

#ifndef O_BINARY
#define O_BINARY 0
Expand Down Expand Up @@ -259,7 +258,7 @@ Import::find_export_data (const std::string &filename, int fd,
//
if (memcmp (buf, Metadata::kMagicHeader, sizeof (Metadata::kMagicHeader))
== 0)
return Rust::make_unique<Stream_from_file> (fd);
return std::make_unique<Stream_from_file> (fd);

// See if we can read this as an archive.
if (Import::is_archive_magic (buf))
Expand Down Expand Up @@ -291,7 +290,7 @@ Import::find_object_export_data (const std::string &filename, int fd,
if (buf == nullptr)
return nullptr;

return Rust::make_unique<Stream_from_buffer> (buf, len);
return std::make_unique<Stream_from_buffer> (buf, len);
}

// Class Import.
Expand Down
23 changes: 11 additions & 12 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "rust-token.h"
#define INCLUDE_ALGORITHM
#include "rust-diagnostics.h"
#include "rust-make-unique.h"
#include "rust-dir-owner.h"
#include "rust-attribute-values.h"
#include "rust-keyword-values.h"
Expand Down Expand Up @@ -3683,7 +3682,7 @@ Parser<ManagedTokenSource>::parse_function_param ()
if (lexer.peek_token ()->get_id () == ELLIPSIS) // Unnamed variadic
{
lexer.skip_token (); // Skip ellipsis
return Rust::make_unique<AST::VariadicParam> (
return std::make_unique<AST::VariadicParam> (
AST::VariadicParam (std::move (outer_attrs), locus));
}

Expand All @@ -3705,7 +3704,7 @@ Parser<ManagedTokenSource>::parse_function_param ()
if (lexer.peek_token ()->get_id () == ELLIPSIS) // Named variadic
{
lexer.skip_token (); // Skip ellipsis
return Rust::make_unique<AST::VariadicParam> (
return std::make_unique<AST::VariadicParam> (
AST::VariadicParam (std::move (param_pattern), std::move (outer_attrs),
locus));
}
Expand All @@ -3716,7 +3715,7 @@ Parser<ManagedTokenSource>::parse_function_param ()
{
return nullptr;
}
return Rust::make_unique<AST::FunctionParam> (
return std::make_unique<AST::FunctionParam> (
AST::FunctionParam (std::move (param_pattern), std::move (param_type),
std::move (outer_attrs), locus));
}
Expand Down Expand Up @@ -7124,14 +7123,14 @@ Parser<ManagedTokenSource>::parse_self_param ()

if (has_reference)
{
return Rust::make_unique<AST::SelfParam> (std::move (lifetime), has_mut,
locus);
return std::make_unique<AST::SelfParam> (std::move (lifetime), has_mut,
locus);
}
else
{
// note that type may be nullptr here and that's fine
return Rust::make_unique<AST::SelfParam> (std::move (type), has_mut,
locus);
return std::make_unique<AST::SelfParam> (std::move (type), has_mut,
locus);
}
}

Expand Down Expand Up @@ -8693,10 +8692,10 @@ Parser<ManagedTokenSource>::parse_array_expr (AST::AttrVec outer_attrs,

std::vector<std::unique_ptr<AST::Expr>> exprs;
auto array_elems
= Rust::make_unique<AST::ArrayElemsValues> (std::move (exprs), locus);
return Rust::make_unique<AST::ArrayExpr> (std::move (array_elems),
std::move (inner_attrs),
std::move (outer_attrs), locus);
= std::make_unique<AST::ArrayElemsValues> (std::move (exprs), locus);
return std::make_unique<AST::ArrayExpr> (std::move (array_elems),
std::move (inner_attrs),
std::move (outer_attrs), locus);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
auto discim_expr = Rust::make_unique<HIR::LiteralExpr> (
auto discim_expr = std::make_unique<HIR::LiteralExpr> (
HIR::LiteralExpr (mapping, std::to_string (last_discriminant),
HIR::Literal::LitType::INT,
PrimitiveCoreType::CORETYPE_I64, item.get_locus (), {}));
Expand Down Expand Up @@ -174,7 +174,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
auto discim_expr = Rust::make_unique<HIR::LiteralExpr> (
auto discim_expr = std::make_unique<HIR::LiteralExpr> (
HIR::LiteralExpr (mapping, std::to_string (last_discriminant),
HIR::Literal::LitType::INT,
PrimitiveCoreType::CORETYPE_I64, item.get_locus (), {}));
Expand Down Expand Up @@ -234,7 +234,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
auto discrim_expr = Rust::make_unique<HIR::LiteralExpr> (
auto discrim_expr = std::make_unique<HIR::LiteralExpr> (
HIR::LiteralExpr (mapping, std::to_string (last_discriminant),
HIR::Literal::LitType::INT,
PrimitiveCoreType::CORETYPE_I64, item.get_locus (), {}));
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check-implitem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function)
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);

auto param_pattern = Rust::make_unique<HIR::IdentifierPattern> (
auto param_pattern = std::make_unique<HIR::IdentifierPattern> (
HIR::IdentifierPattern (mapping, param.get_param_name (),
UNDEF_LOCATION, false, Mutability::Imm,
std::unique_ptr<HIR::Pattern> (nullptr)));
Expand Down Expand Up @@ -390,7 +390,7 @@ TypeCheckImplItem::visit (HIR::Function &function)
HIR::SelfParam &self_param = function.get_self_param ();
// FIXME: which location should be used for Rust::Identifier for `self`?
std::unique_ptr<HIR::Pattern> self_pattern
= Rust::make_unique<HIR::IdentifierPattern> (
= std::make_unique<HIR::IdentifierPattern> (
HIR::IdentifierPattern (mapping, {"self"}, self_param.get_locus (),
self_param.is_ref (), self_param.get_mut (),
std::unique_ptr<HIR::Pattern> (nullptr)));
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-hir-type-check-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ TypeResolveGenericParam::visit (HIR::TypeParam &param)
param.get_mappings ().get_nodeid (),
implicit_id,
param.get_mappings ().get_local_defid ());
implicit_self_bound = Rust::make_unique<HIR::TypePath> (
implicit_self_bound = std::make_unique<HIR::TypePath> (
HIR::TypePath (mappings, {}, BUILTINS_LOCATION, false));
}

Expand Down
Loading
Loading