From 67ed1e36ceae2edd11db4a7f333fe7530f3eed4c Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 30 Mar 2021 18:23:53 +0100 Subject: Fix bad tracking on used substitutions on generic types. When implementing generics we need to keep track of used arguments to recursively substitute ParamTypes when nessecary. This also applies for cases such as: Foo where we can check wether we need to actually perform a substitution. --- gcc/rust/typecheck/rust-tyty.cc | 6 ++---- gcc/rust/typecheck/rust-tyty.h | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 58baee9..3fad7d9 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -369,10 +369,9 @@ ADTType::handle_substitions (SubstitutionArgumentMappings subst_mappings) return nullptr; } - used_arguments = subst_mappings; - ADTType *adt = static_cast (clone ()); adt->set_ty_ref (mappings->get_next_hir_id ()); + adt->used_arguments = subst_mappings; for (auto &sub : adt->get_substs ()) { @@ -571,10 +570,9 @@ FnType::handle_substitions (SubstitutionArgumentMappings subst_mappings) return nullptr; } - used_arguments = subst_mappings; - FnType *fn = static_cast (clone ()); fn->set_ty_ref (mappings->get_next_hir_id ()); + fn->used_arguments = subst_mappings; for (auto &sub : fn->get_substs ()) { diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index ac5a766..0cf7d30 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -527,7 +527,9 @@ public: } } - bool was_substituted () const { return !used_arguments.is_error (); } + bool needs_substitution () const { return used_arguments.is_error (); } + + bool was_substituted () const { return !needs_substitution (); } SubstitutionArgumentMappings get_substitution_arguments () { -- cgit v1.1