summaryrefslogtreecommitdiff
path: root/src/dump_as_rust.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-18 21:40:06 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-18 21:40:06 +0800
commitc0d8141930e95f71a6d4fb84114fdc8a449527b7 (patch)
tree828892e2cbee599bc15227ba3270f6ddc82d2581 /src/dump_as_rust.cpp
parent65aba167033019994e35f43b819d8fbd3620e9ff (diff)
downloadmrust-c0d8141930e95f71a6d4fb84114fdc8a449527b7.tar.gz
All - Support tuple patterns with .. at the start/end - TODO: Support in the middle
Diffstat (limited to 'src/dump_as_rust.cpp')
-rw-r--r--src/dump_as_rust.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp
index 191366fa..1f51f317 100644
--- a/src/dump_as_rust.cpp
+++ b/src/dump_as_rust.cpp
@@ -812,15 +812,18 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
m_os << " ... " << v.end;
}
),
- (WildcardStructTuple,
- m_os << v.path << "(..)";
- ),
(StructTuple,
m_os << v.path << "(";
- for(const auto& sp : v.sub_patterns) {
+ if( v.tup_pat.glob_pos == ::AST::Pattern::TupleGlob::Start ) {
+ m_os << ".., ";
+ }
+ for(const auto& sp : v.tup_pat.sub_patterns) {
print_pattern(sp, is_refutable);
m_os << ",";
}
+ if( v.tup_pat.glob_pos == ::AST::Pattern::TupleGlob::End ) {
+ m_os << " ..";
+ }
m_os << ")";
),
(Struct, {
@@ -833,15 +836,20 @@ void RustPrinter::print_pattern(const AST::Pattern& p, bool is_refutable)
}
m_os << ")";
}),
- (Tuple, {
- const auto& v = p.data().as_Tuple();
+ (Tuple,
m_os << "(";
+ if( v.glob_pos == ::AST::Pattern::TupleGlob::Start ) {
+ m_os << ".., ";
+ }
for(const auto& sp : v.sub_patterns) {
print_pattern(sp, is_refutable);
m_os << ",";
}
+ if( v.glob_pos == ::AST::Pattern::TupleGlob::End ) {
+ m_os << " ..";
+ }
m_os << ")";
- }),
+ ),
(Slice,
m_os << "[";
bool needs_comma = false;