https://gcc.gnu.org/g:15b928c77f4656394d1d519f3d31bb936ee84fec
commit 15b928c77f4656394d1d519f3d31bb936ee84fec Author: Arthur Cohen <arthur.co...@embecosm.com> Date: Thu Jan 2 10:41:44 2025 +0000 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 83532f842b84..1b229ce258aa 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) {