diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-coercion.h | 22 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-rules.h | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-coercion.h b/gcc/rust/typecheck/rust-tyty-coercion.h index 34267b3..ed16365 100644 --- a/gcc/rust/typecheck/rust-tyty-coercion.h +++ b/gcc/rust/typecheck/rust-tyty-coercion.h @@ -1130,6 +1130,28 @@ public: } } + // generic args for the unit-struct case + if (type.is_unit () && base->is_unit ()) + { + rust_assert (type.get_num_substitutions () + == base->get_num_substitutions ()); + + for (size_t i = 0; i < type.get_num_substitutions (); i++) + { + auto &a = base->get_substs ().at (i); + auto &b = type.get_substs ().at (i); + + auto pa = a.get_param_ty (); + auto pb = b.get_param_ty (); + + auto res = pa->unify (pb); + if (res->get_kind () == TyTy::TypeKind::ERROR) + { + return; + } + } + } + resolved = type.clone (); } diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h index ad2d4b7..77d912a 100644 --- a/gcc/rust/typecheck/rust-tyty-rules.h +++ b/gcc/rust/typecheck/rust-tyty-rules.h @@ -1128,6 +1128,28 @@ public: } } + // generic args for the unit-struct case + if (type.is_unit () && base->is_unit ()) + { + rust_assert (type.get_num_substitutions () + == base->get_num_substitutions ()); + + for (size_t i = 0; i < type.get_num_substitutions (); i++) + { + auto &a = base->get_substs ().at (i); + auto &b = type.get_substs ().at (i); + + auto pa = a.get_param_ty (); + auto pb = b.get_param_ty (); + + auto res = pa->unify (pb); + if (res->get_kind () == TyTy::TypeKind::ERROR) + { + return; + } + } + } + resolved = type.clone (); } |