Skip to content

Commit

Permalink
TyTy: Refactor FnType deprecated API
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Use new API.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Use new API.
	* typecheck/rust-tyty-cmp.h: Remove old API.
	* typecheck/rust-tyty.cc (FnPtr::is_equal): Use new API.
	* typecheck/rust-tyty.h: Remove old API.
	* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): Use new API.

Signed-off-by: Jakub Dupak <[email protected]>
  • Loading branch information
jdupak authored and CohenArthur committed Dec 27, 2023
1 parent b9fccab commit a12143b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ CompileExpr::visit (HIR::CallExpr &expr)
if (base->get_kind () == TyTy::TypeKind::FNPTR)
{
const TyTy::FnPtr *fn = static_cast<const TyTy::FnPtr *> (base);
*result = fn->param_at (index);
*result = fn->get_param_type_at (index);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-tyty-call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ TypeCheckCallExpr::visit (FnPtr &type)
for (auto &argument : call.get_arguments ())
{
location_t arg_locus = argument->get_locus ();
BaseType *fnparam = type.param_at (i);
BaseType *fnparam = type.get_param_type_at (i);
auto argument_expr_tyty
= Resolver::TypeCheckExpr::Resolve (argument.get ());
if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
Expand Down
6 changes: 3 additions & 3 deletions gcc/rust/typecheck/rust-tyty-cmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ class FnptrCmp : public BaseCmp

for (size_t i = 0; i < base->num_params (); i++)
{
auto this_param = base->param_at (i);
auto other_param = type.param_at (i);
auto this_param = base->get_param_type_at (i);
auto other_param = type.get_param_type_at (i);
if (!this_param->can_eq (other_param, emit_error_flag))
{
BaseCmp::visit (type);
Expand Down Expand Up @@ -830,7 +830,7 @@ class FnptrCmp : public BaseCmp

for (size_t i = 0; i < base->num_params (); i++)
{
auto this_param = base->param_at (i);
auto this_param = base->get_param_type_at (i);
auto other_param = type.param_at (i).second;
if (!this_param->can_eq (other_param, emit_error_flag))
{
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-tyty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ FnPtr::is_equal (const BaseType &other) const

for (size_t i = 0; i < num_params (); i++)
{
if (!param_at (i)->is_equal (*other2.param_at (i)))
if (!get_param_type_at (i)->is_equal (*other2.get_param_type_at (i)))
return false;
}
return true;
Expand Down
3 changes: 0 additions & 3 deletions gcc/rust/typecheck/rust-tyty.h
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,6 @@ class FnPtr : public CallableTypeInterface

size_t num_params () const { return params.size (); }

// DEPRECATED: Use get_param_type_at
BaseType *param_at (size_t idx) const { return get_param_type_at (idx); }

void accept_vis (TyVisitor &vis) override;
void accept_vis (TyConstVisitor &vis) const override;

Expand Down
6 changes: 3 additions & 3 deletions gcc/rust/typecheck/rust-unify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,8 @@ UnifyRules::expect_fnptr (TyTy::FnPtr *ltype, TyTy::BaseType *rtype)

for (size_t i = 0; i < ltype->num_params (); i++)
{
auto a = ltype->param_at (i);
auto b = type.param_at (i);
auto a = ltype->get_param_type_at (i);
auto b = type.get_param_type_at (i);

auto unified_param
= UnifyRules::Resolve (TyTy::TyWithLocation (a),
Expand Down Expand Up @@ -1058,7 +1058,7 @@ UnifyRules::expect_fnptr (TyTy::FnPtr *ltype, TyTy::BaseType *rtype)

for (size_t i = 0; i < ltype->num_params (); i++)
{
auto this_param = ltype->param_at (i);
auto this_param = ltype->get_param_type_at (i);
auto other_param = type.param_at (i).second;

auto unified_param
Expand Down

0 comments on commit a12143b

Please sign in to comment.