diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-10-21 18:27:37 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-10-22 10:38:17 +0100 |
commit | b538aa91056a10b31c54580316c49c764f884d67 (patch) | |
tree | 109fce1ad7d9ada99d4329a0f481e9a7b08971cc /gcc | |
parent | 649e3e074bf8306bf0eb042f10483dbd61cd040b (diff) | |
download | gcc-b538aa91056a10b31c54580316c49c764f884d67.zip gcc-b538aa91056a10b31c54580316c49c764f884d67.tar.gz gcc-b538aa91056a10b31c54580316c49c764f884d67.tar.bz2 |
The number of required substituions is offset from the already substituted
When doing HIR::GenericArgs substitutions we must offset from the already
partially substituted arguments.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index f08d8cb..a361653 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -357,7 +357,9 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) return SubstitutionArgumentMappings::error (); } - if (args.get_type_args ().size () > substitutions.size ()) + // for inherited arguments + size_t offs = used_arguments.size (); + if (args.get_type_args ().size () + offs > substitutions.size ()) { RichLocation r (args.get_locus ()); r.add_range (substitutions.front ().get_param_locus ()); @@ -369,7 +371,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) return SubstitutionArgumentMappings::error (); } - if (args.get_type_args ().size () < min_required_substitutions ()) + if (args.get_type_args ().size () + offs < min_required_substitutions ()) { RichLocation r (args.get_locus ()); r.add_range (substitutions.front ().get_param_locus ()); @@ -381,9 +383,6 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) return SubstitutionArgumentMappings::error (); } - // for inherited arguments - size_t offs = used_arguments.size (); - std::vector<SubstitutionArg> mappings; for (auto &arg : args.get_type_args ()) { |