diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-05-03 20:55:25 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-05-03 20:55:25 +0800 |
commit | 788767f740979632cfeedeb1ac9b5d4f988ac623 (patch) | |
tree | 1dbfa66a04739cc0307b8e335d76e7f2e3ebb68e | |
parent | 1f407a88dabad32956f6936c1fa52de0c1b20285 (diff) | |
download | mrust-788767f740979632cfeedeb1ac9b5d4f988ac623.tar.gz |
Lower MIR - (minor) Replace TU_MATCH with TU_MATCH_HDR
-rw-r--r-- | src/mir/from_hir_match.cpp | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 32c97682..e3ddce30 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -2819,40 +2819,37 @@ void MatchGenGrouped::gen_dispatch(const ::std::vector<t_rules_subset>& rules, s // Matching over a path can only happen with an enum. // TODO: What about `box` destructures? // - They're handled via hidden derefs - if( !te.binding.is_Enum() ) { - TU_MATCHA( (te.binding), (pbe), - (Unbound, - BUG(sp, "Encounterd unbound path - " << te.path); - ), - (Opaque, - BUG(sp, "Attempting to match over opaque type - " << ty); - ), - (Struct, - const auto& str_data = pbe->m_data; - TU_MATCHA( (str_data), (sd), - (Unit, - BUG(sp, "Attempting to match over unit type - " << ty); - ), - (Tuple, - TODO(sp, "Matching on tuple-like struct?"); - ), - (Named, - TODO(sp, "Matching on struct?"); - ) - ) - ), - (Union, - TODO(sp, "Match over Union"); + TU_MATCH_HDR( (te.binding), { ) + TU_ARM(te.binding, Unbound, pbe) { + BUG(sp, "Encounterd unbound path - " << te.path); + } + TU_ARM(te.binding, Opaque, pbe) { + BUG(sp, "Attempting to match over opaque type - " << ty); + } + TU_ARM(te.binding, Struct, pbe) { + const auto& str_data = pbe->m_data; + TU_MATCHA( (str_data), (sd), + (Unit, + BUG(sp, "Attempting to match over unit type - " << ty); ), - (ExternType, - TODO(sp, "Match over ExternType - " << ty); + (Tuple, + TODO(sp, "Matching on tuple-like struct?"); ), - (Enum, + (Named, + TODO(sp, "Matching on struct? - " << ty); ) ) + } + TU_ARM(te.binding, Union, pbe) { + TODO(sp, "Match over Union"); + } + TU_ARM(te.binding, ExternType, pbe) { + TODO(sp, "Match over ExternType - " << ty); + } + TU_ARM(te.binding, Enum, pbe) { + this->gen_dispatch__enum(mv$(ty), mv$(val), rules, ofs, arm_targets, def_blk); + } } - - this->gen_dispatch__enum(mv$(ty), mv$(val), rules, ofs, arm_targets, def_blk); ), (Generic, BUG(sp, "Attempting to match a generic"); |