diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-23 17:32:29 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-23 17:32:29 +0800 |
commit | c2aedab7b60ca3e6c293b7d022897aee0661db21 (patch) | |
tree | c8de400dc1a7d30726d7e7f56c63ac82416a3775 /src/hir_expand/annotate_value_usage.cpp | |
parent | 6cf05070d793f95e051046f0a301f6e006bebb50 (diff) | |
download | mrust-c2aedab7b60ca3e6c293b7d022897aee0661db21.tar.gz |
HIR Typecheck - Require span for type_is_copy
Diffstat (limited to 'src/hir_expand/annotate_value_usage.cpp')
-rw-r--r-- | src/hir_expand/annotate_value_usage.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/hir_expand/annotate_value_usage.cpp b/src/hir_expand/annotate_value_usage.cpp index 0d8bf891..139814ef 100644 --- a/src/hir_expand/annotate_value_usage.cpp +++ b/src/hir_expand/annotate_value_usage.cpp @@ -215,7 +215,7 @@ namespace { void visit(::HIR::ExprNode_Index& node) override { // TODO: Override to ::Borrow if Res: Copy and moving - if( this->get_usage() == ::HIR::ValueUsage::Move && type_is_copy(node.m_res_type) ) { + if( this->get_usage() == ::HIR::ValueUsage::Move && m_resolve.type_is_copy(node.span(), node.m_res_type) ) { auto _ = push_usage( ::HIR::ValueUsage::Borrow ); this->visit_node_ptr(node.m_value); } @@ -228,7 +228,7 @@ namespace { } void visit(::HIR::ExprNode_Deref& node) override { - if( this->get_usage() == ::HIR::ValueUsage::Move && type_is_copy(node.m_res_type) ) { + if( this->get_usage() == ::HIR::ValueUsage::Move && m_resolve.type_is_copy(node.span(), node.m_res_type) ) { auto _ = push_usage( ::HIR::ValueUsage::Borrow ); this->visit_node_ptr(node.m_value); } @@ -240,7 +240,7 @@ namespace { void visit(::HIR::ExprNode_Field& node) override { // If taking this field by value, but the type is Copy - pretend it's a borrow. - if( this->get_usage() == ::HIR::ValueUsage::Move && type_is_copy(node.m_res_type) ) { + if( this->get_usage() == ::HIR::ValueUsage::Move && m_resolve.type_is_copy(node.span(), node.m_res_type) ) { auto _ = push_usage( ::HIR::ValueUsage::Borrow ); this->visit_node_ptr(node.m_value); } @@ -336,11 +336,6 @@ namespace { // TODO: Detect if a by-value binding exists for a non-Copy type return ::HIR::ValueUsage::Move; } - - bool type_is_copy(const ::HIR::TypeRef& ty) const - { - return m_resolve.type_is_copy(ty); - } }; |