]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Handle structs as scrutinee for match expressions
authorNobel Singh <nobel2073@gmail.com>
Sun, 21 Apr 2024 18:41:12 +0000 (00:26 +0545)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 15 May 2024 13:54:29 +0000 (13:54 +0000)
gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (check_match_scrutinee): Handle structs

Signed-off-by: Nobel Singh <nobel2073@gmail.com>
gcc/rust/backend/rust-compile-expr.cc

index 4d79501ccc3b8c898ff0d3e00bd1c24bd669a7a2..6f37dd8a23ef9c82ec3386cd7a8b97414f4d746c 100644 (file)
@@ -954,8 +954,8 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx)
       // this will need to change but for now the first pass implementation,
       // lets assert this is the case
       TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (scrutinee_expr_tyty);
-      rust_assert (adt->is_enum ());
-      rust_assert (adt->number_of_variants () > 0);
+      if (adt->is_enum ())
+       rust_assert (adt->number_of_variants () > 0);
     }
   else if (scrutinee_kind == TyTy::TypeKind::FLOAT)
     {