Skip to content

Commit

Permalink
FnParam cloning now keeps projections
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
P-E-P committed Nov 19, 2024
1 parent f884951 commit bc26931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-tyty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 (),
Expand Down
5 changes: 5 additions & 0 deletions gcc/rust/typecheck/rust-tyty.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,11 @@ class FnParam
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 ());
}
Expand Down

0 comments on commit bc26931

Please sign in to comment.