From da31b651da678fb8ed784191b9dc1ab3e75bd08e Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 3 Aug 2022 12:32:33 +0100 Subject: Update TyTy::can_eq interface for pointers and references It is valid for pointers and references to unify against inference variables. --- gcc/rust/typecheck/rust-tyty-cmp.h | 106 ++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h index f3118ba..07d1dea 100644 --- a/gcc/rust/typecheck/rust-tyty-cmp.h +++ b/gcc/rust/typecheck/rust-tyty-cmp.h @@ -36,12 +36,7 @@ public: if (other->get_kind () == TypeKind::PARAM) { const ParamType *p = static_cast (other); - if (p->can_resolve ()) - { - const BaseType *resolved = p->resolve (); - resolved->accept_vis (*this); - return ok; - } + other = p->resolve (); } if (other->get_kind () == TypeKind::PLACEHOLDER) { @@ -861,6 +856,17 @@ public: : BaseCmp (base, emit_errors), base (base) {} + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const ClosureType *base; @@ -889,6 +895,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const ArrayType *base; @@ -917,6 +934,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const SliceType *base; @@ -1074,6 +1102,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const ADTType *base; @@ -1111,6 +1150,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const TupleType *base; @@ -1209,6 +1259,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const ReferenceType *base; @@ -1246,6 +1307,17 @@ public: ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const PointerType *base; @@ -1344,6 +1416,17 @@ public: void visit (const StrType &type) override { ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const StrType *base; @@ -1360,6 +1443,17 @@ public: void visit (const NeverType &type) override { ok = true; } + void visit (const InferType &type) override + { + if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL) + { + BaseCmp::visit (type); + return; + } + + ok = true; + } + private: const BaseType *get_base () const override { return base; } const NeverType *base; -- cgit v1.1