diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-05-28 12:16:43 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-05-28 12:16:43 +0800 |
commit | f56c30f45738698fc791f5e33d7203c9421b121b (patch) | |
tree | bdaa9cbac8a1a836374de6f619d38567b2d87bf6 /src/hir_typeck | |
parent | 1ca60578426833dfcfda6ecfa7ef67e31f5d6a85 (diff) | |
download | mrust-f56c30f45738698fc791f5e33d7203c9421b121b.tar.gz |
Typecheck Expressions - Fix some places where ivars don't have indexes
Diffstat (limited to 'src/hir_typeck')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 2 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index ac2cf511..5597b022 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1061,6 +1061,7 @@ namespace { for( auto& val : node.m_args ) { this->context.add_ivars( val->m_res_type ); } + this->context.m_ivars.add_ivars_params(node.m_path.m_params); // - Create ivars in path, and set result type const auto ty = this->get_structenum_ty(node.span(), node.m_is_struct, node.m_path); @@ -1131,6 +1132,7 @@ namespace { void visit(::HIR::ExprNode_StructLiteral& node) override { TRACE_FUNCTION_F(&node << " " << node.m_path << "{...} [" << (node.m_is_struct ? "struct" : "enum") << "]"); + this->add_ivars_generic_path(node.span(), node.m_path); for( auto& val : node.m_values ) { this->context.add_ivars( val.second->m_res_type ); } diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index e257d154..b60b03c8 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -468,6 +468,8 @@ void HMTypeInferrence::add_ivars(::HIR::TypeRef& type) (TraitObject, // Iterate all paths this->add_ivars_params(e.m_trait.m_path.m_params); + for(auto& aty : e.m_trait.m_type_bounds) + this->add_ivars(aty.second); for(auto& marker : e.m_markers) this->add_ivars_params(marker.m_params); ), @@ -2142,7 +2144,7 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple if( e.trait.m_path.m_path == trait ) { // Check against `params` - DEBUG("Checking " << params << " vs " << b_params); + DEBUG("[find_trait_impls_bound] Checking params " << params << " vs " << b_params); auto ord = cmp; ord &= this->compare_pp(sp, b_params, params); if( ord == ::HIR::Compare::Unequal ) @@ -2150,6 +2152,7 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple if( ord == ::HIR::Compare::Fuzzy ) { DEBUG("Fuzzy match"); } + DEBUG("[find_trait_impls_bound] Match " << b); // Hand off to the closure, and return true if it does // TODO: The type bounds are only the types that are specified. if( callback( ImplRef(&e.type, &e.trait.m_path.m_params, &e.trait.m_type_bounds), ord) ) { @@ -3361,6 +3364,12 @@ const ::HIR::TypeRef* TraitResolution::autoderef(const Span& sp, const ::HIR::Ty else { bool succ = this->find_trait_impls(sp, this->m_crate.get_lang_item_path(sp, "deref"), ::HIR::PathParams {}, ty, [&](auto impls, auto match) { tmp_type = impls.get_type("Target"); + if( tmp_type == ::HIR::TypeRef() ) + { + tmp_type = ::HIR::Path( ty.clone(), this->m_crate.get_lang_item_path(sp, "deref"), "Target" ); + tmp_type.m_data.as_Path().binding = ::HIR::TypeRef::TypePathBinding::make_Opaque({}); + } + DEBUG("Deref " << ty << " into " << tmp_type); return true; }); if( succ ) { |