diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-07-21 13:51:27 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-07-21 13:51:27 +0800 |
commit | a0f277b39dc1eae29d1734b67240a90eb64dbece (patch) | |
tree | 356b926b4e711a8454ee88a73706553b88727dfc /src | |
parent | c96d5e03c73d0cd171b29c387601776174e811b8 (diff) | |
download | mrust-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.cpp | 1 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 6 |
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 |