https://gcc.gnu.org/g:1d628b8920ebf3d2c4244b02ab91297b5a0151dd

commit r15-8534-g1d628b8920ebf3d2c4244b02ab91297b5a0151dd
Author: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>
Date:   Wed Nov 20 01:44:28 2024 +0100

    gccrs: Add optional template arguments to please GCC4.8
    
    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>

Diff:
---
 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 2954a31d9f44..b45b5f925df7 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 5836c1ac1487..58c93b9e25dd 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 &param)
        }
     }
 
-  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 089a5af121a0..6e859e5d7196 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 &param)
                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 ())
                  {

Reply via email to