diff options
author | Liam Naddell <liam.naddell@mail.utoronto.ca> | 2024-07-12 20:56:08 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:53 +0100 |
commit | 75dce4d629249a31bebd5e58e6f13e5d3df04711 (patch) | |
tree | 2a10a4e7e6fa7a9a525cd560e33ab726ada6656a /gcc/rust | |
parent | f89b07d3589d071b9b158e8c744f2006f8359f12 (diff) | |
download | gcc-75dce4d629249a31bebd5e58e6f13e5d3df04711.zip gcc-75dce4d629249a31bebd5e58e6f13e5d3df04711.tar.gz gcc-75dce4d629249a31bebd5e58e6f13e5d3df04711.tar.bz2 |
gccrs: [gccrs#3046] ICE on failing to find enum variant
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc:
Fix ICE caused by not finding enum variant by adding new error
message
gcc/testsuite/ChangeLog:
* rust/compile/issue-3046.rs:
Add test for new error message
Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 6212660..0e897813 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -194,7 +194,14 @@ TypeCheckExpr::visit (HIR::CallExpr &expr) HirId variant_id; bool ok = context->lookup_variant_definition ( expr.get_fnexpr ()->get_mappings ().get_hirid (), &variant_id); - rust_assert (ok); + + if (!ok) + { + rust_error_at (expr.get_locus (), ErrorCode::E0423, + "expected function, tuple struct or tuple " + "variant, found enum"); + return; + } TyTy::VariantDef *lookup_variant = nullptr; ok = adt->lookup_variant_by_id (variant_id, &lookup_variant); |