diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-03 23:26:27 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-03 23:26:27 +0800 |
commit | 667f88d7ceb2816dad9c745400e937d9f491c80b (patch) | |
tree | c892fd7d98879ff9d3e581eef31fd1d4d119eb37 /src | |
parent | 606c701bca379038568921aec6f216fa69b7a580 (diff) | |
download | mrust-667f88d7ceb2816dad9c745400e937d9f491c80b.tar.gz |
HIR Typecheck CS - Fixed case where an ivar was incorrectly reduced
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index a2cf5635..d4ebf069 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -2788,6 +2788,23 @@ namespace { return true; } + if( ty_src.m_data.is_Infer() && ty_dst.m_data.is_Infer() ) { + const auto& r_e = ty_src.m_data.as_Infer(); + const auto& l_e = ty_dst.m_data.as_Infer(); + if( r_e.ty_class != ::HIR::InferClass::None ) { + context.equate_types(sp, ty_dst, ty_src); + return true; + } + if( l_e.ty_class != ::HIR::InferClass::None ) { + context.equate_types(sp, ty_dst, ty_src); + return true; + } + context.possible_equate_type_to(r_e.index, ty_dst); + context.possible_equate_type_from(l_e.index, ty_src); + DEBUG("- Infer, add possibility"); + return false; + } + // If the source is '_', we can't know yet TU_IFLET(::HIR::TypeRef::Data, ty_src.m_data, Infer, r_e, // - Except if it's known to be a primitive @@ -3497,6 +3514,11 @@ namespace { DEBUG("- IVar " << ty_l << " not concretely known {" << ivar_ent.types_from << "} and {" << ivar_ent.types_to << "}" ); } + // TODO: Handle `let tmp = mem::replace(&mut self.mut_slice, &mut [])` + if( ivar_ent.types_to.size() == 0 ) { + // If all are of the same form, equate this ivar to that class (with a new ivar as the target) + } + ivar_ent.force_no = false; ivar_ent.types_to.clear(); ivar_ent.types_from.clear(); |