summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mir/from_hir_match.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index e1e90705..1c4a3486 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -1275,7 +1275,23 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
),
(Tuple,
if( !rule.is_Any() ) {
- TODO(sp, "Match over tuple struct");
+ unsigned int total = 0;
+ unsigned int i = 0;
+ for( const auto& fld : sd ) {
+ ::HIR::TypeRef ent_ty_tmp;
+ const auto& ent_ty = (monomorphise_type_needed(fld.ent) ? ent_ty_tmp = monomorph(fld.ent) : fld.ent);
+ unsigned int cnt = MIR_LowerHIR_Match_Simple__GeneratePattern(
+ builder, sp,
+ rules, num_rules, ent_ty,
+ ::MIR::LValue::make_Field({ box$(match_val.clone()), i }),
+ fail_bb
+ );
+ total += cnt;
+ rules += cnt;
+ num_rules -= cnt;
+ i += 1;
+ }
+ return total;
}
return 1;
),