From 7609dfc63e021117c194544f83b2edce34a81520 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 12 Apr 2022 13:20:14 +0100 Subject: 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. --- gcc/rust/typecheck/rust-tyty-rules.h | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'gcc') 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; } -- cgit v1.1