From 9614958e6e20a40af9698c2305b7c5ed378f44a8 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 20 Nov 2024 01:44:28 +0100 Subject: [PATCH] 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 --- 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 fb24a72efa70..a8c07303bd1c 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 ( - std::unique_ptr (translated_base))); + base = tl::optional> ( + Rust::make_unique ( + std::unique_ptr (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 c1bfe213aa17..553c9c9612da 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 ( - ASTLoweringType::translate (param.get_type ()))) - : tl::nullopt; + tl::optional> type = tl::nullopt; + if (param.has_type ()) + type + = tl::optional> (std::unique_ptr ( + 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 099a08910e8d..e0b70976a617 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 (*bound); TyTy::TypeBoundPredicate predicate = get_predicate_from_bound ( - b.get_path (), tl::optional (std::ref (*implicit_self_bound)), + b.get_path (), + tl::optional> ( + std::ref (*implicit_self_bound)), b.get_polarity ()); if (!predicate.is_error ()) {