From: Arthur Cohen <arthur.co...@embecosm.com>

gcc/rust/ChangeLog:

        * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Adapt code to 
lang item
        type path segments.
---
 gcc/rust/hir/rust-ast-lower-type.cc | 40 ++++++++++-------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/gcc/rust/hir/rust-ast-lower-type.cc 
b/gcc/rust/hir/rust-ast-lower-type.cc
index e78c1307523..8df418b272d 100644
--- a/gcc/rust/hir/rust-ast-lower-type.cc
+++ b/gcc/rust/hir/rust-ast-lower-type.cc
@@ -74,11 +74,20 @@ ASTLowerTypePath::visit (AST::TypePathSegment &segment)
   Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid,
                                 UNKNOWN_LOCAL_DEFID);
 
-  HIR::PathIdentSegment ident (segment.get_ident_segment ().as_string ());
-  translated_segment
-    = new HIR::TypePathSegment (std::move (mapping), ident,
-                               segment.get_separating_scope_resolution (),
-                               segment.get_locus ());
+  if (segment.is_lang_item ())
+    {
+      translated_segment = new HIR::TypePathSegment (std::move (mapping),
+                                                    segment.get_lang_item (),
+                                                    segment.get_locus ());
+    }
+  else
+    {
+      HIR::PathIdentSegment ident (segment.get_ident_segment ().as_string ());
+      translated_segment
+       = new HIR::TypePathSegment (std::move (mapping), ident,
+                                   segment.get_separating_scope_resolution (),
+                                   segment.get_locus ());
+    }
 }
 
 void
@@ -139,27 +148,6 @@ ASTLowerTypePath::visit (AST::TypePath &path)
                         path.has_opening_scope_resolution_op ());
 }
 
-// void
-// ASTLowerTypePath::visit (AST::LangItemPath &path)
-// {
-//   auto crate_num = mappings.get_current_crate ();
-//   auto hirid = mappings.get_next_hir_id (crate_num);
-
-//   Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid,
-//                              mappings.get_next_localdef_id (crate_num));
-
-//   std::vector<std::unique_ptr<HIR::TypePathSegment>> translated_segments;
-//   translated_segments.emplace_back (std::unique_ptr<HIR::TypePathSegment> (
-//     new HIR::TypePathSegment (mapping,
-//                           LangItem::ToString (path.get_lang_item_kind ()),
-//                           false, path.get_locus ())));
-
-//   translated
-//     = new HIR::TypePath (std::move (mapping), std::move
-//     (translated_segments),
-//                      path.get_locus ());
-// }
-
 HIR::QualifiedPathInType *
 ASTLowerQualifiedPathInType::translate (AST::QualifiedPathInType &type)
 {
-- 
2.45.2

Reply via email to