From: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
---
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 e2f1361a78e..1073dfa6adc 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 4d1a082f80d..94f7bce00f8 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 ());
}
--
2.45.2