|
18 | 18 |
|
19 | 19 | #include "rust-hir-expr.h" |
20 | 20 | #include "rust-hir-map.h" |
| 21 | +#include "optional.h" |
21 | 22 | #include "rust-operators.h" |
22 | 23 | #include "rust-hir-stmt.h" |
23 | 24 |
|
@@ -794,22 +795,33 @@ BlockExpr::operator= (BlockExpr const &other) |
794 | 795 | AnonConst::AnonConst (Analysis::NodeMapping mappings, |
795 | 796 | std::unique_ptr<Expr> &&expr, location_t locus) |
796 | 797 | : ExprWithBlock (std::move (mappings), {}), locus (locus), |
797 | | - expr (std::move (expr)) |
| 798 | + kind (Kind::Explicit), expr (std::move (expr)) |
798 | 799 | { |
799 | | - rust_assert (this->expr); |
| 800 | + rust_assert (this->expr.value ()); |
800 | 801 | } |
801 | 802 |
|
802 | | -AnonConst::AnonConst (const AnonConst &other) |
803 | | - : ExprWithBlock (other), locus (other.locus), expr (other.expr->clone_expr ()) |
| 803 | +AnonConst::AnonConst (Analysis::NodeMapping mappings, location_t locus) |
| 804 | + : ExprWithBlock (std::move (mappings), {}), locus (locus), |
| 805 | + kind (Kind::DeferredInference), expr (tl::nullopt) |
804 | 806 | {} |
805 | 807 |
|
| 808 | +AnonConst::AnonConst (const AnonConst &other) |
| 809 | + : ExprWithBlock (other), locus (other.locus), kind (other.kind) |
| 810 | +{ |
| 811 | + if (other.expr) |
| 812 | + expr = other.expr.value ()->clone_expr (); |
| 813 | +} |
| 814 | + |
806 | 815 | AnonConst |
807 | 816 | AnonConst::operator= (const AnonConst &other) |
808 | 817 | { |
809 | 818 | ExprWithBlock::operator= (other); |
810 | 819 |
|
811 | 820 | locus = other.locus; |
812 | | - expr = other.expr->clone_expr (); |
| 821 | + kind = other.kind; |
| 822 | + |
| 823 | + if (other.expr) |
| 824 | + expr = other.expr.value ()->clone_expr (); |
813 | 825 |
|
814 | 826 | return *this; |
815 | 827 | } |
|
0 commit comments