summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-11-20 13:54:22 +0800
committerJohn Hodge <tpg@mutabah.net>2016-11-20 13:54:22 +0800
commit57ff8f4174f43aa735186d11dbbd5226e71587f0 (patch)
treed8d53e9d999a8fa6308eb0773c3adde8a3fedcba /src
parent09db207173ba768176ead9ff8dad1b9f744ab035 (diff)
downloadmrust-57ff8f4174f43aa735186d11dbbd5226e71587f0.tar.gz
HIR Typecheck Expr - Better detection for magic params
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/helpers.cpp30
-rw-r--r--src/hir_typeck/impl_ref.hpp2
2 files changed, 3 insertions, 29 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index c7e18fe4..69ba1298 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2504,32 +2504,6 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
return false;
}
- #if 0
- auto monomorph = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- ASSERT_BUG(sp, ge.binding >> 8 != 2, "");
- assert( ge.binding < impl_params.size() );
- if( !impl_params[ge.binding] ) {
- return placeholders[ge.binding];
- }
- return *impl_params[ge.binding];
- };
-
- auto ty_mono = monomorphise_type_with(sp, impl.m_type, monomorph, false);
- auto args_mono = monomorphise_path_params_with(sp, impl.m_trait_args, monomorph, false);
- // TODO: Expand associated types in these then ensure that they still match the desired types.
-
- DEBUG("- Making associated type output map - " << impl.m_types.size() << " entries");
- ::std::map< ::std::string, ::HIR::TypeRef> types;
- for( const auto& aty : impl.m_types )
- {
- DEBUG(" > " << aty.first << " = monomorph(" << aty.second.data << ")");
- types.insert( ::std::make_pair(aty.first, this->expand_associated_types(sp, monomorphise_type_with(sp, aty.second.data, monomorph))) );
- }
- // TODO: Ensure that there are no-longer any magic params?
-
- DEBUG("[find_trait_impls_crate] callback(args=" << args_mono << ", assoc={" << types << "})");
- #endif
return callback(ImplRef(mv$(impl_params), trait, impl, mv$(placeholders)), match);
}
);
@@ -2768,12 +2742,12 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
ASSERT_BUG(sp, !impl_params[i], "Placeholder to populated type returned");
auto& ph = placeholders[i];
if( ph.m_data.is_Generic() && ph.m_data.as_Generic().binding == idx ) {
- DEBUG("Bind placeholder " << i << " to " << ty);
+ DEBUG("[ftic_check_params:cb_match] Bind placeholder " << i << " to " << ty);
ph = ty.clone();
return ::HIR::Compare::Equal;
}
else {
- TODO(sp, "Compare placeholder " << i << " " << ph << " == " << ty);
+ TODO(sp, "[ftic_check_params:cb_match] Compare placeholder " << i << " " << ph << " == " << ty);
}
}
else {
diff --git a/src/hir_typeck/impl_ref.hpp b/src/hir_typeck/impl_ref.hpp
index dd31a7e3..bbff0054 100644
--- a/src/hir_typeck/impl_ref.hpp
+++ b/src/hir_typeck/impl_ref.hpp
@@ -55,7 +55,7 @@ struct ImplRef
bool has_magic_params() const {
TU_IFLET(Data, m_data, TraitImpl, e,
for(const auto& t : e.params_ph)
- if( t.m_data.is_Generic() )
+ if( t.m_data.is_Generic() && (t.m_data.as_Generic().binding >> 8) == 2 )
return true;
)
return false;