From 3db52a81d3891ff7030d622fd2f364cafa29c278 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 26 Nov 2016 10:51:11 +0800 Subject: HIR Annotate - Fix annotation on CallValue arguments --- src/hir_expand/annotate_value_usage.cpp | 7 +++++-- src/hir_expand/closures.cpp | 2 ++ src/mir/mir_builder.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/hir_expand/annotate_value_usage.cpp b/src/hir_expand/annotate_value_usage.cpp index 08c35492..2634920e 100644 --- a/src/hir_expand/annotate_value_usage.cpp +++ b/src/hir_expand/annotate_value_usage.cpp @@ -302,9 +302,12 @@ namespace { vu = ::HIR::ValueUsage::Move; break; } - auto _ = push_usage( vu ); + { + auto _ = push_usage( vu ); + this->visit_node_ptr(node.m_value); + } - this->visit_node_ptr(node.m_value); + auto _ = push_usage( ::HIR::ValueUsage::Move ); for( auto& val : node.m_args ) this->visit_node_ptr(val); } diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp index 9ffcf4de..86811a5e 100644 --- a/src/hir_expand/closures.cpp +++ b/src/hir_expand/closures.cpp @@ -453,6 +453,7 @@ namespace { // --- Apply the capture set for this closure to the parent --- if( m_closure_stack.size() > 0 ) { + DEBUG("> Apply to parent"); for(const auto& cap : ent.captured_vars) { mark_used_variable(node.span(), cap.first, cap.second); @@ -784,6 +785,7 @@ namespace { { if( !m_closure_stack.empty() ) { + TRACE_FUNCTION_F("_CallValue"); if( node.m_trait_used == ::HIR::ExprNode_CallValue::TraitUsed::Unknown ) { if( node.m_res_type.m_data.is_Closure() ) diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index 9c241339..202daac0 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -1113,7 +1113,7 @@ void MirBuilder::moved_lvalue(const Span& sp, const ::MIR::LValue& lv) return ; } } - BUG(sp, "Move out of deref with non-Copy values - &move? - " << lv); + BUG(sp, "Move out of deref with non-Copy values - &move? - " << lv << " : " << FMT_CB(ss, this->with_val_type(sp, lv, [&](const auto& ty){ss<