Skip to content

Commit

Permalink
AST: Fix for lifetime lowering
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-type.cc (ASTLoweringTypeBounds::visit): fix for lifetimes
	(ASTLowerWhereClauseItem::visit): fix for lifetimes

Signed-off-by: Jakub Dupak <[email protected]>
  • Loading branch information
jdupak committed Jan 9, 2024
1 parent caa43fc commit b267299
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions gcc/rust/hir/rust-ast-lower-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,13 @@ ASTLoweringTypeBounds::translate (AST::TypeParamBound *type)
void
ASTLoweringTypeBounds::visit (AST::TraitBound &bound)
{
// FIXME
std::vector<HIR::LifetimeParam> lifetimes;
std::vector<HIR::LifetimeParam> for_lifetimes;
for (auto &lifetime_param : bound.get_for_lifetimes ())
{
auto generic_param = ASTLowerGenericParam::translate (&lifetime_param);
for_lifetimes.push_back (
*static_cast<HIR::LifetimeParam *> (generic_param));
}

AST::TypePath &ast_trait_path = bound.get_type_path ();
HIR::TypePath *trait_path = ASTLowerTypePath::translate (ast_trait_path);
Expand All @@ -544,7 +549,7 @@ ASTLoweringTypeBounds::visit (AST::TraitBound &bound)
? BoundPolarity::AntiBound
: BoundPolarity::RegularBound;
translated = new HIR::TraitBound (mapping, *trait_path, bound.get_locus (),
bound.is_in_parens (), polarity);
bound.is_in_parens (), polarity, for_lifetimes);
}

void
Expand Down Expand Up @@ -596,6 +601,13 @@ ASTLowerWhereClauseItem::visit (AST::TypeBoundWhereClauseItem &item)
// FIXME
std::vector<HIR::LifetimeParam> for_lifetimes;

for (auto &lifetime_param : item.get_for_lifetimes ())
{
auto generic_param = ASTLowerGenericParam::translate (&lifetime_param);
for_lifetimes.push_back (
*static_cast<HIR::LifetimeParam *> (generic_param));
}

std::unique_ptr<HIR::Type> bound_type = std::unique_ptr<HIR::Type> (
ASTLoweringType::translate (item.get_type ().get ()));

Expand Down

0 comments on commit b267299

Please sign in to comment.