diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-23 19:38:13 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-23 19:38:13 +0800 |
commit | ea3c657845313a274f99cc568ff4e3310e248e15 (patch) | |
tree | f8e381baa016bc499cb982bff6e8a2aebe392508 /src/ast | |
parent | 061b63d4fd88e5802927bd42d4b0fd8d5f6fc0f8 (diff) | |
download | mrust-ea3c657845313a274f99cc568ff4e3310e248e15.tar.gz |
AST+HIR - Add stubbed support for erased types (`impl Trait`)
Diffstat (limited to 'src/ast')
-rw-r--r-- | src/ast/types.cpp | 13 | ||||
-rw-r--r-- | src/ast/types.hpp | 20 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/ast/types.cpp b/src/ast/types.cpp index 1c6cc568..7468dcf7 100644 --- a/src/ast/types.cpp +++ b/src/ast/types.cpp @@ -118,6 +118,7 @@ TypeRef::TypeRef(const TypeRef& other) _COPY(Generic) _COPY(Path) _COPY(TraitObject) + _COPY(ErasedType) #undef _COPY #undef _CLONE } @@ -172,6 +173,9 @@ Ordering TypeRef::ord(const TypeRef& x) const ), (TraitObject, return ::ord(ent.traits, x_ent.traits); + ), + (ErasedType, + return ::ord(ent.traits, x_ent.traits); ) ) throw ::std::runtime_error(FMT("BUGCHECK - Unhandled TypeRef class '" << m_data.tag() << "'")); @@ -249,6 +253,15 @@ Ordering TypeRef::ord(const TypeRef& x) const } os << ")"; ) + _(ErasedType, + os << "impl "; + for( const auto& it : ent.traits ) { + if( &it != &ent.traits.front() ) + os << "+"; + os << it; + } + os << ""; + ) } #undef _ //os << ")"; diff --git a/src/ast/types.hpp b/src/ast/types.hpp index 79934e16..66f5797c 100644 --- a/src/ast/types.hpp +++ b/src/ast/types.hpp @@ -96,10 +96,10 @@ TAGGED_UNION(TypeData, None, (TraitObject, struct {
::std::vector<::std::string> hrls;
::std::vector<AST::Path> traits;
- // }),
- //(ImplTrait, struct {
- // ::std::vector<::std::string> hrls;
- // ::std::vector<AST::Path> traits;
+ }),
+ (ErasedType, struct {
+ ::std::vector<::std::string> hrls;
+ ::std::vector<AST::Path> traits;
})
);
@@ -112,18 +112,10 @@ public: virtual ~TypeRef();
- TypeRef(TypeRef&& other) noexcept:
- m_data( mv$(other.m_data) )
- {
- m_span = mv$(other.m_span);
- }
+ TypeRef(TypeRef&& other) noexcept = default;
+ TypeRef& operator=(TypeRef&& other) = default;
TypeRef(const TypeRef& other);
- TypeRef& operator=(TypeRef&& other) {
- m_data = mv$( other.m_data );
- m_span = mv$( other.m_span );
- return *this;
- }
TypeRef& operator=(const TypeRef& other) {
m_data = TypeRef(other).m_data;
return *this;
|