diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-17 14:48:01 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-17 14:48:01 +0800 |
commit | cc772e2ac06fda3f872c90cb24c59654f9f4f1c0 (patch) | |
tree | f3d05679710b72230bbcfa2d4dbd6e471d4c9b9c | |
parent | b1c915c9f875de458cacd6717af83cfc003cd4e0 (diff) | |
download | mrust-cc772e2ac06fda3f872c90cb24c59654f9f4f1c0.tar.gz |
HIR Typecheck Expr - Stop autoderef method search when unbound UFCS is hit
-rw-r--r-- | src/hir_typeck/helpers.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index d2c60828..b6b81efc 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -2828,11 +2828,11 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, ty_p = &this->m_ivars.get_type(tmp); } const auto& ty = *ty_p; - DEBUG("[find_trait_impls_crate] - Compare " << ty << " and " << assoc_bound.second << ", matching generics"); + DEBUG("[ftic_check_params] - Compare " << ty << " and " << assoc_bound.second << ", matching generics"); // `ty` = Monomorphised actual type (< `be.type` as `be.trait` >::`assoc_bound.first`) // `assoc_bound.second` = Desired type (monomorphised too) - auto cmp = assoc_bound.second .match_test_generics_fuzz(sp, ty, cb_infer, cb_match); - switch(cmp) + auto cmp_i = assoc_bound.second .match_test_generics_fuzz(sp, ty, cb_infer, cb_match); + switch(cmp_i) { case ::HIR::Compare::Equal: DEBUG("Equal"); @@ -2843,7 +2843,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, case ::HIR::Compare::Fuzzy: // TODO: When a fuzzy match is encountered on a conditional bound, returning `false` can lead to an false negative (and a compile error) // BUT, returning `true` could lead to it being selected. (Is this a problem, should a later validation pass check?) - DEBUG("[find_trait_impls_crate] Fuzzy match assoc bound between " << ty << " and " << assoc_bound.second); + DEBUG("[ftic_check_params] Fuzzy match assoc bound between " << ty << " and " << assoc_bound.second); cmp = ::HIR::Compare::Fuzzy; continue ; } @@ -3128,6 +3128,9 @@ unsigned int TraitResolution::autoderef_find_method(const Span& sp, const HIR::t if( ty.m_data.is_Infer() ) { return ~0u; } + if(ty.m_data.is_Path() && ty.m_data.as_Path().binding.is_Unbound()) { + return ~0u; + } auto allowed_receivers = (unconditional_allow_move || (deref_count == 0) ? AllowedReceivers::All : AllowedReceivers::AnyBorrow); if( this->find_method(sp, traits, ivars, ty, method_name, allowed_receivers, fcn_path) ) { |