summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-01 13:06:26 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-01 13:06:26 +0800
commit67ab325a8c67ae39dd5b5c7b790db96469d6902d (patch)
tree8835c897f1b84558bfda4866b77a3e6cbce1f93f /src
parentbdb0eb302b17e999a322fbb1d0b18c6b25bae78b (diff)
downloadmrust-67ab325a8c67ae39dd5b5c7b790db96469d6902d.tar.gz
HIR Typecheck CS - Edge case associate type equality
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 431e8807..56f71f87 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -53,7 +53,7 @@ struct Context
os << "req ty " << v.impl_ty << " impl " << v.trait << v.params;
}
else {
- os << v.left_ty << " = " << "<" << v.impl_ty << " as " << v.trait << v.params << ">::" << v.name;
+ os << v.left_ty << " = " << "< `" << v.impl_ty << "` as `" << v.trait << v.params << "` >::" << v.name;
}
return os;
}
@@ -3013,7 +3013,21 @@ namespace {
}
}
- // Search for ops trait impl
+ // HACK: If the LHS is an opqaue UfcsKnown for the same trait and item, equate the inner types
+ TU_IFLET(::HIR::TypeRef::Data, v.left_ty.m_data, Path, e,
+ if( e.binding.is_Opaque() )
+ {
+ TU_IFLET(::HIR::Path::Data, e.path.m_data, UfcsKnown, pe,
+ if( pe.trait.m_path == v.trait && pe.item == v.name )
+ {
+ context.equate_types(sp, *pe.type, v.impl_ty);
+ return true;
+ }
+ )
+ }
+ )
+
+ // Locate applicable trait impl
unsigned int count = 0;
DEBUG("Searching for impl " << v.trait << v.params << " for " << context.m_ivars.fmt_type(v.impl_ty));
bool found = context.m_resolve.find_trait_impls(sp, v.trait, v.params, v.impl_ty,