diff options
-rw-r--r-- | src/hir/path.hpp | 6 | ||||
-rw-r--r-- | src/trans/enumerate.cpp | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/hir/path.hpp b/src/hir/path.hpp index 7734b657..addfba05 100644 --- a/src/hir/path.hpp +++ b/src/hir/path.hpp @@ -110,6 +110,12 @@ struct PathParams Compare compare_with_placeholders(const Span& sp, const PathParams& x, t_cb_resolve_type resolve_placeholder) const; Compare match_test_generics_fuzz(const Span& sp, const PathParams& x, t_cb_resolve_type resolve_placeholder, t_cb_match_generics) const; + /// Indicates that params exist (and thus the target requires monomorphisation) + /// - Ignores lifetime params + bool has_params() const { + return !m_types.empty(); + } + bool operator==(const PathParams& x) const; bool operator!=(const PathParams& x) const { return !(*this == x); } bool operator<(const PathParams& x) const { return ord(x) == OrdLess; } diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp index 54bf4ed7..283617f2 100644 --- a/src/trans/enumerate.cpp +++ b/src/trans/enumerate.cpp @@ -1035,7 +1035,8 @@ void Trans_Enumerate_Types(EnumState& state) ) ASSERT_BUG(Span(), markings_ptr, "Path binding not set correctly - " << ty); - if( markings_ptr->has_drop_impl ) + // If the type has a drop impl, and it's either defined in this crate or has params (and thus was monomorphised) + if( markings_ptr->has_drop_impl && (te.path.m_data.as_Generic().m_path.m_crate_name == state.crate.m_crate_name || te.path.m_data.as_Generic().m_params.has_params()) ) { // Add the Drop impl to the codegen list Trans_Enumerate_FillFrom_Path(state, ::HIR::Path( ty.clone(), state.crate.get_lang_item_path(sp, "drop"), "drop"), {}); |