summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hir/deserialise.cpp1
-rw-r--r--src/hir/hir.hpp4
-rw-r--r--src/hir/serialise.cpp1
-rw-r--r--src/hir_conv/markings.cpp7
-rw-r--r--src/hir_typeck/static.hpp2
5 files changed, 15 insertions, 0 deletions
diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp
index 732e8156..7b821630 100644
--- a/src/hir/deserialise.cpp
+++ b/src/hir/deserialise.cpp
@@ -557,6 +557,7 @@ namespace {
BIT(0, m.can_unsize)
BIT(1, m.has_a_deref)
BIT(2, m.is_copy)
+ BIT(3, m.has_drop_impl)
#undef BIT
m.dst_type = static_cast< ::HIR::TraitMarkings::DstType>( m_in.read_tag() );
m.coerce_unsized_index = m_in.read_count( );
diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp
index 49d03fbd..5f1f55f0 100644
--- a/src/hir/hir.hpp
+++ b/src/hir/hir.hpp
@@ -161,6 +161,10 @@ struct TraitMarkings
/// Indicates that there is at least one Deref impl
bool has_a_deref = false;
+ /// Indicates that there is a Drop impl
+ /// - If there is an impl, there must be an applicable impl to every instance.
+ bool has_drop_impl = false;
+
// If populated, indicates the field that is the coercable pointer.
unsigned int coerce_unsized_index = ~0u;
diff --git a/src/hir/serialise.cpp b/src/hir/serialise.cpp
index 5f8749b5..0acd95ea 100644
--- a/src/hir/serialise.cpp
+++ b/src/hir/serialise.cpp
@@ -819,6 +819,7 @@ namespace {
BIT(0, m.can_unsize)
BIT(1, m.has_a_deref)
BIT(2, m.is_copy)
+ BIT(3, m.has_drop_impl)
#undef BIT
m_out.write_u8(bitflag_1);
diff --git a/src/hir_conv/markings.cpp b/src/hir_conv/markings.cpp
index ca5f7ca7..ed49be52 100644
--- a/src/hir_conv/markings.cpp
+++ b/src/hir_conv/markings.cpp
@@ -21,6 +21,7 @@ class Visitor:
const ::HIR::SimplePath& m_lang_Unsize;
const ::HIR::SimplePath& m_lang_CoerceUnsized;
const ::HIR::SimplePath& m_lang_Deref;
+ const ::HIR::SimplePath& m_lang_Drop;
const ::HIR::SimplePath& m_lang_PhantomData;
public:
Visitor(const ::HIR::Crate& crate):
@@ -28,6 +29,7 @@ public:
m_lang_Unsize( crate.get_lang_item_path_opt("unsize") ),
m_lang_CoerceUnsized( crate.get_lang_item_path_opt("coerce_unsized") ),
m_lang_Deref( crate.get_lang_item_path_opt("deref") ),
+ m_lang_Drop( crate.get_lang_item_path_opt("drop") ),
m_lang_PhantomData( crate.get_lang_item_path_opt("phantom_data") )
{
}
@@ -105,6 +107,11 @@ public:
DEBUG("Type " << impl.m_type << " can Unsize");
ERROR(sp, E0000, "Unsize shouldn't be manually implemented");
}
+ else if( trait_path == m_lang_Drop )
+ {
+ // TODO: Check that there's only one impl, and that it covers the same set as the type.
+ markings.has_drop_impl = true;
+ }
else if( trait_path == m_lang_CoerceUnsized ) {
if( markings_ptr->coerce_unsized_index != ~0u )
ERROR(sp, E0000, "CoerceUnsized can only be implemented once per struct");
diff --git a/src/hir_typeck/static.hpp b/src/hir_typeck/static.hpp
index 11de2970..847b06e3 100644
--- a/src/hir_typeck/static.hpp
+++ b/src/hir_typeck/static.hpp
@@ -23,6 +23,7 @@ public:
::std::map< ::HIR::TypeRef, ::HIR::TypeRef> m_type_equalities;
::HIR::SimplePath m_lang_Copy;
+ ::HIR::SimplePath m_lang_Drop;
::HIR::SimplePath m_lang_Sized;
::HIR::SimplePath m_lang_Fn;
::HIR::SimplePath m_lang_FnMut;
@@ -37,6 +38,7 @@ public:
m_item_generics(nullptr)
{
m_lang_Copy = m_crate.get_lang_item_path_opt("copy");
+ m_lang_Drop = m_crate.get_lang_item_path_opt("drop");
m_lang_Sized = m_crate.get_lang_item_path_opt("sized");
m_lang_Fn = m_crate.get_lang_item_path_opt("fn");
m_lang_FnMut = m_crate.get_lang_item_path_opt("fn_mut");