From 01504790ad2694d546f7c400be8e9d9a3f78e18c Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 2 Jan 2025 10:41:44 +0000 Subject: [PATCH] gccrs: lower: Properly lower non-generic lang item type path segments. 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> translated_segments; -// translated_segments.emplace_back (std::unique_ptr ( -// 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.47.2