aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-08-08 17:04:03 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-08-08 17:08:01 +0100
commite0a14f483979aea48f7588656b4269e1b9dbee34 (patch)
tree2ee0b9bb4e3f5d6d431740c5fb61936ed197828d /gcc
parent8749b66879f3ef78182d7712e5da981cc55f747a (diff)
downloadgcc-e0a14f483979aea48f7588656b4269e1b9dbee34.zip
gcc-e0a14f483979aea48f7588656b4269e1b9dbee34.tar.gz
gcc-e0a14f483979aea48f7588656b4269e1b9dbee34.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty-coercion.h24
-rw-r--r--gcc/rust/typecheck/rust-tyty-rules.h12
2 files changed, 36 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-coercion.h b/gcc/rust/typecheck/rust-tyty-coercion.h
index c862de5..34267b3 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 1dd0112..ad2d4b7 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; }