[gcc r17-2244] gccrs: fix ICE on generic type aliases

Arthur Cohen via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:55552cd4acbe884b6bf5e5783aa7a5a126a117a6

commit r17-2244-g55552cd4acbe884b6bf5e5783aa7a5a126a117a6
Author: Lucas Ly Ba <[email protected]>
Date:   Sat Jun 27 21:15:27 2026 +0200

    gccrs: fix ICE on generic type aliases
    
    A type alias with generic parameters never resolved those parameters
    into the type context, so the reachability pass asserted when looking
    up their types. Resolve the generic parameters, as the other items do.
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Resolve
            the generic parameters of a type alias.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/type-alias-generic-params.rs: New test.
    
    Signed-off-by: Lucas Ly Ba <[email protected]>

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-item.cc          | 7 +++++++
 gcc/testsuite/rust/compile/type-alias-generic-params.rs | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc
index d8f2b8754e89..8c8d7e416147 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc
@@ -228,6 +228,13 @@ TypeCheckItem::validate_trait_impl_block (
 void
 TypeCheckItem::visit (HIR::TypeAlias &alias)
 {
+  auto lifetime_pin = context->push_clean_lifetime_resolver ();
+
+  std::vector<TyTy::SubstitutionParamMapping> substitutions;
+  if (alias.has_generics ())
+    resolve_generic_params (HIR::Item::ItemKind::TypeAlias, alias.get_locus (),
+			    alias.get_generic_params (), substitutions);
+
   TyTy::BaseType *actual_type
     = TypeCheckType::Resolve (alias.get_type_aliased ());
 
diff --git a/gcc/testsuite/rust/compile/type-alias-generic-params.rs b/gcc/testsuite/rust/compile/type-alias-generic-params.rs
new file mode 100644
index 000000000000..8e0883fea6c6
--- /dev/null
+++ b/gcc/testsuite/rust/compile/type-alias-generic-params.rs
@@ -0,0 +1,9 @@
+// Generic type aliases used to ICE in the reachability pass because their
+// generic parameters were never resolved into the type context.
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+pub type Alias<T> = T;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.