[COMMITTED 37/83] gccrs: Fix self referencial assocated type

arthur.cohen@opensrcsec.com arthur.cohen@opensrcsec.com
Wed Sep 16 12:29:56 GMT 2026


From: Philip Herron <herron.philip@googlemail.com>

Fixes Rust-GCC/gccrs#4821

gcc/rust/ChangeLog:

	* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): can be recusive

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
---
 gcc/rust/typecheck/rust-hir-trait-resolve.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
index 5be1989c55a..502d0e8f7d8 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -490,6 +490,8 @@ TraitItemReference::resolve_item (const TraitReference *tref,
 				TyTy::SubstitutionArgumentMappings::error (),
 				{}, {}, inherited_count);
 
+  context->insert_type (type.get_mappings (), projection);
+
   // Attach the bounds declared on the associated type itself:
   //
   //     type IntoIter: Iterator<Item = Self::Item>
@@ -514,8 +516,6 @@ TraitItemReference::resolve_item (const TraitReference *tref,
       if (!trait_item_bounds.empty ())
 	projection->inherit_bounds (trait_item_bounds);
     }
-
-  context->insert_type (type.get_mappings (), projection);
 }
 
 void
-- 
2.50.1



More information about the Gcc-rust mailing list