aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Dupak <dev@jakubdupak.com>2024-02-02 14:33:56 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-04-04 16:21:10 +0000
commitba7e9a78f6c0f875d94db51c9fc64fec64477874 (patch)
tree0e50432c582bab88bbd1f530117a3cb38d4cae23
parent02d788d14c763bbf4e439869d2a984f5d9aa4f9d (diff)
downloadgcc-ba7e9a78f6c0f875d94db51c9fc64fec64477874.zip
gcc-ba7e9a78f6c0f875d94db51c9fc64fec64477874.tar.gz
gcc-ba7e9a78f6c0f875d94db51c9fc64fec64477874.tar.bz2
borrowck: BIR: use callable API
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Use callable API Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
-rw-r--r--gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc23
1 files changed, 5 insertions, 18 deletions
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
index 2c91629..ea8107b 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
@@ -248,25 +248,12 @@ ExprStmtBuilder::visit (HIR::CallExpr &expr)
PlaceId fn = visit_expr (*expr.get_fnexpr ());
std::vector<PlaceId> arguments = visit_list (expr.get_arguments ());
- auto *call_type = ctx.place_db[fn].tyty;
- if (auto fn_type = call_type->try_as<TyTy::FnType> ())
- {
- for (size_t i = 0; i < fn_type->get_params ().size (); ++i)
- {
- coercion_site (arguments[i], fn_type->get_params ()[i].second);
- }
- }
- else if (auto fn_ptr_type = call_type->try_as<TyTy::FnPtr> ())
- {
- for (size_t i = 0; i < fn_ptr_type->get_params ().size (); ++i)
- {
- coercion_site (arguments[i],
- fn_ptr_type->get_params ()[i].get_tyty ());
- }
- }
- else
+ const auto fn_type
+ = ctx.place_db[fn].tyty->as<const TyTy::CallableTypeInterface> ();
+
+ for (size_t i = 0; i < fn_type->get_num_params (); ++i)
{
- rust_unreachable ();
+ coercion_site (arguments[i], fn_type->get_param_type_at (i));
}
return_expr (new CallExpr (fn, std::move (arguments)), lookup_type (expr),