aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-02-27 13:43:37 +0100
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-11-20 13:36:42 +0000
commit2d6d91a776ebd26d3bad128cfec00a60540a659b (patch)
treed6ad5753f3015b69ddbef83b23e058895e1770ca /gcc/rust/hir
parent41a12471b514e45d5f94d3a58b569ae8996c2501 (diff)
downloadgcc-2d6d91a776ebd26d3bad128cfec00a60540a659b.zip
gcc-2d6d91a776ebd26d3bad128cfec00a60540a659b.tar.gz
gcc-2d6d91a776ebd26d3bad128cfec00a60540a659b.tar.bz2
Refactor HIR to reduce the amount of raw pointers
Attempt to use references and smart pointers whenever possible. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function_body): Remove usage of get function to retrieve a raw pointer. * backend/rust-compile-base.h: Change API usage from raw pointer to a reference. * backend/rust-compile-block.cc (CompileBlock::compile): Likewise. (CompileBlock::visit): Likewise. (CompileConditionalBlocks::visit): Likewise. * backend/rust-compile-block.h: Likewise. * backend/rust-compile-expr.cc (CompileExpr::Compile): Likewise. (CompileExpr::visit): Likewise. (check_match_scrutinee): Likewise. (CompileExpr::array_value_expr): Likewise. (CompileExpr::array_copied_expr): Likewise. (CompileExpr::generate_closure_function): Likewise. (CompileExpr::generate_possible_fn_trait_call): Likewise. * backend/rust-compile-expr.h: Likewise. * backend/rust-compile-fnparam.cc (CompileFnParam::compile): Likewise. (CompileFnParam::visit): Likewise. * backend/rust-compile-fnparam.h: Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-intrinsic.cc (compile_fn_params): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Likewise. (compile_range_pattern_bound): Likewise. (CompilePatternBindings::visit): Likewise. (CompilePatternLet::visit): Likewise. * backend/rust-compile-pattern.h: Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. (HIRCompileBase::query_compile): Likewise. * backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::Compile): Likewise. (CompileStructExprField::visit): Likewise. * backend/rust-compile-struct-field-expr.h: Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-mangle-v0.cc (v0_inherent_or_trait_impl_path): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-bir-builder.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_type_privacy): Likewise. (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. * checks/lints/rust-lint-marklive.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-pattern.h: Likewise. * hir/tree/rust-hir-stmt.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-inherent-impl-overlap.h: Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::process_impl_item_candidate): Likewise. (PathProbeImplTrait::process_trait_impl_items_for_candidates): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): Likewise. (TraitItemReference::resolve_item): Likewise. * typecheck/rust-hir-type-check-base.cc: Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::Resolve): Likewise. (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-enumitem.h: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::Resolve): Likewise. (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::Resolve): Likewise. (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. (TypeCheckImplItemWithTrait::visit): Likewise. * typecheck/rust-hir-type-check-implitem.h: Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. (TypeCheckItem::resolve_impl_item): Likewise. (TypeCheckItem::resolve_impl_block_substitutions): Likewise. (TypeCheckItem::resolve_impl_block_self): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_segments): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Likewise. (TypeCheckPattern::visit): Likewise. (ClosureParamInfer::Resolve): Likewise. (ClosureParamInfer::visit): Likewise. * typecheck/rust-hir-type-check-pattern.h: Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::Resolve): Likewise. (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h: Likewise. * typecheck/rust-hir-type-check-struct-field.h: Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::TypeCheckStructExpr): Likewise. (TypeCheckStructExpr::Resolve): Likewise. (TypeCheckStructExpr::resolve): Likewise. (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckResolveGenericArguments::resolve): Likewise. (TypeCheckType::Resolve): Likewise. (TypeCheckType::visit): Likewise. (TypeCheckType::resolve_root_path): Likewise. (TypeResolveGenericParam::Resolve): Likewise. (TypeResolveGenericParam::visit): Likewise. (ResolveWhereClauseItem::visit): Likewise. * typecheck/rust-hir-type-check-type.h: Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-hir-type-check.h: Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * typecheck/rust-typecheck-context.cc (TypeCheckContextItem::TypeCheckContextItem): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. (TypeCheckMethodCallExpr::go): Likewise. (TypeCheckMethodCallExpr::check): Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty.cc (BaseType::monomorphized_clone): Likewise. (VariantDef::VariantDef): Remove copy constructor. (VariantDef::operator=): Change to move operator. (VariantDef::get_discriminant): Replace return type to a reference instead of a reference to a unique pointer. (VariantDef::clone): Change to references. (VariantDef::monomorphized_clone): Likewise. (FnType::as_string): Likewise. (FnType::clone): Likewise. * typecheck/rust-tyty.h: Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_impl_block): Likewise. * backend/rust-compile-asm.cc: Use a reference instead of the raw pointer value. * checks/errors/borrowck/rust-bir-builder-pattern.cc: Use references. * checks/errors/rust-hir-pattern-analysis.cc: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc34
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h117
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h59
-rw-r--r--gcc/rust/hir/tree/rust-hir-path.h21
-rw-r--r--gcc/rust/hir/tree/rust-hir-pattern.h18
-rw-r--r--gcc/rust/hir/tree/rust-hir-stmt.h8
-rw-r--r--gcc/rust/hir/tree/rust-hir-type.h18
-rw-r--r--gcc/rust/hir/tree/rust-hir.h7
8 files changed, 140 insertions, 142 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 8ebdd3d..1f56d5e 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -800,7 +800,7 @@ Dump::visit (QualifiedPathInType &e)
end_field ("path_type");
begin_field ("associated_segment");
- do_typepathsegment (*e.get_associated_segment ());
+ do_typepathsegment (e.get_associated_segment ());
end_field ("associated_segment");
visit_collection ("segments", e.get_segments ());
@@ -911,7 +911,7 @@ Dump::visit (ArithmeticOrLogicalExpr &e)
}
put_field ("expr_type", str);
do_operatorexpr (e);
- visit_field ("right_expr", *e.get_rhs ());
+ visit_field ("right_expr", e.get_rhs ());
end ("ArithmeticOrLogicalExpr");
}
@@ -946,7 +946,7 @@ Dump::visit (ComparisonExpr &e)
}
put_field ("expr_type", str);
do_operatorexpr (e);
- visit_field ("right_expr", *e.get_rhs ());
+ visit_field ("right_expr", e.get_rhs ());
end ("ComparisonExpr");
}
@@ -969,7 +969,7 @@ Dump::visit (LazyBooleanExpr &e)
}
do_operatorexpr (e);
- visit_field ("right_expr", *e.get_rhs ());
+ visit_field ("right_expr", e.get_rhs ());
end ("LazyBooleanExpr");
}
@@ -987,7 +987,7 @@ Dump::visit (AssignmentExpr &e)
{
begin ("AssignmentExpr");
do_operatorexpr (e);
- visit_field ("right_expr", *e.get_rhs ());
+ visit_field ("right_expr", e.get_rhs ());
end ("AssignmentExpr");
}
@@ -997,7 +997,7 @@ Dump::visit (CompoundAssignmentExpr &e)
begin ("CompoundAssignmentExpr");
do_operatorexpr (e);
- visit_field ("right_expr", *e.get_rhs ());
+ visit_field ("right_expr", e.get_rhs ());
std::string str;
@@ -1684,7 +1684,7 @@ Dump::visit (TypeAlias &e)
else
put_field ("where clause", e.get_where_clause ().as_string ());
- put_field ("type", e.get_type_aliased ()->as_string ());
+ put_field ("type", e.get_type_aliased ().as_string ());
end ("TypeAlias");
}
@@ -2050,7 +2050,7 @@ Dump::visit (IdentifierPattern &e)
put_field ("mut", std::to_string (e.is_mut ()));
if (e.has_pattern_to_bind ())
- put_field ("to_bind", e.get_to_bind ()->as_string ());
+ put_field ("to_bind", e.get_to_bind ().as_string ());
else
put_field ("to_bind", "none");
@@ -2094,8 +2094,8 @@ Dump::visit (RangePattern &e)
{
begin ("RangePattern");
do_mappings (e.get_mappings ());
- put_field ("lower", e.get_lower_bound ()->as_string ());
- put_field ("upper", e.get_upper_bound ()->as_string ());
+ put_field ("lower", e.get_lower_bound ().as_string ());
+ put_field ("upper", e.get_upper_bound ().as_string ());
put_field ("has_ellipsis_syntax",
std::to_string (e.get_has_ellipsis_syntax ()));
end ("RangePattern");
@@ -2107,7 +2107,7 @@ Dump::visit (ReferencePattern &e)
begin ("ReferencePattern");
do_mappings (e.get_mappings ());
put_field ("mut", std::to_string (e.is_mut ()));
- put_field ("pattern", e.get_referenced_pattern ()->as_string ());
+ put_field ("pattern", e.get_referenced_pattern ().as_string ());
end ("ReferencePattern");
}
@@ -2119,7 +2119,7 @@ Dump::visit (StructPatternFieldTuplePat &e)
auto oa = e.get_outer_attrs ();
do_outer_attrs (oa);
put_field ("index", std::to_string (e.get_index ()));
- put_field ("tuple_pattern", e.get_tuple_pattern ()->as_string ());
+ put_field ("tuple_pattern", e.get_tuple_pattern ().as_string ());
end ("StructPatternFieldTuplePat");
}
@@ -2130,7 +2130,7 @@ Dump::visit (StructPatternFieldIdentPat &e)
auto oa = e.get_outer_attrs ();
do_outer_attrs (oa);
put_field ("ident", e.get_identifier ().as_string ());
- put_field ("ident_pattern", e.get_pattern ()->as_string ());
+ put_field ("ident_pattern", e.get_pattern ().as_string ());
end ("StructPatternFieldIdentPat");
}
@@ -2248,7 +2248,7 @@ Dump::visit (LetStmt &e)
auto oa = e.get_outer_attrs ();
do_outer_attrs (oa);
- put_field ("variable_pattern", e.get_pattern ()->as_string ());
+ put_field ("variable_pattern", e.get_pattern ().as_string ());
visit_field ("type", e.get_type ());
visit_field ("init_expr", e.get_init_expr ());
@@ -2309,7 +2309,7 @@ Dump::visit (ParenthesisedType &e)
{
begin ("ParenthesisedType");
do_type (e);
- put_field ("type_in_parens", e.get_type_in_parens ()->as_string ());
+ put_field ("type_in_parens", e.get_type_in_parens ().as_string ());
end ("ParenthesisedType");
}
@@ -2345,7 +2345,7 @@ Dump::visit (RawPointerType &e)
begin ("RawPointerType");
do_type (e);
put_field ("mut", Rust::enum_to_str (e.get_mut ()));
- put_field ("type", e.get_type ()->as_string ());
+ put_field ("type", e.get_type ().as_string ());
end ("RawPointerType");
}
@@ -2356,7 +2356,7 @@ Dump::visit (ReferenceType &e)
do_type (e);
put_field ("lifetime", e.get_lifetime ().as_string ());
put_field ("mut", enum_to_str (e.get_mut ()));
- put_field ("type", e.get_base_type ()->as_string ());
+ put_field ("type", e.get_base_type ().as_string ());
end ("ReferenceType");
}
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index cb69939..c4a821e 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -209,7 +209,7 @@ protected:
public:
location_t get_locus () const override final { return locus; }
- std::unique_ptr<Expr> &get_expr () { return main_or_left_expr; }
+ Expr &get_expr () { return *main_or_left_expr; }
ExprType get_expression_type () const override final
{
@@ -423,8 +423,8 @@ public:
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
- std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
- std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ Expr &get_lhs () { return *main_or_left_expr; }
+ Expr &get_rhs () { return *right_expr; }
std::string get_operator_str () const;
@@ -497,8 +497,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
- std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ Expr &get_lhs () { return *main_or_left_expr; }
+ Expr &get_rhs () { return *right_expr; }
ExprType get_kind () { return expr_type; }
@@ -571,8 +571,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
- std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ Expr &get_lhs () { return *main_or_left_expr; }
+ Expr &get_rhs () { return *right_expr; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -633,12 +633,9 @@ public:
void accept_vis (HIRExpressionVisitor &vis) override;
// FIXME: isn't it the same as get_expr() from parent?
- std::unique_ptr<Expr> &get_casted_expr () { return main_or_left_expr; }
+ Expr &get_casted_expr () { return *main_or_left_expr; }
- std::unique_ptr<Type> &get_type_to_convert_to ()
- {
- return type_to_convert_to;
- }
+ Type &get_type_to_convert_to () { return *type_to_convert_to; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -700,8 +697,8 @@ public:
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
- std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
- std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ Expr &get_lhs () { return *main_or_left_expr; }
+ Expr &get_rhs () { return *right_expr; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -770,9 +767,9 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
+ Expr &get_lhs () { return *main_or_left_expr; }
- std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ Expr &get_rhs () { return *right_expr; }
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
@@ -834,7 +831,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_expr_in_parens () { return expr_in_parens; }
+ Expr &get_expr_in_parens () { return *expr_in_parens; }
ExprType get_expression_type () const override final
{
@@ -986,9 +983,9 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
- std::unique_ptr<Expr> &get_elem_to_copy () { return elem_to_copy; }
+ Expr &get_elem_to_copy () { return *elem_to_copy; }
- std::unique_ptr<Expr> &get_num_copies_expr () { return num_copies; }
+ Expr &get_num_copies_expr () { return *num_copies; }
ArrayElems::ArrayExprType get_array_expr_type () const override final
{
@@ -1056,10 +1053,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<ArrayElems> &get_internal_elements ()
- {
- return internal_elements;
- };
+ ArrayElems &get_internal_elements () { return *internal_elements; };
ExprType get_expression_type () const override final
{
@@ -1125,8 +1119,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_array_expr () { return array_expr; }
- std::unique_ptr<Expr> &get_index_expr () { return index_expr; }
+ Expr &get_array_expr () { return *array_expr; }
+ Expr &get_index_expr () { return *index_expr; }
ExprType get_expression_type () const override final
{
@@ -1279,7 +1273,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_tuple_expr () { return tuple_expr; }
+ Expr &get_tuple_expr () { return *tuple_expr; }
ExprType get_expression_type () const override final
{
@@ -1524,7 +1518,7 @@ protected:
public:
std::string as_string () const override;
- std::unique_ptr<Expr> &get_value () { return value; }
+ Expr &get_value () { return *value; }
};
// Identifier and value variant of StructExprField HIR node
@@ -1797,7 +1791,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_fnexpr () { return function; }
+ bool has_fnexpr () const { return function != nullptr; }
+ Expr &get_fnexpr () { return *function; }
size_t num_params () const { return params.size (); }
@@ -1884,7 +1879,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_receiver () { return receiver; }
+ Expr &get_receiver () { return *receiver; }
PathExprSegment &get_method_name () { return method_name; };
const PathExprSegment &get_method_name () const { return method_name; };
@@ -1968,7 +1963,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_receiver_expr () { return receiver; }
+ Expr &get_receiver_expr () { return *receiver; }
Identifier get_field_name () const { return field; }
@@ -2058,9 +2053,9 @@ public:
}
std::vector<AST::Attribute> &get_outer_attrs () { return outer_attrs; }
- std::unique_ptr<Pattern> &get_pattern () { return pattern; }
+ Pattern &get_pattern () { return *pattern; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
location_t get_locus () const { return locus; }
};
@@ -2128,8 +2123,8 @@ public:
bool has_return_type () const { return return_type != nullptr; }
- std::unique_ptr<Type> &get_return_type () { return return_type; };
- std::unique_ptr<Expr> &get_expr () { return expr; }
+ Type &get_return_type () { return *return_type; };
+ Expr &get_expr () { return *expr; }
bool has_params () const { return !params.empty (); }
std::vector<ClosureParam> &get_params () { return params; }
@@ -2243,7 +2238,7 @@ public:
bool is_final_stmt (Stmt *stmt) { return statements.back ().get () == stmt; }
- std::unique_ptr<Expr> &get_final_expr () { return expr; }
+ Expr &get_final_expr () { return *expr; }
std::vector<std::unique_ptr<Stmt> > &get_statements () { return statements; }
@@ -2388,7 +2383,7 @@ public:
Lifetime &get_label () { return label; }
- std::unique_ptr<Expr> &get_expr () { return break_expr; }
+ Expr &get_expr () { return *break_expr; }
ExprType get_expression_type () const override final
{
@@ -2468,8 +2463,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_from_expr () { return from; }
- std::unique_ptr<Expr> &get_to_expr () { return to; }
+ Expr &get_from_expr () { return *from; }
+ Expr &get_to_expr () { return *to; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -2522,7 +2517,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_from_expr () { return from; }
+ Expr &get_from_expr () { return *from; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -2576,7 +2571,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_to_expr () { return to; }
+ Expr &get_to_expr () { return *to; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -2666,8 +2661,8 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_from_expr () { return from; }
- std::unique_ptr<Expr> &get_to_expr () { return to; }
+ Expr &get_from_expr () { return *from; }
+ Expr &get_to_expr () { return *to; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -2721,7 +2716,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_to_expr () { return to; };
+ Expr &get_to_expr () { return *to; };
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -2790,7 +2785,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_expr () { return return_expr; }
+ Expr &get_expr () { return *return_expr; }
ExprType get_expression_type () const override final
{
@@ -2856,7 +2851,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<BlockExpr> &get_block_expr () { return expr; }
+ BlockExpr &get_block_expr () { return *expr; }
ExprType get_expression_type () const override final
{
@@ -2932,7 +2927,7 @@ public:
location_t get_locus () const override final { return locus; }
- std::unique_ptr<HIR::BlockExpr> &get_loop_block () { return loop_block; };
+ HIR::BlockExpr &get_loop_block () { return *loop_block; };
LoopLabel &get_loop_label () { return loop_label; }
};
@@ -3010,7 +3005,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_predicate_expr () { return condition; }
+ Expr &get_predicate_expr () { return *condition; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -3086,7 +3081,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_cond () { return condition; }
+ Expr &get_cond () { return *condition; }
std::vector<std::unique_ptr<Pattern> > &get_patterns ()
{
return match_arm_patterns;
@@ -3166,8 +3161,8 @@ public:
void vis_if_condition (HIRFullVisitor &vis) { condition->accept_vis (vis); }
void vis_if_block (HIRFullVisitor &vis) { if_block->accept_vis (vis); }
- std::unique_ptr<Expr> &get_if_condition () { return condition; }
- std::unique_ptr<BlockExpr> &get_if_block () { return if_block; }
+ Expr &get_if_condition () { return *condition; }
+ BlockExpr &get_if_block () { return *if_block; }
ExprType get_expression_type () const final override { return ExprType::If; }
@@ -3230,7 +3225,7 @@ public:
void vis_else_block (HIRFullVisitor &vis) { else_block->accept_vis (vis); }
- std::unique_ptr<ExprWithBlock> &get_else_block () { return else_block; }
+ ExprWithBlock &get_else_block () { return *else_block; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -3330,7 +3325,7 @@ public:
return match_arm_patterns;
}
- std::unique_ptr<Expr> &get_guard_expr () { return guard_expr; }
+ Expr &get_guard_expr () { return *guard_expr; }
location_t get_locus () const { return locus; }
};
@@ -3374,7 +3369,7 @@ public:
Analysis::NodeMapping get_mappings () const { return mappings; }
MatchArm &get_arm () { return arm; }
- std::unique_ptr<Expr> &get_expr () { return expr; }
+ Expr &get_expr () { return *expr; }
};
// Match expression HIR node
@@ -3435,7 +3430,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_scrutinee_expr () { return branch_value; }
+ Expr &get_scrutinee_expr () { return *branch_value; }
AST::AttrVec get_inner_attrs () const { return inner_attrs; }
const std::vector<MatchCase> &get_match_cases () const { return match_arms; }
std::vector<MatchCase> &get_match_cases () { return match_arms; }
@@ -3499,7 +3494,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
- std::unique_ptr<Expr> &get_awaited_expr () { return awaited_expr; }
+ Expr &get_awaited_expr () { return *awaited_expr; }
ExprType get_expression_type () const final override
{
@@ -3556,7 +3551,7 @@ public:
location_t get_locus () const override final { return locus; }
bool get_has_move () const { return has_move; }
- std::unique_ptr<BlockExpr> &get_block_expr () { return block_expr; }
+ BlockExpr &get_block_expr () { return *block_expr; }
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
@@ -3581,31 +3576,31 @@ class OperatorExprMeta
public:
OperatorExprMeta (HIR::CompoundAssignmentExpr &expr)
: node_mappings (expr.get_mappings ()),
- lvalue_mappings (expr.get_expr ()->get_mappings ()),
+ lvalue_mappings (expr.get_expr ().get_mappings ()),
locus (expr.get_locus ())
{}
OperatorExprMeta (HIR::ArithmeticOrLogicalExpr &expr)
: node_mappings (expr.get_mappings ()),
- lvalue_mappings (expr.get_expr ()->get_mappings ()),
+ lvalue_mappings (expr.get_expr ().get_mappings ()),
locus (expr.get_locus ())
{}
OperatorExprMeta (HIR::NegationExpr &expr)
: node_mappings (expr.get_mappings ()),
- lvalue_mappings (expr.get_expr ()->get_mappings ()),
+ lvalue_mappings (expr.get_expr ().get_mappings ()),
locus (expr.get_locus ())
{}
OperatorExprMeta (HIR::DereferenceExpr &expr)
: node_mappings (expr.get_mappings ()),
- lvalue_mappings (expr.get_expr ()->get_mappings ()),
+ lvalue_mappings (expr.get_expr ().get_mappings ()),
locus (expr.get_locus ())
{}
OperatorExprMeta (HIR::ArrayIndexExpr &expr)
: node_mappings (expr.get_mappings ()),
- lvalue_mappings (expr.get_array_expr ()->get_mappings ()),
+ lvalue_mappings (expr.get_array_expr ().get_mappings ()),
locus (expr.get_locus ())
{}
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index 86fdabd..ba554d5 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -118,7 +118,7 @@ public:
Identifier get_type_representation () const { return type_representation; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
Analysis::NodeMapping get_type_mappings () const
{
@@ -277,7 +277,7 @@ public:
std::vector<LifetimeParam> &get_for_lifetimes () { return for_lifetimes; }
- std::unique_ptr<Type> &get_bound_type () { return bound_type; }
+ Type &get_bound_type () { return *bound_type; }
std::vector<std::unique_ptr<TypeParamBound>> &get_type_param_bounds ()
{
@@ -452,7 +452,7 @@ public:
ImplicitSelfKind get_self_kind () const { return self_kind; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
Analysis::NodeMapping get_mappings () { return mappings; }
@@ -547,9 +547,11 @@ public:
location_t get_locus () const { return locus; }
- std::unique_ptr<Pattern> &get_param_name () { return param_name; }
+ Pattern &get_param_name () { return *param_name; }
- std::unique_ptr<Type> &get_type () { return type; }
+ std::unique_ptr<Pattern> take_param_name () { return std::move (param_name); }
+
+ Type &get_type () { return *type; }
const Analysis::NodeMapping &get_mappings () const { return mappings; }
};
@@ -1056,7 +1058,7 @@ public:
location_t get_locus () const override final { return locus; }
ItemKind get_item_kind () const override { return ItemKind::UseDeclaration; }
- std::unique_ptr<UseTree> &get_use_tree () { return use_tree; }
+ UseTree &get_use_tree () { return *use_tree; }
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRStmtVisitor &vis) override;
void accept_vis (HIRVisItemVisitor &vis) override;
@@ -1210,7 +1212,7 @@ public:
}
// TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<BlockExpr> &get_definition () { return function_body; }
+ BlockExpr &get_definition () { return *function_body; }
const FunctionQualifiers &get_qualifiers () const { return qualifiers; }
@@ -1222,7 +1224,7 @@ public:
bool has_return_type () const { return return_type != nullptr; }
// TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<Type> &get_return_type () { return return_type; }
+ Type &get_return_type () { return *return_type; }
bool is_method () const { return !self.is_error (); }
@@ -1337,7 +1339,7 @@ public:
WhereClause &get_where_clause () { return where_clause; }
- std::unique_ptr<Type> &get_type_aliased () { return existing_type; }
+ Type &get_type_aliased () { return *existing_type; }
Identifier get_new_type_name () const { return new_type_name; }
@@ -1503,7 +1505,7 @@ public:
Identifier get_field_name () const { return field_name; }
- std::unique_ptr<Type> &get_field_type () { return field_type; }
+ Type &get_field_type () { return *field_type; }
Analysis::NodeMapping get_mappings () const { return mappings; }
@@ -1640,7 +1642,7 @@ public:
location_t get_locus () const { return locus; }
AST::AttrVec &get_outer_attrs () { return outer_attrs; }
- std::unique_ptr<HIR::Type> &get_field_type () { return field_type; }
+ HIR::Type &get_field_type () { return *field_type; }
};
// Rust tuple declared using struct keyword HIR node
@@ -1855,7 +1857,12 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRStmtVisitor &vis) override;
- std::unique_ptr<Expr> &get_discriminant_expression () { return expression; }
+ Expr &get_discriminant_expression () { return *expression; }
+
+ std::unique_ptr<Expr> take_discriminant_expression ()
+ {
+ return std::move (expression);
+ }
protected:
// Clone function implementation as (not pure) virtual method
@@ -2126,9 +2133,9 @@ public:
void accept_vis (HIRImplVisitor &vis) override;
void accept_vis (HIRVisItemVisitor &vis) override;
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
- std::unique_ptr<Expr> &get_expr () { return const_expr; }
+ Expr &get_expr () { return *const_expr; }
Identifier get_identifier () const { return identifier; }
@@ -2222,9 +2229,9 @@ public:
bool is_mut () const { return mut == Mutability::Mut; }
- std::unique_ptr<Expr> &get_expr () { return expr; }
+ Expr &get_expr () { return *expr; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
ItemKind get_item_kind () const override { return ItemKind::Static; }
@@ -2324,7 +2331,7 @@ public:
return generic_params;
}
- std::unique_ptr<Type> &get_return_type () { return return_type; }
+ Type &get_return_type () { return *return_type; }
std::vector<FunctionParam> &get_function_params () { return function_params; }
@@ -2391,7 +2398,7 @@ public:
bool has_block_defined () const { return block_expr != nullptr; }
- std::unique_ptr<BlockExpr> &get_block_expr () { return block_expr; }
+ BlockExpr &get_block_expr () { return *block_expr; }
const std::string trait_identifier () const override final
{
@@ -2476,9 +2483,9 @@ public:
bool has_expr () const { return expr != nullptr; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
- std::unique_ptr<Expr> &get_expr () { return expr; }
+ Expr &get_expr () { return *expr; }
const std::string trait_identifier () const override final
{
@@ -2828,7 +2835,9 @@ public:
location_t get_locus () const override final { return locus; }
- std::unique_ptr<Type> &get_type () { return impl_type; };
+ Type &get_type () { return *impl_type; };
+
+ bool has_type () { return impl_type == nullptr; }
std::vector<std::unique_ptr<GenericParam>> &get_generic_params ()
{
@@ -2837,7 +2846,7 @@ public:
bool has_trait_ref () const { return trait_ref != nullptr; }
- std::unique_ptr<TypePath> &get_trait_ref () { return trait_ref; }
+ TypePath &get_trait_ref () { return *trait_ref; }
WhereClause &get_where_clause () { return where_clause; }
@@ -2976,7 +2985,7 @@ public:
Mutability get_mut () { return mut; }
- std::unique_ptr<Type> &get_item_type () { return item_type; }
+ Type &get_item_type () { return *item_type; }
ExternKind get_extern_kind () override { return ExternKind::Static; }
@@ -3033,7 +3042,7 @@ public:
Identifier get_param_name () const { return name; }
- std::unique_ptr<Type> &get_type () { return param_type; }
+ Type &get_type () { return *param_type; }
Analysis::NodeMapping get_mappings () const { return mappings; }
};
@@ -3132,7 +3141,7 @@ public:
return generic_params;
}
- std::unique_ptr<Type> &get_return_type () { return return_type; }
+ Type &get_return_type () { return *return_type; }
std::vector<NamedFunctionParam> &get_function_params ()
{
diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h
index 0566e2e..b561c30 100644
--- a/gcc/rust/hir/tree/rust-hir-path.h
+++ b/gcc/rust/hir/tree/rust-hir-path.h
@@ -107,8 +107,8 @@ public:
Identifier &get_identifier () { return identifier; }
const Identifier &get_identifier () const { return identifier; }
- std::unique_ptr<Type> &get_type () { return type; }
- const std::unique_ptr<Type> &get_type () const { return type; }
+ Type &get_type () { return *type; }
+ const Type &get_type () const { return *type; }
location_t get_locus () const { return locus; }
};
@@ -574,7 +574,7 @@ public:
TypePathFunction (TypePathFunction const &other)
{
return_type = other.has_return_type ()
- ? other.get_return_type ()->clone_type ()
+ ? other.get_return_type ().clone_type ()
: nullptr;
inputs.reserve (other.inputs.size ());
@@ -588,7 +588,7 @@ public:
TypePathFunction &operator= (TypePathFunction const &other)
{
return_type = other.has_return_type ()
- ? other.get_return_type ()->clone_type ()
+ ? other.get_return_type ().clone_type ()
: nullptr;
inputs.reserve (other.inputs.size ());
@@ -610,8 +610,8 @@ public:
};
std::vector<std::unique_ptr<Type> > &get_params () { return inputs; };
- const std::unique_ptr<Type> &get_return_type () const { return return_type; };
- std::unique_ptr<Type> &get_return_type () { return return_type; };
+ const Type &get_return_type () const { return *return_type; };
+ Type &get_return_type () { return *return_type; };
};
// Segment used in type path with a function argument
@@ -811,9 +811,9 @@ public:
Analysis::NodeMapping get_mappings () const { return mappings; }
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
- std::unique_ptr<TypePath> &get_trait () { return trait; }
+ TypePath &get_trait () { return *trait; }
bool trait_has_generic_args () const
{
@@ -963,10 +963,7 @@ public:
QualifiedPathType &get_path_type () { return path_type; }
- std::unique_ptr<TypePathSegment> &get_associated_segment ()
- {
- return associated_segment;
- }
+ TypePathSegment &get_associated_segment () { return *associated_segment; }
std::vector<std::unique_ptr<TypePathSegment> > &get_segments ()
{
diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h
index e65a62f..bedc6de 100644
--- a/gcc/rust/hir/tree/rust-hir-pattern.h
+++ b/gcc/rust/hir/tree/rust-hir-pattern.h
@@ -132,7 +132,7 @@ public:
bool is_mut () const { return mut == Mutability::Mut; }
bool get_is_ref () const { return is_ref; }
- std::unique_ptr<Pattern> &get_to_bind () { return to_bind; }
+ Pattern &get_to_bind () { return *to_bind; }
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
@@ -405,9 +405,9 @@ public:
return PatternType::RANGE;
}
- std::unique_ptr<RangePatternBound> &get_lower_bound () { return lower; }
+ RangePatternBound &get_lower_bound () { return *lower; }
- std::unique_ptr<RangePatternBound> &get_upper_bound () { return upper; }
+ RangePatternBound &get_upper_bound () { return *upper; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -476,7 +476,7 @@ public:
return PatternType::REFERENCE;
}
- std::unique_ptr<Pattern> &get_referenced_pattern () { return pattern; }
+ Pattern &get_referenced_pattern () { return *pattern; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -572,7 +572,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
TupleIndex get_index () { return index; }
- std::unique_ptr<Pattern> &get_tuple_pattern () { return tuple_pattern; }
+ Pattern &get_tuple_pattern () { return *tuple_pattern; }
ItemType get_item_type () const override final { return ItemType::TUPLE_PAT; }
@@ -630,7 +630,7 @@ public:
Identifier get_identifier () const { return ident; }
- std::unique_ptr<Pattern> &get_pattern () { return ident_pattern; }
+ Pattern &get_pattern () { return *ident_pattern; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -1002,7 +1002,7 @@ public:
PathInExpression &get_path () { return path; }
- std::unique_ptr<TupleStructItems> &get_items () { return items; }
+ TupleStructItems &get_items () { return *items; }
const Analysis::NodeMapping &get_mappings () const override final
{
@@ -1221,8 +1221,8 @@ public:
return PatternType::TUPLE;
}
- std::unique_ptr<TuplePatternItems> &get_items () { return items; }
- const std::unique_ptr<TuplePatternItems> &get_items () const { return items; }
+ TuplePatternItems &get_items () { return *items; }
+ const TuplePatternItems &get_items () const { return *items; }
protected:
/* Use covariance to implement clone function as returning this object rather
diff --git a/gcc/rust/hir/tree/rust-hir-stmt.h b/gcc/rust/hir/tree/rust-hir-stmt.h
index a51dab7..f637177 100644
--- a/gcc/rust/hir/tree/rust-hir-stmt.h
+++ b/gcc/rust/hir/tree/rust-hir-stmt.h
@@ -144,11 +144,11 @@ public:
}
std::vector<AST::Attribute> &get_outer_attrs () { return outer_attrs; }
- std::unique_ptr<HIR::Type> &get_type () { return type; }
+ HIR::Type &get_type () { return *type; }
- std::unique_ptr<HIR::Expr> &get_init_expr () { return init_expr; }
+ HIR::Expr &get_init_expr () { return *init_expr; }
- std::unique_ptr<HIR::Pattern> &get_pattern () { return variables_pattern; }
+ HIR::Pattern &get_pattern () { return *variables_pattern; }
bool is_item () const override final { return false; }
@@ -186,7 +186,7 @@ public:
bool is_item () const override final { return false; }
- std::unique_ptr<Expr> &get_expr () { return expr; }
+ Expr &get_expr () { return *expr; }
// Copy constructor with clone
ExprStmt (ExprStmt const &other)
diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h
index 8f068ef..a8ac4a1 100644
--- a/gcc/rust/hir/tree/rust-hir-type.h
+++ b/gcc/rust/hir/tree/rust-hir-type.h
@@ -271,7 +271,7 @@ public:
* parenthesised type, it must be in parentheses. */
return type_in_parens->to_trait_bound (true);
}
- std::unique_ptr<Type> &get_type_in_parens () { return type_in_parens; }
+ Type &get_type_in_parens () { return *type_in_parens; }
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
};
@@ -439,7 +439,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- std::unique_ptr<Type> &get_type () { return type; }
+ Type &get_type () { return *type; }
Mutability get_mut () const { return mut; }
@@ -447,7 +447,7 @@ public:
bool is_const () const { return mut == Mutability::Imm; }
- std::unique_ptr<Type> &get_base_type () { return type; }
+ Type &get_base_type () { return *type; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -520,7 +520,7 @@ public:
Mutability get_mut () const { return mut; }
- std::unique_ptr<Type> &get_base_type () { return type; }
+ Type &get_base_type () { return *type; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -578,9 +578,9 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- std::unique_ptr<Type> &get_element_type () { return elem_type; }
+ Type &get_element_type () { return *elem_type; }
- std::unique_ptr<Expr> &get_size_expr () { return size; }
+ Expr &get_size_expr () { return *size; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -633,7 +633,7 @@ public:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRTypeVisitor &vis) override;
- std::unique_ptr<Type> &get_element_type () { return elem_type; }
+ Type &get_element_type () { return *elem_type; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -743,7 +743,7 @@ public:
location_t get_locus () const { return locus; }
- std::unique_ptr<Type> &get_type () { return param_type; }
+ Type &get_type () { return *param_type; }
ParamKind get_param_kind () const { return param_kind; }
@@ -828,7 +828,7 @@ public:
}
// TODO: would a "vis_type" be better?
- std::unique_ptr<Type> &get_return_type () { return return_type; }
+ Type &get_return_type () { return *return_type; }
protected:
/* Use covariance to implement clone function as returning this object rather
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index 38d35ee..44dcc8e 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -765,11 +765,8 @@ public:
bool has_default_expression () { return default_expression != nullptr; }
std::string get_name () { return name; }
- std::unique_ptr<Type> &get_type () { return type; }
- std::unique_ptr<Expr> &get_default_expression ()
- {
- return default_expression;
- }
+ Type &get_type () { return *type; }
+ Expr &get_default_expression () { return *default_expression; }
protected:
/* Use covariance to implement clone function as returning this object rather