summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-04-26 16:02:11 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-04-26 16:02:11 +0800
commita6ca64bf6645e8e3bac089d370f9dc2a0b6e7b6e (patch)
treef94833f3309ffdad00eee0f185085e0c24546075 /src
parentf8e6e964ffdac258780087d90899e7d3ad34b947 (diff)
downloadmrust-a6ca64bf6645e8e3bac089d370f9dc2a0b6e7b6e.tar.gz
Typecheck Expressions - Strong disable match ergonomics downstream ivars, hack for ivar_poss match ergonomics
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index b453cf9d..913c3fc1 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -4410,7 +4410,8 @@ void Context::handle_pattern(const Span& sp, ::HIR::Pattern& pat, const ::HIR::T
{
if( pat.m_binding.is_valid() ) {
const auto& pb = pat.m_binding;
- context.equate_types_from_shadow(sp, context.get_var(sp, pb.m_slot));
+ //context.equate_types_from_shadow(sp, context.get_var(sp, pb.m_slot));
+ context.equate_types_shadow_strong(sp, context.get_var(sp, pb.m_slot));
}
TU_MATCHA( (pat.m_data), (e),
(Any,
@@ -7854,6 +7855,31 @@ namespace {
}
DEBUG("possible_tys = " << possible_tys);
+ // Find a CD option that can deref to a `--` option
+ for(const auto& e : possible_tys)
+ {
+ if( e.is_pointer && e.can_deref )
+ {
+ ::HIR::TypeRef tmp;
+ const auto* dty = context.m_resolve.autoderef(sp, *e.ty, tmp);
+ if( dty && !dty->m_data.is_Infer() )
+ {
+ for(const auto& e2 : possible_tys)
+ {
+ if( !e2.is_pointer && !e2.can_deref )
+ {
+ if( context.m_ivars.types_equal(*dty, *e2.ty) )
+ {
+ DEBUG("Coerce source can deref once to an unsize destination, picking source " << *e.ty);
+ context.equate_types(sp, ty_l, *e.ty);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
// If there's only one option (or one real option w/ ivars, if in fallback mode) - equate it
//if( possible_tys.size() == 1 && (n_ivars == 0 || !honour_disable) )
if( possible_tys.size() == 1 && n_ivars == 0 )