https://gcc.gnu.org/g:ba71c9d3b565fd4a493e1ddcf7a9584e1b33c0c6
commit r15-8531-gba71c9d3b565fd4a493e1ddcf7a9584e1b33c0c6 Author: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> Date: Tue Nov 19 15:37:56 2024 +0100 gccrs: FnParam cloning now keeps projections FnParam type where monomorphized during cloning. gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Reverse monomorphization during cloning and make a new function to explicitly monomorphize. * typecheck/rust-tyty.cc: Use monomorphization when required. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> Diff: --- gcc/rust/typecheck/rust-tyty.cc | 2 +- gcc/rust/typecheck/rust-tyty.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index e2f1361a78e0..1073dfa6adc9 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -597,7 +597,7 @@ BaseType::monomorphized_clone () const { std::vector<TyTy::FnParam> cloned_params; for (auto &p : fn->get_params ()) - cloned_params.push_back (p.clone ()); + cloned_params.push_back (p.monomorphized_clone ()); BaseType *retty = fn->get_return_type ()->monomorphized_clone (); return new FnType (fn->get_ref (), fn->get_ty_ref (), fn->get_id (), diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 4d1a082f80d3..94f7bce00f82 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -791,6 +791,11 @@ public: void set_type (BaseType *new_type) { type = new_type; } FnParam clone () const + { + return FnParam (pattern->clone_pattern (), type->clone ()); + } + + FnParam monomorphized_clone () const { return FnParam (pattern->clone_pattern (), type->monomorphized_clone ()); }