diff options
| author | John Hodge <tpg@mutabah.net> | 2016-07-10 17:02:41 +1000 | 
|---|---|---|
| committer | John Hodge <tpg@mutabah.net> | 2016-07-10 17:02:41 +1000 | 
| commit | 478c905e5db5dc6ded018e3123b4346de6da0693 (patch) | |
| tree | 48dd69d009ee7e5c724ebeda0fafc8c9ac01c9bc /src | |
| parent | 0096355b2db981c481948426c0aad635b0da9e69 (diff) | |
| download | mrust-478c905e5db5dc6ded018e3123b4346de6da0693.tar.gz | |
HIR Typecheck CS - Allow fuzzy impl matching
Diffstat (limited to 'src')
| -rw-r--r-- | src/hir_typeck/helpers.cpp | 13 | 
1 files changed, 8 insertions, 5 deletions
| diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 7dafcb8b..a6ce091b 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1672,12 +1672,15 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,                  if( ! impl_params[idx] ) {                      impl_params[idx] = &ty;                  } -                else if( ! this->m_ivars.types_equal(*impl_params[idx], ty) ) { -                    // Strict equality is OK, as all types should be sane -                    // - TODO: What if there's an un-expanded associated? -                    match = ::HIR::Compare::Unequal; +                else if( this->m_ivars.types_equal(*impl_params[idx], ty) ) { +                    // Fall +                } +                else if( ty.m_data.is_Infer() ) { +                    // Fall +                    match = ::HIR::Compare::Fuzzy;                  }                  else { +                    match = ::HIR::Compare::Unequal;                  }                  };              assert( impl.m_trait_args.m_types.size() == params.m_types.size() ); @@ -1685,7 +1688,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,              for(unsigned int i = 0; i < impl.m_trait_args.m_types.size(); i ++)                  match &= impl.m_trait_args.m_types[i].match_test_generics_fuzz(sp, params.m_types[i], this->m_ivars.callback_resolve_infer(), cb);              if( match == ::HIR::Compare::Unequal ) { -                DEBUG("- Failed to match parameters - " << impl.m_trait_args << " != " << params); +                DEBUG("- Failed to match parameters - " << impl.m_trait_args << "+" << impl.m_type << " != " << params << "+" << type);                  return false;              }              for(unsigned int i = 0; i < impl_params.size(); i ++ ) { | 
