diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-05-10 13:55:42 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-05-10 13:55:42 +0100 |
commit | e0c5afe70d33d902cf89f2e0ced5431a50521dcd (patch) | |
tree | 43aa7c68413a96b62ea646296fb1441ee6a31abd /gcc | |
parent | 02f08eef46dbf257e60d935123ab72f22789ddd6 (diff) | |
download | gcc-e0c5afe70d33d902cf89f2e0ced5431a50521dcd.zip gcc-e0c5afe70d33d902cf89f2e0ced5431a50521dcd.tar.gz gcc-e0c5afe70d33d902cf89f2e0ced5431a50521dcd.tar.bz2 |
Only infer substitutions for type parameters which need it
When we infer substitutions it means to infer for all type parameters
regardless of defaults. This means we need to also not simply ignore
any type paramters which are already been substituted.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 84f2a80..cbb447c 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -693,10 +693,18 @@ public: BaseType *infer_substitions (Location locus) { std::vector<SubstitutionArg> args; - for (auto &sub : get_substs ()) + for (auto &p : get_substs ()) { - TyVar infer_var = TyVar::get_implicit_infer_var (locus); - args.push_back (SubstitutionArg (&sub, infer_var.get_tyty ())); + if (p.needs_substitution ()) + { + TyVar infer_var = TyVar::get_implicit_infer_var (locus); + args.push_back (SubstitutionArg (&p, infer_var.get_tyty ())); + } + else + { + args.push_back ( + SubstitutionArg (&p, p.get_param_ty ()->resolve ())); + } } SubstitutionArgumentMappings infer_arguments (std::move (args), locus); |