aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-04-12 13:20:14 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-04-12 13:49:30 +0100
commit7609dfc63e021117c194544f83b2edce34a81520 (patch)
tree7721c333d9f3ad0e5b35b7b03726b109a54a70f2 /gcc
parenta5b38698aa439a935f0c0f4c55611f2173a28b57 (diff)
downloadgcc-7609dfc63e021117c194544f83b2edce34a81520.zip
gcc-7609dfc63e021117c194544f83b2edce34a81520.tar.gz
gcc-7609dfc63e021117c194544f83b2edce34a81520.tar.bz2
Add missing unify rules for inference variables
Inference variables can unify with anything so this includes these covariant types like references/slices etc. This patch is needed for more complex type-checking in libcore and generics.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty-rules.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h
index 7c50112..f95e7bf 100644
--- a/gcc/rust/typecheck/rust-tyty-rules.h
+++ b/gcc/rust/typecheck/rust-tyty-rules.h
@@ -867,6 +867,18 @@ public:
TyVar (base_resolved->get_ref ()));
}
+ 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; }
@@ -896,6 +908,18 @@ public:
TyVar (base_resolved->get_ref ()));
}
+ 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; }
@@ -1140,6 +1164,18 @@ public:
type.get_ident ().locus, fields);
}
+ 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; }
@@ -1263,6 +1299,18 @@ public:
base->mutability ());
}
+ 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; }
@@ -1303,6 +1351,18 @@ public:
base->mutability ());
}
+ 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; }