diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-03 10:04:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-03 10:04:06 +0800 |
commit | c6b54cafb06560d298b550a3711de642710f72e1 (patch) | |
tree | ed675784cc78b3c5062b003e0a369c8a4072d1f9 | |
parent | 3d4b0c406c11a2f98ea258e0762736fca119b76a (diff) | |
download | mrust-c6b54cafb06560d298b550a3711de642710f72e1.tar.gz |
MIR Gen - Fix missing type param for Place trait
-rw-r--r-- | src/mir/from_hir.cpp | 4 | ||||
-rw-r--r-- | src/trans/enumerate.cpp | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index a763b42c..9bc1c287 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -1271,8 +1271,8 @@ namespace { auto place_refmut__type = ::HIR::TypeRef::new_borrow(::HIR::BorrowType::Unique, place_type.clone()); auto place_refmut = m_builder.lvalue_or_temp(node.span(), place_refmut__type, ::MIR::RValue::make_Borrow({ 0, ::HIR::BorrowType::Unique, place.clone() })); auto fcn_ty_data = ::HIR::FunctionType { false, "", box$( place_raw__type.clone() ), ::make_vec1(mv$(place_refmut__type)) }; - // <typeof(place) as ops::Place>::pointer - auto fcn_path = ::HIR::Path(place_type.clone(), ::HIR::GenericPath(path_Place), "pointer", {}); + // <typeof(place) as ops::Place<T>>::pointer (T = inner) + auto fcn_path = ::HIR::Path(place_type.clone(), ::HIR::GenericPath(path_Place, ::HIR::PathParams(data_ty.clone())), "pointer"); auto fcn_val = m_builder.new_temporary( ::HIR::TypeRef(mv$(fcn_ty_data)) ); m_builder.push_stmt_assign( node.span(), fcn_val.clone(), ::MIR::RValue::make_Constant( ::MIR::Constant(mv$(fcn_path)) ) ); m_builder.end_block(::MIR::Terminator::make_Call({ diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp index 5eab0bb9..24c87897 100644 --- a/src/trans/enumerate.cpp +++ b/src/trans/enumerate.cpp @@ -144,11 +144,12 @@ namespace { // Easy (ish) EntPtr rv; crate.find_type_impls(*e.type, [](const auto&x)->const auto& { return x; }, [&](const auto& impl) { + DEBUG("Found impl" << impl.m_params.fmt_args() << " " << impl.m_type); { auto fit = impl.m_methods.find(e.item); if( fit != impl.m_methods.end() ) { - DEBUG("Found impl" << impl.m_params.fmt_args() << " " << impl.m_type); + DEBUG("- Contains method, good"); rv = EntPtr { &fit->second.data }; return true; } @@ -182,6 +183,8 @@ namespace { ::std::vector<const ::HIR::TypeRef*> best_impl_params; const ::HIR::TraitImpl* best_impl = nullptr; crate.find_trait_impls(e.trait.m_path, *e.type, [](const auto&x)->const auto& { return x; }, [&](const auto& impl) { + DEBUG("Found impl" << impl.m_params.fmt_args() << " " << e.trait.m_path << impl.m_trait_args << " for " << impl.m_type); + ASSERT_BUG(sp, impl.m_trait_args.m_types.size() == e.trait.m_params.m_types.size(), "Trait parameter count mismatch " << impl.m_trait_args << " vs " << e.trait.m_params); ::std::vector<const ::HIR::TypeRef*> impl_params; @@ -199,8 +202,10 @@ namespace { impl_params.resize(impl.m_params.m_types.size()); auto match = impl.m_type.match_test_generics_fuzz(sp, *e.type, cb_ident, cb); match &= impl.m_trait_args.match_test_generics_fuzz(sp, e.trait.m_params, cb_ident, cb); - if( match != ::HIR::Compare::Equal ) + if( match != ::HIR::Compare::Equal ) { + DEBUG("- Match failed (" << match << ") " << *e.type << " \n + " << e.trait.m_params); return false; + } if( best_impl == nullptr || impl.more_specific_than(*best_impl) ) { best_impl = &impl; |