diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index c24a22a3118..1aa55acf278 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -31,6 +31,7 @@ #include "convert.h" #include "print-tree.h" #include "rust-system.h" +#include "rust-tyty.h" namespace Rust { namespace Compile { @@ -1035,11 +1036,13 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx) } TyTy::TypeKind scrutinee_kind = scrutinee_expr_tyty->get_kind (); - rust_assert ((TyTy::is_primitive_type_kind (scrutinee_kind) - && scrutinee_kind != TyTy::TypeKind::NEVER) - || scrutinee_kind == TyTy::TypeKind::ADT - || scrutinee_kind == TyTy::TypeKind::TUPLE - || scrutinee_kind == TyTy::TypeKind::REF); + rust_debug_loc(expr.get_locus(), "[ARTHUR] check scrutinee: type: %s, %s", TyTy::TypeKindFormat::to_string(scrutinee_kind).c_str(), scrutinee_expr_tyty->as_string().c_str()); + + // rust_assert ((TyTy::is_primitive_type_kind (scrutinee_kind) + // && scrutinee_kind != TyTy::TypeKind::NEVER) + // || scrutinee_kind == TyTy::TypeKind::ADT + // || scrutinee_kind == TyTy::TypeKind::TUPLE + // || scrutinee_kind == TyTy::TypeKind::REF); if (scrutinee_kind == TyTy::TypeKind::FLOAT) { diff --git a/gcc/testsuite/rust/compile/match_scrutinee.rs b/gcc/testsuite/rust/compile/match_scrutinee.rs new file mode 100644 index 00000000000..5bd1b4c833b --- /dev/null +++ b/gcc/testsuite/rust/compile/match_scrutinee.rs @@ -0,0 +1,29 @@ +struct Foo { + a: i32, + b: bool, +} + +fn foo() -> Foo { + Foo { a: 145, b: false } +} + +fn main() { + let x = 15; + + match x { + 15 => {}, + _ => {}, + }; + + match 14 { + 14 => {}, + _ => {}, + }; + + match foo() { + mut foo => { + let _ = foo.a; + let _ = foo.b; + }, + }; +}