]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add optional template arguments to please GCC4.8
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 20 Nov 2024 00:44:28 +0000 (01:44 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:32:58 +0000 (12:32 +0100)
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.patry@embecosm.com>
gcc/rust/hir/rust-ast-lower-expr.cc
gcc/rust/hir/rust-ast-lower-type.cc
gcc/rust/typecheck/rust-hir-type-check-type.cc

index 2954a31d9f447fc89840f86a59fdd570f4b21e3e..b45b5f925df79d7bee4bbf56766dff657a4ee6c8 100644 (file)
@@ -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 ();
index 5836c1ac1487b193495251b48b9b93bf49a6e743..58c93b9e25dd09e15c06ba93ca137794fc8db4fc 100644 (file)
@@ -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 (),
index 089a5af121a033d7ea59db746750339dd8048002..6e859e5d7196e6f87b105079f7df6d6d126332d9 100644 (file)
@@ -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 ())
                  {