aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-02 10:41:44 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-16 14:00:31 +0000
commit15b928c77f4656394d1d519f3d31bb936ee84fec (patch)
tree33453adccfe3db628ab38b59c0504993654a98a7
parente7011f62930b662426ceb53a4cc40a64268163b4 (diff)
downloadgcc-15b928c77f4656394d1d519f3d31bb936ee84fec.zip
gcc-15b928c77f4656394d1d519f3d31bb936ee84fec.tar.gz
gcc-15b928c77f4656394d1d519f3d31bb936ee84fec.tar.bz2
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.
-rw-r--r--gcc/rust/hir/rust-ast-lower-type.cc40
1 files 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 83532f8..1b229ce 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)
{