|
18 | 18 |
|
19 | 19 | #include "rust-ast-builder.h" |
20 | 20 | #include "optional.h" |
21 | | -#include "rust-ast-builder-type.h" |
22 | 21 | #include "rust-ast.h" |
23 | 22 | #include "rust-common.h" |
24 | 23 | #include "rust-expr.h" |
|
29 | 28 | #include "rust-pattern.h" |
30 | 29 | #include "rust-system.h" |
31 | 30 | #include "rust-token.h" |
32 | | -#include <memory> |
33 | 31 |
|
34 | 32 | namespace Rust { |
35 | 33 | namespace AST { |
@@ -552,13 +550,6 @@ Builder::discriminant_value (std::string binding_name, std::string instance) |
552 | 550 | call (std::move (intrinsic), identifier (instance))); |
553 | 551 | } |
554 | 552 |
|
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 | | - |
562 | 553 | std::unique_ptr<GenericParam> |
563 | 554 | Builder::new_lifetime_param (LifetimeParam ¶m) |
564 | 555 | { |
@@ -596,7 +587,7 @@ Builder::new_type_param ( |
596 | 587 | std::unique_ptr<Type> type = nullptr; |
597 | 588 |
|
598 | 589 | if (param.has_type ()) |
599 | | - type = new_type (param.get_type ()); |
| 590 | + type = param.get_type ().reconstruct (); |
600 | 591 |
|
601 | 592 | for (auto &&extra_bound : extra_bounds) |
602 | 593 | type_param_bounds.emplace_back (std::move (extra_bound)); |
@@ -726,28 +717,33 @@ Builder::new_generic_args (GenericArgs &args) |
726 | 717 | for (auto &binding : args.get_binding_args ()) |
727 | 718 | { |
728 | 719 | Type &t = *binding.get_type_ptr ().get (); |
729 | | - std::unique_ptr<Type> ty = new_type (t); |
| 720 | + std::unique_ptr<Type> ty = t.reconstruct (); |
730 | 721 | GenericArgsBinding b (binding.get_identifier (), std::move (ty), |
731 | 722 | binding.get_locus ()); |
732 | 723 | binding_args.push_back (std::move (b)); |
733 | 724 | } |
734 | 725 |
|
735 | 726 | for (auto &arg : args.get_generic_args ()) |
736 | 727 | { |
| 728 | + tl::optional<GenericArg> new_arg = tl::nullopt; |
| 729 | + |
737 | 730 | switch (arg.get_kind ()) |
738 | 731 | { |
739 | 732 | 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 ()); |
744 | 734 | 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()` |
749 | 743 | break; |
750 | 744 | } |
| 745 | + |
| 746 | + generic_args.emplace_back (*new_arg); |
751 | 747 | } |
752 | 748 |
|
753 | 749 | return GenericArgs (std::move (lifetime_args), std::move (generic_args), |
|
0 commit comments