]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: AST: Fix for lifetime lowering
authorJakub Dupak <dev@jakubdupak.com>
Tue, 9 Jan 2024 14:46:41 +0000 (15:46 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:52 +0000 (12:36 +0100)
gcc/rust/ChangeLog:

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

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/hir/rust-ast-lower-type.cc

index a0178ebf490ef38f9c7be5d232165c82dc3a38ae..504ca051f59a429a6d0d1142e048a427a343ae2b 100644 (file)
@@ -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);
@@ -543,8 +548,9 @@ ASTLoweringTypeBounds::visit (AST::TraitBound &bound)
   BoundPolarity polarity = bound.has_opening_question_mark ()
                             ? BoundPolarity::AntiBound
                             : BoundPolarity::RegularBound;
-  translated = new HIR::TraitBound (mapping, *trait_path, bound.get_locus (),
-                                   bound.is_in_parens (), polarity);
+  translated
+    = new HIR::TraitBound (mapping, *trait_path, bound.get_locus (),
+                          bound.is_in_parens (), polarity, for_lifetimes);
 }
 
 void
@@ -596,6 +602,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 ()));