aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-09-17 14:15:31 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-09-17 15:46:42 +0100
commite29a8a4172ae5c4f85d0e21d7edfaf934744c9fb (patch)
tree98f1af69c6ba1c718ab680751a2129eeaadbbab0 /gcc/rust
parentecb777cc8df55a024add203e858486eadcc3aa62 (diff)
downloadgcc-e29a8a4172ae5c4f85d0e21d7edfaf934744c9fb.zip
gcc-e29a8a4172ae5c4f85d0e21d7edfaf934744c9fb.tar.gz
gcc-e29a8a4172ae5c4f85d0e21d7edfaf934744c9fb.tar.bz2
Cleanup error handling for CallExpr
Call Expressions need to type check the argument passing but the type system will return TyTy::Error nodes, it used to return nullptr about a year ago. Returning error nodes are safer and more flexible for detailed error handling and diagnostics. Addresses: #539
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 69fb8c4..dd33975 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -2352,14 +2352,14 @@ TypeCheckCallExpr::visit (ADTType &type)
BaseType *field_tyty = field->get_field_type ();
BaseType *arg = Resolver::TypeCheckExpr::Resolve (p, false);
- if (arg == nullptr)
+ if (arg->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (p->get_locus (), "failed to resolve argument type");
return false;
}
auto res = field_tyty->unify (arg);
- if (res == nullptr)
+ if (res->get_kind () == TyTy::TypeKind::ERROR)
{
return false;
}
@@ -2407,7 +2407,7 @@ TypeCheckCallExpr::visit (FnType &type)
size_t i = 0;
call.iterate_params ([&] (HIR::Expr *param) mutable -> bool {
auto argument_expr_tyty = Resolver::TypeCheckExpr::Resolve (param, false);
- if (argument_expr_tyty == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"failed to resolve type for argument expr in CallExpr");
@@ -2421,7 +2421,7 @@ TypeCheckCallExpr::visit (FnType &type)
{
auto fnparam = type.param_at (i);
resolved_argument_type = fnparam.second->unify (argument_expr_tyty);
- if (resolved_argument_type == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"Type Resolution failure on parameter");
@@ -2472,7 +2472,7 @@ TypeCheckCallExpr::visit (FnPtr &type)
call.iterate_params ([&] (HIR::Expr *param) mutable -> bool {
auto fnparam = type.param_at (i);
auto argument_expr_tyty = Resolver::TypeCheckExpr::Resolve (param, false);
- if (argument_expr_tyty == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"failed to resolve type for argument expr in CallExpr");
@@ -2480,7 +2480,7 @@ TypeCheckCallExpr::visit (FnPtr &type)
}
auto resolved_argument_type = fnparam->unify (argument_expr_tyty);
- if (resolved_argument_type == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"Type Resolution failure on parameter");
@@ -2523,7 +2523,7 @@ TypeCheckMethodCallExpr::visit (FnType &type)
call.iterate_params ([&] (HIR::Expr *param) mutable -> bool {
auto fnparam = type.param_at (i);
auto argument_expr_tyty = Resolver::TypeCheckExpr::Resolve (param, false);
- if (argument_expr_tyty == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"failed to resolve type for argument expr in CallExpr");
@@ -2531,7 +2531,7 @@ TypeCheckMethodCallExpr::visit (FnType &type)
}
auto resolved_argument_type = fnparam.second->unify (argument_expr_tyty);
- if (resolved_argument_type == nullptr)
+ if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR)
{
rust_error_at (param->get_locus (),
"Type Resolution failure on parameter");