2121
2222#include " optional.h"
2323#include " rust-ast.h"
24+ #include " rust-expr.h"
2425#include " rust-path.h"
2526
2627namespace Rust {
@@ -678,27 +679,26 @@ class ReferenceType : public TypeNoBounds
678679class ArrayType : public TypeNoBounds
679680{
680681 std::unique_ptr<Type> elem_type;
681- std::unique_ptr<Expr> size;
682+ AnonConst size;
682683 location_t locus;
683684
684685public:
685686 // Constructor requires pointers for polymorphism
686- ArrayType (std::unique_ptr<Type> type, std::unique_ptr<Expr> array_size,
687- location_t locus)
687+ ArrayType (std::unique_ptr<Type> type, AnonConst array_size, location_t locus)
688688 : elem_type (std::move (type)), size (std::move (array_size)), locus (locus)
689689 {}
690690
691691 // Copy constructor requires deep copies of both unique pointers
692692 ArrayType (ArrayType const &other)
693- : elem_type (other.elem_type->clone_type ()),
694- size (other.size-> clone_expr ()), locus (other.locus)
693+ : elem_type (other.elem_type->clone_type ()), size (other.size),
694+ locus (other.locus)
695695 {}
696696
697697 // Overload assignment operator to deep copy pointers
698698 ArrayType &operator = (ArrayType const &other)
699699 {
700700 elem_type = other.elem_type ->clone_type ();
701- size = other.size -> clone_expr () ;
701+ size = other.size ;
702702 locus = other.locus ;
703703 return *this ;
704704 }
@@ -721,17 +721,15 @@ class ArrayType : public TypeNoBounds
721721 }
722722
723723 // TODO: would a "vis_expr" be better?
724- Expr &get_size_expr ()
724+ AnonConst &get_size_expr ()
725725 {
726- rust_assert (size != nullptr );
727- return *size;
726+ // rust_assert (size != nullptr);
727+
728+ return size;
728729 }
729730
730731 std::unique_ptr<Type> &get_element_type () { return elem_type; }
731732
732- // Additional getter for direct access to the size expr unique_ptr
733- std::unique_ptr<Expr> &get_size_ptr () { return size; }
734-
735733protected:
736734 /* Use covariance to implement clone function as returning this object rather
737735 * than base */
@@ -741,10 +739,9 @@ class ArrayType : public TypeNoBounds
741739 }
742740 ArrayType *reconstruct_impl () const override
743741 {
744- return new ArrayType (
745- elem_type->reconstruct (),
746- size->clone_expr () /* FIXME: This should be `reconstruct_expr()` */ ,
747- locus);
742+ return new ArrayType (elem_type->reconstruct (),
743+ size /* FIXME: This should be `reconstruct_expr()` */ ,
744+ locus);
748745 }
749746};
750747
0 commit comments