public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ADT's and tuples are valid to be unified with inference variables
@ 2022-08-09 20:39 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-08-09 20:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e0a14f483979aea48f7588656b4269e1b9dbee34

commit e0a14f483979aea48f7588656b4269e1b9dbee34
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Mon Aug 8 17:04:03 2022 +0100

    ADT's and tuples are valid to be unified with inference variables
    
    There is some dulication here which will eventually go away with the
    coercion site refactor which is still a WIP. Here we update the type rules
    so that we allow ADT's and tuples to unify and thus fulfill the type
    inference rules.
    
    Addresses #1447

Diff:
---
 gcc/rust/typecheck/rust-tyty-coercion.h | 24 ++++++++++++++++++++++++
 gcc/rust/typecheck/rust-tyty-rules.h    | 12 ++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/gcc/rust/typecheck/rust-tyty-coercion.h b/gcc/rust/typecheck/rust-tyty-coercion.h
index c862de5bc62..34267b30838 100644
--- a/gcc/rust/typecheck/rust-tyty-coercion.h
+++ b/gcc/rust/typecheck/rust-tyty-coercion.h
@@ -1133,6 +1133,18 @@ public:
     resolved = type.clone ();
   }
 
+  void visit (InferType &type) override
+  {
+    if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
+      {
+	BaseCoercionRules::visit (type);
+	return;
+      }
+
+    resolved = base->clone ();
+    resolved->set_ref (type.get_ref ());
+  }
+
 private:
   BaseType *get_base () override { return base; }
 
@@ -1172,6 +1184,18 @@ public:
 				    type.get_ident ().locus, fields);
   }
 
+  void visit (InferType &type) override
+  {
+    if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
+      {
+	BaseCoercionRules::visit (type);
+	return;
+      }
+
+    resolved = base->clone ();
+    resolved->set_ref (type.get_ref ());
+  }
+
 private:
   BaseType *get_base () override { return base; }
 
diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h
index 1dd011229c2..ad2d4b79b00 100644
--- a/gcc/rust/typecheck/rust-tyty-rules.h
+++ b/gcc/rust/typecheck/rust-tyty-rules.h
@@ -1131,6 +1131,18 @@ public:
     resolved = type.clone ();
   }
 
+  void visit (InferType &type) override
+  {
+    if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
+      {
+	BaseRules::visit (type);
+	return;
+      }
+
+    resolved = base->clone ();
+    resolved->set_ref (type.get_ref ());
+  }
+
 private:
   BaseType *get_base () override { return base; }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-09 20:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09 20:39 [gcc/devel/rust/master] ADT's and tuples are valid to be unified with inference variables Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).