]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Ensure we track the const generic substitution on the param mappings
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 1 Aug 2025 10:52:16 +0000 (11:52 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:37:02 +0000 (16:37 +0200)
gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.cc: track the const generic
* typecheck/rust-tyty.cc (ConstType::is_equal): finish the is_equal

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-tyty-subst.cc
gcc/rust/typecheck/rust-tyty.cc

index 45c8cd638eb4dad67c1b2926ff78ea79037889fc..64791097b18d8b8c257e6e72c9a9d7a85b00c2f1 100644 (file)
@@ -163,8 +163,11 @@ SubstitutionParamMapping::fill_param_ty (
 
   if (type.get_kind () == TypeKind::PARAM)
     {
-      // delete param;
-      param = static_cast<ParamType *> (type.clone ());
+      param = static_cast<BaseGeneric *> (type.clone ());
+    }
+  else if (type.get_kind () == TyTy::TypeKind::CONST)
+    {
+      param = static_cast<BaseGeneric *> (type.clone ());
     }
   else if (param->get_kind () == TypeKind::PARAM)
     {
index c5488fca500ee2d5646c4122ba1ebb9846ebb660..d25f524a6cc9e3eccf683e8f524519f38310dab4 100644 (file)
@@ -37,6 +37,7 @@
 #include "options.h"
 #include "rust-system.h"
 #include "tree.h"
+#include "fold-const.h"
 #include <string>
 
 namespace Rust {
@@ -3712,9 +3713,14 @@ ConstType::is_equal (const BaseType &other) const
       return false;
     }
 
-  // TODO
+  const ConstType &rhs = static_cast<const ConstType &> (other);
+  if (!get_ty ()->is_equal (*rhs.get_ty ()))
+    return false;
 
-  return false;
+  tree lv = get_value ();
+  tree rv = rhs.get_value ();
+
+  return operand_equal_p (lv, rv, 0);
 }
 
 ConstType *