]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
gccrs: Fix ICE in ADTType::is_concrete
authorPhilip Herron <herron.philip@googlemail.com>
Sun, 26 Feb 2023 22:36:20 +0000 (22:36 +0000)
committerPhilip Herron <philip.herron@embecosm.com>
Tue, 28 Feb 2023 20:38:35 +0000 (20:38 +0000)
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (ADTType::is_concrete):  need to consider if is a num_variant
* typecheck/rust-tyty.h: refactor to cc file

gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h

index d0d36ac0a11d4847681955ad4f5171002ce72c1b..28d03ce52c5ad576e77a873edd271e894dad8950 100644 (file)
@@ -1110,6 +1110,30 @@ ADTType::as_string () const
   return identifier + subst_as_string () + "{" + variants_buffer + "}";
 }
 
+bool
+ADTType::is_concrete () const
+{
+  if (is_unit ())
+    {
+      return !needs_substitution ();
+    }
+
+  for (auto &variant : variants)
+    {
+      bool is_num_variant
+       = variant->get_variant_type () == VariantDef::VariantType::NUM;
+      if (is_num_variant)
+       continue;
+
+      for (auto &field : variant->get_fields ())
+       {
+         if (!field->is_concrete ())
+           return false;
+       }
+    }
+  return true;
+}
+
 bool
 ADTType::can_eq (const BaseType *other, bool emit_errors) const
 {
index 64b9379a1c07b95392ee708a5f2f1f8d26e4840b..05cd3a78dd8ac516a49279e7a4fb16a63ab1ba7d 100644 (file)
@@ -604,23 +604,7 @@ public:
     return identifier + subst_as_string ();
   }
 
-  bool is_concrete () const override final
-  {
-    if (is_unit ())
-      {
-       return !needs_substitution ();
-      }
-
-    for (auto &variant : variants)
-      {
-       for (auto &field : variant->get_fields ())
-         {
-           if (!field->is_concrete ())
-             return false;
-         }
-      }
-    return true;
-  }
+  bool is_concrete () const override final;
 
   BaseType *clone () const final override;
   BaseType *monomorphized_clone () const final override;