summaryrefslogtreecommitdiff
path: root/src/mir/from_hir_match.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-11-05 14:58:52 +0800
committerJohn Hodge <tpg@mutabah.net>2016-11-05 14:58:52 +0800
commit85425660cc655b9b71966c5131e692739c04c159 (patch)
tree59803d457d2e10872fcb951010090614f5fc4bb0 /src/mir/from_hir_match.cpp
parent351957a215675d1a3035971ef4af0601a8cdf47a (diff)
downloadmrust-85425660cc655b9b71966c5131e692739c04c159.tar.gz
MIR Gen Match - struct tuples in Simple
Diffstat (limited to 'src/mir/from_hir_match.cpp')
-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;
),