diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-06-09 20:31:41 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-06-09 20:31:41 +0800 |
commit | a9f501bde9d8ff5e714d0ef2663177b0949f95cc (patch) | |
tree | 47189972d96bb44e2111e707987aabf75f9e3872 /src/hir/type.hpp | |
parent | 8992eaa470e27ed3da396aed41ce741bc509bb0f (diff) | |
download | mrust-a9f501bde9d8ff5e714d0ef2663177b0949f95cc.tar.gz |
HIR - Sort trait impls too
Diffstat (limited to 'src/hir/type.hpp')
-rw-r--r-- | src/hir/type.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/hir/type.hpp b/src/hir/type.hpp index 7a5a0a1c..13300bbc 100644 --- a/src/hir/type.hpp +++ b/src/hir/type.hpp @@ -328,6 +328,24 @@ public: // Compares this type with another, using `resolve_placeholder` to get replacements for generics/infers in `x` Compare compare_with_placeholders(const Span& sp, const ::HIR::TypeRef& x, t_cb_resolve_type resolve_placeholder) const; + + const ::HIR::SimplePath* get_sort_path() const { + // - Generic paths get sorted + if( TU_TEST1(this->m_data, Path, .path.m_data.is_Generic()) ) + { + return &this->m_data.as_Path().path.m_data.as_Generic().m_path; + } + // - So do trait objects + else if( this->m_data.is_TraitObject() ) + { + return &this->m_data.as_TraitObject().m_trait.m_path.m_path; + } + else + { + // Keep as nullptr, will search primitive list + return nullptr; + } + } }; extern ::std::ostream& operator<<(::std::ostream& os, const ::HIR::TypeRef& ty); |