summaryrefslogtreecommitdiff
path: root/src/parse/token.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-10 14:07:38 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-10 14:07:38 +0800
commit32ed843e8ebafc22f61c3f166bcb4af0ce7f4fd7 (patch)
tree0ad098392b603e5277dc9837ae55e5907863b72e /src/parse/token.cpp
parent41a56d4a17132f67adb187aad3ab13a5486ee1c3 (diff)
downloadmrust-32ed843e8ebafc22f61c3f166bcb4af0ce7f4fd7.tar.gz
Parse - Fix a few cases where tokens were copied instead of cloned
Diffstat (limited to 'src/parse/token.cpp')
-rw-r--r--src/parse/token.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/parse/token.cpp b/src/parse/token.cpp
index 3c4d68ac..6e32f958 100644
--- a/src/parse/token.cpp
+++ b/src/parse/token.cpp
@@ -142,6 +142,20 @@ Token::Token(TagTakeIP, InterpolatedFragment frag)
}
}
+Token::Token(const Token& t):
+ m_type(t.m_type),
+ m_data( Data::make_None({}) ),
+ m_pos( t.m_pos )
+{
+ assert( t.m_data.tag() != Data::TAGDEAD );
+ TU_MATCH(Data, (t.m_data), (e),
+ (None, ),
+ (String, m_data = Data::make_String(e); ),
+ (Integer, m_data = Data::make_Integer(e);),
+ (Float, m_data = Data::make_Float(e);),
+ (Fragment, BUG(t.m_pos, "Attempted to copy a fragment - " << t);)
+ )
+}
Token Token::clone() const
{
Token rv(m_type);