Skip to content

Commit

Permalink
Add optional template arguments to please GCC4.8
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
P-E-P committed Nov 20, 2024
1 parent 8167c78 commit f5b47db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions gcc/rust/hir/rust-ast-lower-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
8 changes: 5 additions & 3 deletions gcc/rust/hir/rust-ast-lower-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 (),
Expand Down
4 changes: 3 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ())
{
Expand Down

0 comments on commit f5b47db

Please sign in to comment.