diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-22 15:12:08 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-22 16:00:27 +0800 |
commit | d9e027e992b798dafde2b6e90aecca90aee525eb (patch) | |
tree | 3dbd74be28d2823759b4622fcb364868c72f8423 /src | |
parent | 30d34d460870d7b3b972b7f4edae0507512bc441 (diff) | |
download | mrust-d9e027e992b798dafde2b6e90aecca90aee525eb.tar.gz |
HIR Typecheck Expr - Handle TraitObject coerce with no data trait
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/helpers.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 02f06c6a..ccedfb07 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -985,11 +985,17 @@ bool TraitResolution::find_trait_impls(const Span& sp, // TODO: Magic impl if T: ThisTrait bool good; ::HIR::Compare total_cmp = ::HIR::Compare::Equal; - good = find_trait_impls(sp, e.m_trait.m_path.m_path, e.m_trait.m_path.m_params, ty, [&](const auto& , auto cmp){return cmp == ::HIR::Compare::Equal;} ); + if( e.m_trait.m_path.m_path == ::HIR::SimplePath() ) { + ASSERT_BUG(sp, e.m_markers.size() > 0, "TraitObject with no traits - " << dst_ty); + good = true; + } + else { + good = find_trait_impls(sp, e.m_trait.m_path.m_path, e.m_trait.m_path.m_params, ty, [&](const auto& , auto cmp){return cmp == ::HIR::Compare::Equal;} ); + } for(const auto& marker : e.m_markers) { if(!good) break; - good |= find_trait_impls(sp, marker.m_path, marker.m_params, ty, [&](const auto& , auto cmp){return cmp == ::HIR::Compare::Equal;} ); + good &= find_trait_impls(sp, marker.m_path, marker.m_params, ty, [&](const auto& , auto cmp){return cmp == ::HIR::Compare::Equal;} ); } if( good ) { return callback( ImplRef(type.clone(), params.clone(), {}), total_cmp ); |