diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-06 13:18:38 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-06 13:18:38 +0800 |
commit | e3f224aa2bc05460faf68c8249c2d4c5ef93da61 (patch) | |
tree | a1d635ce96a1988119049083065941693b051505 /src | |
parent | 256e89db445be8567bea0bab33bdeade9e25c7a8 (diff) | |
download | mrust-e3f224aa2bc05460faf68c8249c2d4c5ef93da61.tar.gz |
HIR Typecheck Static - Support extraction of associated type from TraitOBject bound
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/static.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index cb01e78d..c8afdebf 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -485,6 +485,25 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI //} ) + // If it's a TraitObject, then maybe we're asking for a bound + TU_IFLET(::HIR::TypeRef::Data, e2.type->m_data, TraitObject, te, + const auto& data_trait = te.m_trait.m_path; + if( e2.trait.m_path == data_trait.m_path ) { + if( e2.trait.m_params == data_trait.m_params ) + { + auto it = te.m_trait.m_type_bounds.find( e2.item ); + if( it == te.m_trait.m_type_bounds.end() ) { + // TODO: Mark as opaque and return. + // - Why opaque? It's not bounded, don't even bother + TODO(sp, "Handle unconstrained associate type " << e2.item << " from " << *e2.type); + } + + input = it->second.clone(); + return ; + } + } + ) + // 1. Bounds bool rv; bool assume_opaque = true; |