diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-04-22 14:49:57 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-04-22 14:49:57 +0800 |
commit | 1c4623b57314f67aabe196e416c2ef72a9743112 (patch) | |
tree | dc4c8fcec253c7ed6f370189bbdf723a343a64ec /src | |
parent | 018a5a14dbf4ea94bdbb1bd17db9f7ef3852c2b0 (diff) | |
download | mrust-1c4623b57314f67aabe196e416c2ef72a9743112.tar.gz |
Typecheck Expressions - More hackery
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 3bc7cfe5..f402c2d2 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -4033,6 +4033,7 @@ void Context::handle_pattern(const Span& sp, ::HIR::Pattern& pat, const ::HIR::T // Still pure infer, can't do anything // - What if it's a literal? + // TODO: Don't do fallback if the ivar is marked as being hard blocked if( n_deref == 0 && is_fallback ) { ::HIR::TypeRef possible_type; @@ -6425,6 +6426,12 @@ namespace { context.equate_types_shadow_strong(sp, v.left_ty); } + // HACK? Soft-prevent inferrence of the param types + for(const auto& t : v.params.m_types) + { + context.equate_types_to_shadow(sp, t); + } + // 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)); @@ -6940,6 +6947,14 @@ namespace { } } + // If there's no disable flags set, and there's only one option, pick it. + // - Slight hack to speed up flow-down inference + if( possible_tys.size() == 1 && possible_tys[0].can_deref && !(ivar_ent.force_no_to || ivar_ent.force_no_from) ) { + DEBUG("One possibility (before ivar removal), setting to " << *possible_tys[0].ty); + context.equate_types(sp, ty_l, *possible_tys[0].ty); + return true; + } + // Filter out ivars // - TODO: Should this also remove &_ types? (maybe not, as they give information about borrow classes) size_t n_ivars; |