aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-03-30 18:23:53 +0100
committerPhilip Herron <herron.philip@googlemail.com>2021-03-31 09:45:07 +0100
commit67ed1e36ceae2edd11db4a7f333fe7530f3eed4c (patch)
treed64ee711f842156da955038d6d8453be49634adb /gcc
parentf3275df08d6ad4808b6e03d5e0fa2609c5843ad6 (diff)
downloadgcc-67ed1e36ceae2edd11db4a7f333fe7530f3eed4c.zip
gcc-67ed1e36ceae2edd11db4a7f333fe7530f3eed4c.tar.gz
gcc-67ed1e36ceae2edd11db4a7f333fe7530f3eed4c.tar.bz2
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<i32> where we can check wether we need to actually perform a substitution.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc6
-rw-r--r--gcc/rust/typecheck/rust-tyty.h4
2 files changed, 5 insertions, 5 deletions
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<ADTType *> (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<FnType *> (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 ()
{