diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:24 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:24 +0800 |
commit | 83dbb728f62306d2e43b2688dd0f2d320fd5b038 (patch) | |
tree | a064267bdf8d0455ed725140abfcbed3e04b2d4a /src/hir_conv/bind.cpp | |
parent | 0b9fd0014c8f32ecf299dae2ad1811dfb484af46 (diff) | |
parent | f19c75571c48588fb3816e8eb5b96f03474fbdf5 (diff) | |
download | mrust-83dbb728f62306d2e43b2688dd0f2d320fd5b038.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/hir_conv/bind.cpp')
-rw-r--r-- | src/hir_conv/bind.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/hir_conv/bind.cpp b/src/hir_conv/bind.cpp index 20e8f7ca..cf443eb6 100644 --- a/src/hir_conv/bind.cpp +++ b/src/hir_conv/bind.cpp @@ -247,35 +247,42 @@ namespace { ), (Struct, const auto& str = get_struct_ptr(sp, m_crate, e.path); - TU_IFLET(::HIR::Struct::Data, str.m_data, Named, _, - e.binding = &str; - ) + if(str.m_data.is_Named() ) { + } + else if( str.m_data.is_Unit() && e.sub_patterns.size() == 0 ) { + } + else if( str.m_data.is_Tuple() && str.m_data.as_Tuple().empty() && e.sub_patterns.size() == 0 ) { + } else { - ERROR(sp, E0000, "Struct pattern on field-less struct " << e.path); + ERROR(sp, E0000, "Struct pattern `" << pat << "` on field-less struct " << e.path); } + e.binding = &str; ), (EnumTuple, auto p = get_enum_ptr(sp, m_crate, e.path); const auto& var = p.first->m_variants[p.second].second; - TU_IFLET(::HIR::Enum::Variant, var, Tuple, _, - e.binding_ptr = p.first; - e.binding_idx = p.second; - ) + if( var.is_Tuple() ) { + } else { ERROR(sp, E0000, "Enum tuple pattern on non-tuple variant " << e.path); } + e.binding_ptr = p.first; + e.binding_idx = p.second; ), (EnumStruct, auto p = get_enum_ptr(sp, m_crate, e.path); const auto& var = p.first->m_variants[p.second].second; - TU_IFLET(::HIR::Enum::Variant, var, Struct, _, - // All good - e.binding_ptr = p.first; - e.binding_idx = p.second; - ) + if( var.is_Struct() ) { + } + else if( var.is_Unit() && e.sub_patterns.empty() ) { + } + else if( var.is_Tuple() && var.as_Tuple().empty() && e.sub_patterns.empty() ) { + } else { - ERROR(sp, E0000, "Enum tuple pattern on non-tuple variant " << e.path); + ERROR(sp, E0000, "Enum struct pattern `" << pat << "` on non-struct variant " << e.path); } + e.binding_ptr = p.first; + e.binding_idx = p.second; ) ) } |