summaryrefslogtreecommitdiff
path: root/src/dump_as_rust.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-01-30 15:41:15 +0800
committerJohn Hodge <tpg@mutabah.net>2016-01-30 15:41:15 +0800
commite3cf598517bf45317df0891462d71fa0b20dd1b9 (patch)
tree9c359e49507faa9c36e0c3ebb6612a8c26271a0a /src/dump_as_rust.cpp
parentbc4c6189980d2fc1c8e753b9cd614699652ecba7 (diff)
downloadmrust-e3cf598517bf45317df0891462d71fa0b20dd1b9.tar.gz
A whole lot of messing around for not much
Diffstat (limited to 'src/dump_as_rust.cpp')
-rw-r--r--src/dump_as_rust.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp
index cbd0eaac..f0355a6f 100644
--- a/src/dump_as_rust.cpp
+++ b/src/dump_as_rust.cpp
@@ -720,34 +720,33 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
if( p.binding() != "" ) {
m_os << p.binding();
// If binding is irrefutable, and would be binding against a wildcard, just emit the name
- if( !is_refutable && p.data().tag() == AST::Pattern::Data::Any )
+ if( !is_refutable && p.data().is_Any() )
{
return ;
}
m_os << " @ ";
}
- switch(p.data().tag())
- {
- case AST::Pattern::Data::Any:
+ TU_MATCH(AST::Pattern::Data, (p.data()), (v),
+ (Any,
m_os << "_";
- break;
- case AST::Pattern::Data::MaybeBind:
+ ),
+ (MaybeBind,
m_os << "_ /*?*/";
- break;
- case AST::Pattern::Data::Ref: {
+ ),
+ (Ref, {
const auto& v = p.data().as_Ref();
m_os << "& ";
print_pattern(*v.sub, is_refutable);
- break; }
- case AST::Pattern::Data::Value: {
+ }),
+ (Value, {
auto& v = p.data().as_Value();
v.start->visit(*this);
if( v.end.get() ) {
m_os << " ... ";
v.end->visit(*this);
}
- break; }
- case AST::Pattern::Data::StructTuple: {
+ }),
+ (StructTuple, {
const auto& v = p.data().as_StructTuple();
m_os << v.path << "(";
for(const auto& sp : v.sub_patterns) {
@@ -755,8 +754,8 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
m_os << ",";
}
m_os << ")";
- break; }
- case AST::Pattern::Data::Struct: {
+ }),
+ (Struct, {
const auto& v = p.data().as_Struct();
m_os << v.path << "(";
for(const auto& sp : v.sub_patterns) {
@@ -765,8 +764,8 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
m_os << ",";
}
m_os << ")";
- break; }
- case AST::Pattern::Data::Tuple: {
+ }),
+ (Tuple, {
const auto& v = p.data().as_Tuple();
m_os << "(";
for(const auto& sp : v.sub_patterns) {
@@ -774,8 +773,8 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
m_os << ",";
}
m_os << ")";
- break; }
- }
+ })
+ )
}
void RustPrinter::print_type(const TypeRef& t)