summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/static.cpp19
-rw-r--r--src/hir_typeck/static.hpp3
-rw-r--r--src/mir/mir_builder.cpp1
3 files changed, 12 insertions, 11 deletions
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index a7f09541..f62c7313 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -85,7 +85,8 @@ bool StaticTraitResolve::find_impl(
const Span& sp,
const ::HIR::SimplePath& trait_path, const ::HIR::PathParams* trait_params,
const ::HIR::TypeRef& type,
- t_cb_find_impl found_cb
+ t_cb_find_impl found_cb,
+ bool dont_handoff_to_specialised
) const
{
TRACE_FUNCTION_F(trait_path << FMT_CB(os, if(trait_params) { os << *trait_params; } else { os << "<?>"; }) << " for " << type);
@@ -94,9 +95,11 @@ bool StaticTraitResolve::find_impl(
static ::HIR::PathParams null_params;
static ::std::map< ::std::string, ::HIR::TypeRef> null_assoc;
- if( trait_path == m_lang_Copy ) {
- if( this->type_is_copy(sp, type) ) {
- return found_cb( ImplRef(&type, &null_params, &null_assoc) );
+ if( !dont_handoff_to_specialised ) {
+ if( trait_path == m_lang_Copy ) {
+ if( this->type_is_copy(sp, type) ) {
+ return found_cb( ImplRef(&type, &null_params, &null_assoc) );
+ }
}
}
@@ -952,12 +955,8 @@ bool StaticTraitResolve::type_is_copy(const Span& sp, const ::HIR::TypeRef& ty)
});
),
(Path,
- // TODO: Cache this result for the relevant scope.
- auto cb_ident = [](const auto&ty)->const auto&{return ty;};
- return m_crate.find_trait_impls(m_lang_Copy, ty, cb_ident, [&](const auto& impl) {
- auto pp = ::HIR::PathParams();
- return this->find_impl__check_crate(sp, m_lang_Copy, &pp, ty, [&](auto ){ return true; }, impl);
- });
+ auto pp = ::HIR::PathParams();
+ return this->find_impl(sp, m_lang_Copy, &pp, ty, [&](auto ){ return true; }, true);
),
(Diverge,
// The ! type is kinda Copy ...
diff --git a/src/hir_typeck/static.hpp b/src/hir_typeck/static.hpp
index 2d3ee129..c6a37c3a 100644
--- a/src/hir_typeck/static.hpp
+++ b/src/hir_typeck/static.hpp
@@ -102,7 +102,8 @@ public:
const Span& sp,
const ::HIR::SimplePath& trait_path, const ::HIR::PathParams* trait_params,
const ::HIR::TypeRef& type,
- t_cb_find_impl found_cb
+ t_cb_find_impl found_cb,
+ bool dont_handoff_to_specialised = false
) const;
private:
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp
index b0f14a28..21afefba 100644
--- a/src/mir/mir_builder.cpp
+++ b/src/mir/mir_builder.cpp
@@ -854,6 +854,7 @@ bool MirBuilder::lvalue_is_copy(const Span& sp, const ::MIR::LValue& val)
{
int rv = 0;
with_val_type(sp, val, [&](const auto& ty){
+ DEBUG("[lvalue_is_copy] ty="<<ty);
rv = (m_resolve.type_is_copy(sp, ty) ? 2 : 1);
});
assert(rv != 0);