diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-14 17:12:55 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-14 17:12:55 +0800 |
commit | 43aa83c0ecf84445fc9f1159d1e0b8e8767d66a2 (patch) | |
tree | 3eff51453d03ad9972a44ad92f43dbd622646da1 /src | |
parent | d1382b793e98957e5d6664bea3b75af75d00f1ca (diff) | |
download | mrust-43aa83c0ecf84445fc9f1159d1e0b8e8767d66a2.tar.gz |
HIR Typecheck Expr - Fix possible bug in closure Fn trait selection
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/helpers.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 8489be39..8975c6ba 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -991,18 +991,25 @@ bool TraitResolution::find_trait_impls(const Span& sp, args.push_back( at.clone() ); cmp &= at.compare_with_placeholders(sp, args_des[i], this->m_ivars.callback_resolve_infer()); } - - // NOTE: This is a conditional "true", we know nothing about the move/mut-ness of this closure yet - // - Could we? - // - Not until after the first stage of typeck - - DEBUG("Closure Fn* impl - cmp = " << cmp); - - ::HIR::PathParams pp; - pp.m_types.push_back( ::HIR::TypeRef(mv$(args)) ); - ::std::map< ::std::string, ::HIR::TypeRef> types; - types.insert( ::std::make_pair( "Output", e.m_rettype->clone() ) ); - return callback( ImplRef(type.clone(), mv$(pp), mv$(types)), cmp ); + if( cmp != ::HIR::Compare::Unequal ) + { + // NOTE: This is a conditional "true", we know nothing about the move/mut-ness of this closure yet + // - Could we? + // - Not until after the first stage of typeck + + DEBUG("Closure Fn* impl - cmp = " << cmp); + + ::HIR::PathParams pp; + pp.m_types.push_back( ::HIR::TypeRef(mv$(args)) ); + ::std::map< ::std::string, ::HIR::TypeRef> types; + types.insert( ::std::make_pair( "Output", e.m_rettype->clone() ) ); + return callback( ImplRef(type.clone(), mv$(pp), mv$(types)), cmp ); + } + else + { + DEBUG("Closure Fn* impl - cmp = Compare::Unequal"); + return false; + } } ) |