summaryrefslogtreecommitdiff
path: root/src/ast
diff options
context:
space:
mode:
authorJohn Hodge (bugs) <tpg@mutabah.net>2017-06-04 21:23:24 +0800
committerJohn Hodge (bugs) <tpg@mutabah.net>2017-06-04 21:23:24 +0800
commit83dbb728f62306d2e43b2688dd0f2d320fd5b038 (patch)
treea064267bdf8d0455ed725140abfcbed3e04b2d4a /src/ast
parent0b9fd0014c8f32ecf299dae2ad1811dfb484af46 (diff)
parentf19c75571c48588fb3816e8eb5b96f03474fbdf5 (diff)
downloadmrust-83dbb728f62306d2e43b2688dd0f2d320fd5b038.tar.gz
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/ast')
-rw-r--r--src/ast/ast.cpp3
-rw-r--r--src/ast/ast.hpp6
-rw-r--r--src/ast/dump.cpp26
3 files changed, 20 insertions, 15 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
index 39250a41..df5f4d5a 100644
--- a/src/ast/ast.cpp
+++ b/src/ast/ast.cpp
@@ -175,6 +175,9 @@ Enum Enum::clone() const
Struct Struct::clone() const
{
TU_MATCHA( (m_data), (e),
+ (Unit,
+ return Struct(m_params.clone());
+ ),
(Tuple,
decltype(e.ents) new_fields;
for(const auto& f : e.ents)
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index b63cb2e6..c067001a 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -319,6 +319,7 @@ public:
TAGGED_UNION_EX(StructData, (), Struct,
(
+ (Unit, struct {}),
(Tuple, struct {
::std::vector<TupleItem> ents;
}),
@@ -339,6 +340,11 @@ public:
StructData m_data;
Struct() {}
+ Struct(GenericParams params):
+ m_params( mv$(params) ),
+ m_data( StructData::make_Unit({}) )
+ {
+ }
Struct( GenericParams params, ::std::vector<StructItem> fields ):
m_params( move(params) ),
m_data( StructData::make_Struct({mv$(fields)}) )
diff --git a/src/ast/dump.cpp b/src/ast/dump.cpp
index a6c298b0..0d77054c 100644
--- a/src/ast/dump.cpp
+++ b/src/ast/dump.cpp
@@ -991,22 +991,18 @@ void RustPrinter::handle_struct(const AST::Struct& s)
print_params(s.params());
TU_MATCH(AST::StructData, (s.m_data), (e),
+ (Unit,
+ m_os << " /* unit-like */\n";
+ print_bounds(s.params());
+ m_os << indent() << ";\n";
+ ),
(Tuple,
- if( e.ents.size() == 0 )
- {
- m_os << " /* unit-like */\n";
- print_bounds(s.params());
- m_os << indent() << ";\n";
- }
- else
- {
- m_os << "(";
- for( const auto& i : e.ents )
- m_os << i.m_type << ", ";
- m_os << ")\n";
- print_bounds(s.params());
- m_os << indent() << ";\n";
- }
+ m_os << "(";
+ for( const auto& i : e.ents )
+ m_os << i.m_type << ", ";
+ m_os << ")\n";
+ print_bounds(s.params());
+ m_os << indent() << ";\n";
),
(Struct,
m_os << "\n";