diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/helpers.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index ebcf0d97..318d910e 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1708,6 +1708,22 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp, for(auto& ty : pe.trait.m_params.m_types) expand_associated_types_inplace(sp, ty, stack); + // TODO: If there are impl params present, return early + { + auto cb = [](const ::HIR::TypeRef& ty){ return !( ty.m_data.is_Generic() && (ty.m_data.as_Generic().binding >> 8) == 2 ); }; + bool has_impl_placeholders = false; + if( !visit_ty_with(*pe.type, cb) ) + has_impl_placeholders = true; + for(const auto& ty : pe.trait.m_params.m_types) + if( !visit_ty_with(ty, cb) ) + has_impl_placeholders = true; + if( has_impl_placeholders ) + { + e.binding = ::HIR::TypeRef::TypePathBinding::make_Opaque({}); + return ; + } + } + // - If it's a closure, then the only trait impls are those generated by typeck TU_IFLET(::HIR::TypeRef::Data, pe.type->m_data, Closure, te, const auto trait_fn = this->m_crate.get_lang_item_path(sp, "fn"); @@ -2839,10 +2855,14 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, DEBUG("- Bound " << real_type << " : " << real_trait_path << " fuzzed"); match = ::HIR::Compare::Fuzzy; } - else if( real_type.m_data.is_Infer() && real_type.m_data.as_Infer().ty_class == ::HIR::InferClass::None ) { + else if( TU_TEST1(real_type.m_data, Infer, .ty_class == ::HIR::InferClass::None) ) { DEBUG("- Bound " << real_type << " : " << real_trait_path << " full infer type - make result fuzzy"); match = ::HIR::Compare::Fuzzy; } + else if( TU_TEST1(real_type.m_data, Generic, .is_placeholder()) ) { + DEBUG("- Bound " << real_type << " : " << real_trait_path << " placeholder - make result fuzzy"); + match = ::HIR::Compare::Fuzzy; + } else { DEBUG("- Bound " << real_type << " : " << real_trait_path << " failed"); return ::HIR::Compare::Unequal; |