diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-22 14:56:44 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-22 16:00:27 +0800 |
commit | 30d34d460870d7b3b972b7f4edae0507512bc441 (patch) | |
tree | a979a0eae8e564590344d12630ef8dc4ea218b3a /src | |
parent | 2a3fe3be8373594fcd7e46fd4d9c151c28317c9e (diff) | |
download | mrust-30d34d460870d7b3b972b7f4edae0507512bc441.tar.gz |
HIR Resolve UFCS - Populate trait params
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_conv/resolve_ufcs.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/hir_conv/resolve_ufcs.cpp b/src/hir_conv/resolve_ufcs.cpp index 9dec8b91..400d4e0a 100644 --- a/src/hir_conv/resolve_ufcs.cpp +++ b/src/hir_conv/resolve_ufcs.cpp @@ -278,7 +278,22 @@ namespace { const auto& type = *e.type; return this->m_resolve.find_impl(sp, trait_path.m_path, nullptr, type, [&](const auto& impl){ - pd = get_ufcs_known(mv$(e), make_generic_path(trait_path.m_path, trait), trait); + auto pp = impl.get_trait_params(); + // Replace all placeholder parameters (group 2) with ivars (empty types) + pp = monomorphise_path_params_with(sp, pp, [&](const auto& gt)->const auto& { + const auto& ge = gt.m_data.as_Generic(); + if( (ge.binding >> 8) == 2 ) { + static ::HIR::TypeRef empty_type; + return empty_type; + } + return gt; + }, true); + pd = get_ufcs_known(mv$(e), ::HIR::GenericPath(trait_path.m_path, mv$(pp)), trait); + // TODO: What if there's multiple suitable impls for this? + // - Need to be aware in which context this is being called: outer or expression + // > Expression should end up with all trait parameters as `_` (and let inferrence deal with it) + // > Outer should error if there's multiple applicable impls (and get params from the impl) + // Doesn't appear to break anything... yet. DEBUG("FOUND impl from " << impl); return true; }); |