From: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> Clang on macos as well as GCC 4.8 complains when those templates are missing.
gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Add template to tl::optional. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> --- gcc/rust/hir/rust-ast-lower-expr.cc | 5 +++-- gcc/rust/hir/rust-ast-lower-type.cc | 8 +++++--- gcc/rust/typecheck/rust-hir-type-check-type.cc | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index 2954a31d9f4..b45b5f925df 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -517,8 +517,9 @@ ASTLoweringExpr::visit (AST::StructExprStructFields &struct_expr) { HIR::Expr *translated_base = ASTLoweringExpr::translate ( struct_expr.get_struct_base ().get_base_struct ()); - base = tl::optional (Rust::make_unique<StructBase> ( - std::unique_ptr<HIR::Expr> (translated_base))); + base = tl::optional<std::unique_ptr<HIR::StructBase>> ( + Rust::make_unique<StructBase> ( + std::unique_ptr<HIR::Expr> (translated_base))); } auto const &in_fields = struct_expr.get_fields (); diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc index 5836c1ac148..58c93b9e25d 100644 --- a/gcc/rust/hir/rust-ast-lower-type.cc +++ b/gcc/rust/hir/rust-ast-lower-type.cc @@ -503,9 +503,11 @@ ASTLowerGenericParam::visit (AST::TypeParam ¶m) } } - auto type = param.has_type () ? tl::optional (std::unique_ptr<HIR::Type> ( - ASTLoweringType::translate (param.get_type ()))) - : tl::nullopt; + tl::optional<std::unique_ptr<HIR::Type>> type = tl::nullopt; + if (param.has_type ()) + type + = tl::optional<std::unique_ptr<HIR::Type>> (std::unique_ptr<HIR::Type> ( + ASTLoweringType::translate (param.get_type ()))); auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 089a5af121a..6e859e5d719 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -829,7 +829,9 @@ TypeResolveGenericParam::visit (HIR::TypeParam ¶m) HIR::TraitBound &b = static_cast<HIR::TraitBound &> (*bound); TyTy::TypeBoundPredicate predicate = get_predicate_from_bound ( - b.get_path (), tl::optional (std::ref (*implicit_self_bound)), + b.get_path (), + tl::optional<std::reference_wrapper<HIR::Type>> ( + std::ref (*implicit_self_bound)), b.get_polarity ()); if (!predicate.is_error ()) { -- 2.45.2