summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-07-21 13:51:27 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-07-21 13:51:27 +0800
commita0f277b39dc1eae29d1734b67240a90eb64dbece (patch)
tree356b926b4e711a8454ee88a73706553b88727dfc /src
parentc96d5e03c73d0cd171b29c387601776174e811b8 (diff)
downloadmrust-a0f277b39dc1eae29d1734b67240a90eb64dbece.tar.gz
HIR Typecheck - Short-circuit when method name is found on a trait object
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp1
-rw-r--r--src/hir_typeck/helpers.cpp6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index ecaae208..eb0ccbdb 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -2867,6 +2867,7 @@ namespace {
if( possible_methods.size() != 1 && possible_methods.front().second.m_data.is_UfcsKnown() )
{
DEBUG("- Multiple options, deferring");
+ // TODO: If the type is fully known, then this is an error.
return;
}
auto& ad_borrow = possible_methods.front().first;
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 663818e2..c2e95fd6 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -4021,6 +4021,12 @@ bool TraitResolution::find_method(const Span& sp,
rv = true;
}
}
+
+ // If the method was found on the trait object, prefer that over all others.
+ if( !possibilities.empty() )
+ {
+ return rv;
+ }
}
// 3. Mutually exclusive searches