https://gcc.gnu.org/g:4fec26e049607b7bd78134c7ef20126d355f1576

commit r17-4319-g4fec26e049607b7bd78134c7ef20126d355f1576
Author: Philip Herron <[email protected]>
Date:   Mon Aug 31 22:31:38 2026 +0100

    gccrs: Add missing handling to variance analysis
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-tyty-variance-analysis.cc 
(GenericTyVisitorCtx::lookup_or_add_type):
            handle the other tyty types
    
    Signed-off-by: Philip Herron <[email protected]>

Diff:
---
 gcc/rust/typecheck/rust-tyty-variance-analysis.cc | 24 ++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc 
b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
index ca8e9f6b1a82..6c6877ef9ecb 100644
--- a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
+++ b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
@@ -366,15 +366,29 @@ GenericTyVisitorCtx::lookup_or_add_type (HirId hir_id)
     }
 
   SubstitutionRef *subst = nullptr;
-  if (auto adt = ty->try_as<ADTType> ())
-    {
-      subst = adt;
-    }
-  else
+  switch (ty->get_kind ())
     {
+    case TypeKind::ADT:
+      subst = static_cast<ADTType *> (ty);
+      break;
+
+    case TypeKind::FNDEF:
+      subst = static_cast<FnType *> (ty);
+      break;
+
+    case TypeKind::CLOSURE:
+      subst = static_cast<ClosureType *> (ty);
+      break;
+
+    case TypeKind::PROJECTION:
+      subst = static_cast<ProjectionType *> (ty);
+      break;
+
+    default:
       rust_sorry_at (
        ty->get_locus (),
        "This is a compiler bug: Unhandled type in variance analysis");
+      break;
     }
   rust_assert (subst != nullptr);

Reply via email to