diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-12 14:03:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 14:03:11 +0000 |
commit | 2076e69bf92fae8efb0ee11a205a69ad8b4854a8 (patch) | |
tree | 8bc359709578d1610dd282a4333d35e14d092638 | |
parent | c494f30766b569f6bebaf715ae6368c0335b0025 (diff) | |
parent | 7609dfc63e021117c194544f83b2edce34a81520 (diff) | |
download | gcc-2076e69bf92fae8efb0ee11a205a69ad8b4854a8.zip gcc-2076e69bf92fae8efb0ee11a205a69ad8b4854a8.tar.gz gcc-2076e69bf92fae8efb0ee11a205a69ad8b4854a8.tar.bz2 |
Merge #1108
1108: Add missing unify rules for inference variables r=philberty a=philberty
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.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-rules.h | 60 |
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; } |