Skip to content

Commit 95a09d7

Browse files
authored
Merge branch 'master' into restpattern-tuple-compile
2 parents 3bb39a7 + 138a760 commit 95a09d7

17 files changed

Lines changed: 339 additions & 305 deletions

gcc/rust/Make-lang.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ GRS_OBJS = \
9393
rust/rust-cfg-strip.o \
9494
rust/rust-expand-visitor.o \
9595
rust/rust-ast-builder.o \
96-
rust/rust-ast-builder-type.o \
9796
rust/rust-derive.o \
9897
rust/rust-derive-cmp-common.o \
9998
rust/rust-derive-clone.o \

gcc/rust/ast/rust-ast-builder-type.cc

Lines changed: 0 additions & 166 deletions
This file was deleted.

gcc/rust/ast/rust-ast-builder-type.h

Lines changed: 0 additions & 57 deletions
This file was deleted.

gcc/rust/ast/rust-ast-builder.cc

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "rust-ast-builder.h"
2020
#include "optional.h"
21-
#include "rust-ast-builder-type.h"
2221
#include "rust-ast.h"
2322
#include "rust-common.h"
2423
#include "rust-expr.h"
@@ -29,7 +28,6 @@
2928
#include "rust-pattern.h"
3029
#include "rust-system.h"
3130
#include "rust-token.h"
32-
#include <memory>
3331

3432
namespace Rust {
3533
namespace AST {
@@ -552,13 +550,6 @@ Builder::discriminant_value (std::string binding_name, std::string instance)
552550
call (std::move (intrinsic), identifier (instance)));
553551
}
554552

555-
std::unique_ptr<Type>
556-
Builder::new_type (Type &type)
557-
{
558-
Type *t = ASTTypeBuilder::build (type);
559-
return std::unique_ptr<Type> (t);
560-
}
561-
562553
std::unique_ptr<GenericParam>
563554
Builder::new_lifetime_param (LifetimeParam &param)
564555
{
@@ -596,7 +587,7 @@ Builder::new_type_param (
596587
std::unique_ptr<Type> type = nullptr;
597588

598589
if (param.has_type ())
599-
type = new_type (param.get_type ());
590+
type = param.get_type ().reconstruct ();
600591

601592
for (auto &&extra_bound : extra_bounds)
602593
type_param_bounds.emplace_back (std::move (extra_bound));
@@ -726,28 +717,33 @@ Builder::new_generic_args (GenericArgs &args)
726717
for (auto &binding : args.get_binding_args ())
727718
{
728719
Type &t = *binding.get_type_ptr ().get ();
729-
std::unique_ptr<Type> ty = new_type (t);
720+
std::unique_ptr<Type> ty = t.reconstruct ();
730721
GenericArgsBinding b (binding.get_identifier (), std::move (ty),
731722
binding.get_locus ());
732723
binding_args.push_back (std::move (b));
733724
}
734725

735726
for (auto &arg : args.get_generic_args ())
736727
{
728+
tl::optional<GenericArg> new_arg = tl::nullopt;
729+
737730
switch (arg.get_kind ())
738731
{
739732
case GenericArg::Kind::Type:
740-
{
741-
std::unique_ptr<Type> ty = new_type (arg.get_type ());
742-
GenericArg arg = GenericArg::create_type (std::move (ty));
743-
}
733+
new_arg = GenericArg::create_type (arg.get_type ().reconstruct ());
744734
break;
745-
746-
default:
747-
// FIXME
748-
rust_unreachable ();
735+
case GenericArg::Kind::Either:
736+
new_arg
737+
= GenericArg::create_ambiguous (arg.get_path (), arg.get_locus ());
738+
break;
739+
case GenericArg::Kind::Const:
740+
new_arg
741+
= GenericArg::create_const (arg.get_expression ().clone_expr ());
742+
// FIXME: Use `reconstruct()` here, not `clone_expr()`
749743
break;
750744
}
745+
746+
generic_args.emplace_back (*new_arg);
751747
}
752748

753749
return GenericArgs (std::move (lifetime_args), std::move (generic_args),

gcc/rust/ast/rust-ast-builder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ class Builder
315315
std::unique_ptr<Stmt> discriminant_value (std::string binding_name,
316316
std::string instance = "self");
317317

318-
static std::unique_ptr<Type> new_type (Type &type);
319-
320318
static std::unique_ptr<GenericParam>
321319
new_lifetime_param (LifetimeParam &param);
322320

0 commit comments

Comments
 (0)