[gcc r15-8621] gccrs: lower: Properly lower non-generic lang item type path segments.
Arthur Cohen
cohenarthur@gcc.gnu.org
Fri Mar 21 11:58:17 GMT 2025
https://gcc.gnu.org/g:01504790ad2694d546f7c400be8e9d9a3f78e18c
commit r15-8621-g01504790ad2694d546f7c400be8e9d9a3f78e18c
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Jan 2 10:41:44 2025 +0000
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.
Diff:
---
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 e78c1307523d..8df418b272d4 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)
{
More information about the Gcc-cvs
mailing list