diff options
author | John Hodge <tpg@mutabah.net> | 2018-05-20 22:01:59 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-05-20 22:01:59 +0800 |
commit | de9ecd7a2d70359b34e77ded57e5aa9284345ac5 (patch) | |
tree | 29ab42c6c06960720bd67f0b8ebaec807ad0284e /src/ast/ast.cpp | |
parent | 134be5198993096ab5216b6d52a8937430c733b0 (diff) | |
download | mrust-de9ecd7a2d70359b34e77ded57e5aa9284345ac5.tar.gz |
AST - Refactor lifetime/HRB handling
Diffstat (limited to 'src/ast/ast.cpp')
-rw-r--r-- | src/ast/ast.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 641bd633..1a19a10f 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -379,10 +379,31 @@ Item Item::clone() const //os << ")"; return os; } +::std::ostream& operator<<(::std::ostream& os, const LifetimeParam& p) +{ + os << "'" << p.m_name; + return os; +} + +::std::ostream& operator<<(::std::ostream& os, const HigherRankedBounds& x) +{ + if( x.m_lifetimes.empty() ) { + return os; + } + os << "for<"; + for(const auto& l : x.m_lifetimes) + os << "'" << l << ","; + os << "> "; + return os; +} + ::std::ostream& operator<<(::std::ostream& os, const GenericBound& x) { TU_MATCH(GenericBound, (x), (ent), + (None, + os << "/*-*/"; + ), (Lifetime, os << "'" << ent.test << ": '" << ent.bound; ), @@ -390,14 +411,7 @@ Item Item::clone() const os << ent.type << ": '" << ent.bound; ), (IsTrait, - if( ! ent.hrls.empty() ) - { - os << "for<"; - for(const auto& l : ent.hrls) - os << "'" << l; - os << ">"; - } - os << ent.type << ": " << ent.trait; + os << ent.outer_hrbs << ent.type << ": " << ent.inner_hrbs << ent.trait; ), (MaybeTrait, os << ent.type << ": ?" << ent.trait; |