diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 085d5a79..e63a39b5 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -5539,8 +5539,8 @@ namespace { } /// Returns true if `dst` is found when dereferencing `src` - static bool type_derefs_from(const Span& sp, const Context& context, const ::HIR::TypeRef& dst, const ::HIR::TypeRef& src) { - + static bool type_derefs_from(const Span& sp, const Context& context, const ::HIR::TypeRef& dst, const ::HIR::TypeRef& src) + { ::HIR::TypeRef tmp; const ::HIR::TypeRef* ty = &src; do @@ -5637,6 +5637,18 @@ namespace { // Find an entry in the `types_unsize_from` list that all other entries can unsize to H::dedup_type_list_with(ivar_ent.types_unsize_from, [&](const auto& l, const auto& r) { + if( l.m_data.is_Infer() || r.m_data.is_Infer() ) + return DedupKeep::Both; + + // Check for fuzzy equality of types, and keep only one + // TODO: Ensure that whatever ivar differs can't be different (i.e. it wouldn't change the unsize/coerce) + // TODO: Use `check_unsize_tys` instead + if( l.compare_with_placeholders(sp, r, context.m_ivars.callback_resolve_infer()) != ::HIR::Compare::Unequal ) + { + DEBUG("Possible match, keep left"); + return DedupKeep::Left; + } + // &T and T TU_IFLET( ::HIR::TypeRef::Data, l.m_data, Borrow, le, TU_IFLET( ::HIR::TypeRef::Data, r.m_data, Borrow, re, @@ -5661,6 +5673,15 @@ namespace { if( l.m_data.is_Infer() || r.m_data.is_Infer() ) return DedupKeep::Both; + // Check for fuzzy equality of types, and keep only one + // TODO: Ensure that whatever ivar differs can't be different (i.e. it wouldn't change the unsize/coerce) + // TODO: Use `check_coerce_tys` instead + if( l.compare_with_placeholders(sp, r, context.m_ivars.callback_resolve_infer()) != ::HIR::Compare::Unequal ) + { + DEBUG("Possible match, keep left"); + return DedupKeep::Left; + } + if( l.m_data.is_Borrow() ) { const auto& le = l.m_data.as_Borrow(); |