diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-11-18 12:33:47 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-11-18 17:47:12 +0800 |
commit | a2db789d465cd0306e1d87335ddb23c6021fab4e (patch) | |
tree | 39f376b4f625947559a9ce00934173eb78fbf7a1 | |
parent | a28e029ac5c257ea2684899aa5dde3b1b846a96e (diff) | |
download | mrust-a2db789d465cd0306e1d87335ddb23c6021fab4e.tar.gz |
Typecheck Expressions - Treat unbounded ivars as fuzzy in ftic_check_params
-rw-r--r-- | src/hir_typeck/helpers.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 9f72483b..f74ef4f0 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -2806,10 +2806,16 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, const auto& real_trait_path = real_trait.m_path; DEBUG("- bound mono " << real_type << " : " << real_trait); bool found_fuzzy_match = false; - if( real_type.m_data.is_Path() && real_type.m_data.as_Path().binding.is_Unbound() ) { + // If the type is an unbound UFCS path, assume fuzzy + if( TU_TEST1(real_type.m_data, Path, .binding.is_Unbound()) ) { DEBUG("- Bounded type is unbound UFCS, assuming fuzzy match"); found_fuzzy_match = true; } + // If the type is an ivar, but not a literal, assume fuzzy + if( TU_TEST1(real_type.m_data, Infer, .is_lit() == false) ) { + DEBUG("- Bounded type is an ivar, assuming fuzzy match"); + found_fuzzy_match = true; + } // TODO: Pass the `match_test_generics` callback? Or another one that handles the impl placeholders. auto rv = this->find_trait_impls(sp, real_trait_path.m_path, real_trait_path.m_params, real_type, [&](auto impl, auto impl_cmp) { DEBUG("[ftic_check_params] impl_cmp = " << impl_cmp << ", impl = " << impl); |