diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2024-05-02 20:58:49 -0400 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-05-16 09:10:48 +0000 |
commit | 1c52754ee19991bc07c4023cad777a6a894bb64f (patch) | |
tree | 40f21b109f1e05374b32ef638d8d698fb5e554b9 /gcc/rust/backend/rust-compile-expr.cc | |
parent | 154ce770c6844d7211276a53b2ec3db0b5e3f485 (diff) | |
download | gcc-1c52754ee19991bc07c4023cad777a6a894bb64f.zip gcc-1c52754ee19991bc07c4023cad777a6a894bb64f.tar.gz gcc-1c52754ee19991bc07c4023cad777a6a894bb64f.tar.bz2 |
Improve matching on non-enum ADTs
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc
(check_match_scrutinee): Add assertion.
* backend/rust-compile-pattern.cc
(CompilePatternCheckExpr::visit):
Handle HIR::PathInExpression matching a non-enum.
gcc/testsuite/ChangeLog:
* rust/compile/match-struct-path.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 6f37dd8..e53da93 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -956,6 +956,8 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx) TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (scrutinee_expr_tyty); if (adt->is_enum ()) rust_assert (adt->number_of_variants () > 0); + else + rust_assert (adt->number_of_variants () == 1); } else if (scrutinee_kind == TyTy::TypeKind::FLOAT) { |