]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix ICE when handling case of unknown field in HIR::FieldAccess
authorPhilip Herron <herron.philip@googlemail.com>
Thu, 17 Apr 2025 12:50:55 +0000 (13:50 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Fri, 18 Apr 2025 14:01:15 +0000 (14:01 +0000)
commitf81ec04bfde4e771998b44dd5c685069d1229652
tree9a976c3a47b4164cf555245a95577eb7c6c33bde
parent0a34f7bb91855ac95c51219c89d4049c4d69f7b3
gccrs: Fix ICE when handling case of unknown field in HIR::FieldAccess

We were wrongly adding the assertion that this must not be an enum but
this is a pointless assertion we only care that there are variant in the
ADT and if the field exists in the first variant.

Fixes Rust-GCC#3581

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bad assertion

gcc/testsuite/ChangeLog:

* rust/compile/nonexistent-field.rs: fix bad error message
* rust/compile/issue-3581-1.rs: New test.
* rust/compile/issue-3581-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/testsuite/rust/compile/issue-3581-1.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/issue-3581-2.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/nonexistent-field.rs