diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-23 17:16:14 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-23 17:16:14 +0800 |
commit | ae47593d02752ab6d7a6c768cc168772b5244e22 (patch) | |
tree | 9a2eccd5824c937aa70264678df1802666ee12c2 /src | |
parent | cb2430a01df314896aeaa4f99ab77dd1a9a3e93f (diff) | |
download | mrust-ae47593d02752ab6d7a6c768cc168772b5244e22.tar.gz |
Trans - Only codegen drop impls if needed
Diffstat (limited to 'src')
-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"), {}); |