From 9428db632815386ea6e6c994e92c9aabf00abb35 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 7 May 2021 16:39:28 +0100 Subject: We need to monomorphize tuples as well as ADT's When we have generic data types or types that can contain type parameters we need to make sure to avoid duplicating record types and abusing structural equality rules in GCC. We do this by looking for already compiled types that the item is equal to so they refer to the canoncial record type. Fixes #415 --- gcc/rust/backend/rust-compile-context.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/rust/backend/rust-compile-context.h') diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 11e791c..bdc9eca 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -66,7 +66,7 @@ public: bool lookup_compiled_types (HirId id, ::Btype **type, const TyTy::BaseType *ref = nullptr) { - if (ref != nullptr && ref->has_subsititions_defined ()) + if (ref != nullptr) { for (auto it = mono.begin (); it != mono.end (); it++) { @@ -393,7 +393,8 @@ public: return; } - bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &translated); + bool ok + = ctx->lookup_compiled_types (type.get_ty_ref (), &translated, &type); if (ok) return; @@ -402,8 +403,7 @@ public: for (size_t i = 0; i < type.num_fields (); i++) { TyTy::BaseType *field = type.get_field (i); - Btype *compiled_field_ty - = TyTyCompile::compile (ctx->get_backend (), field); + Btype *compiled_field_ty = TyTyResolveCompile::compile (ctx, field); Backend::Btyped_identifier f (std::to_string (i), compiled_field_ty, ctx->get_mappings ()->lookup_location ( @@ -418,7 +418,7 @@ public: type.get_ty_ref ())); ctx->push_type (named_struct); - ctx->insert_compiled_type (type.get_ty_ref (), named_struct); + ctx->insert_compiled_type (type.get_ty_ref (), named_struct, &type); translated = named_struct; } -- cgit v1.1