summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-06 19:24:09 +1000
committerJohn Hodge <tpg@mutabah.net>2016-07-06 19:24:09 +1000
commit6d44c5e7d57dd270d06ecf81d6aed3111b4be406 (patch)
tree439e3b2cb4e425f1a3d416482a5799e60ae64228 /src
parent39cbbbe0814ec3710510fe85d37d036dd8bc3d6b (diff)
downloadmrust-6d44c5e7d57dd270d06ecf81d6aed3111b4be406.tar.gz
HIR Typecheck CS - Don't expand associated unless needed when compacting
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/helpers.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 0d541808..67f6445a 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -886,9 +886,13 @@ void TraitResolution::compact_ivars(HMTypeInferrence& m_ivars)
for(auto& v : m_ivars.m_ivars)
{
if( !v.is_alias() ) {
- auto nt = this->expand_associated_types(Span(), v.type->clone());
- DEBUG("- " << i << " " << *v.type << " -> " << nt);
- *v.type = mv$(nt);
+ // Don't expand unless it is needed
+ if( this->has_associated_type(*v.type) ) {
+ // TODO: cloning is expensive, BUT printing below is nice
+ auto nt = this->expand_associated_types(Span(), v.type->clone());
+ DEBUG("- " << i << " " << *v.type << " -> " << nt);
+ *v.type = mv$(nt);
+ }
}
else {