summaryrefslogtreecommitdiff
path: root/src/hir_conv
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-06-04 07:28:18 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-06-04 07:28:18 +0800
commit2f2f8f04b081f89de411f9b9b2ad40ace3733983 (patch)
treeea9ea9c5231d55408b5774fbcb5fdac985157530 /src/hir_conv
parent4c695334a5e9c71bb264ff6727e213635fd64610 (diff)
downloadmrust-2f2f8f04b081f89de411f9b9b2ad40ace3733983.tar.gz
HIR Markings - Flag for any Copy impl
Diffstat (limited to 'src/hir_conv')
-rw-r--r--src/hir_conv/markings.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/hir_conv/markings.cpp b/src/hir_conv/markings.cpp
index d43db2b5..01eb0952 100644
--- a/src/hir_conv/markings.cpp
+++ b/src/hir_conv/markings.cpp
@@ -20,6 +20,7 @@ class Visitor:
const ::HIR::Crate& m_crate;
const ::HIR::SimplePath& m_lang_Unsize;
const ::HIR::SimplePath& m_lang_CoerceUnsized;
+ const ::HIR::SimplePath& m_lang_Copy;
const ::HIR::SimplePath& m_lang_Deref;
const ::HIR::SimplePath& m_lang_Drop;
const ::HIR::SimplePath& m_lang_PhantomData;
@@ -28,6 +29,7 @@ public:
m_crate(crate),
m_lang_Unsize( crate.get_lang_item_path_opt("unsize") ),
m_lang_CoerceUnsized( crate.get_lang_item_path_opt("coerce_unsized") ),
+ m_lang_Copy( crate.get_lang_item_path_opt("copy") ),
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") )
@@ -329,15 +331,7 @@ public:
if( impl.m_type.m_data.is_Path() )
{
const auto& te = impl.m_type.m_data.as_Path();
- const ::HIR::TraitMarkings* markings_ptr = nullptr;
- TU_MATCHA( (te.binding), (tpb),
- (Unbound, ),
- (Opaque, ),
- (ExternType, markings_ptr = &tpb->m_markings; ),
- (Struct, markings_ptr = &tpb->m_markings; ),
- (Union , markings_ptr = &tpb->m_markings; ),
- (Enum , markings_ptr = &tpb->m_markings; )
- )
+ const ::HIR::TraitMarkings* markings_ptr = te.binding.get_trait_markings();
if( markings_ptr )
{
::HIR::TraitMarkings& markings = *const_cast<::HIR::TraitMarkings*>(markings_ptr);
@@ -435,6 +429,10 @@ public:
DEBUG("Type " << impl.m_type << " can Deref");
markings.has_a_deref = true;
}
+ else if( trait_path == m_lang_Copy ) {
+ DEBUG("Type " << impl.m_type << " has a Copy impl");
+ markings.is_copy = true;
+ }
// TODO: Marker traits (with conditions)
else {
}