summaryrefslogtreecommitdiff
path: root/src/mir/from_hir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r--src/mir/from_hir.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 6727ab4b..0edec1f9 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -975,13 +975,14 @@ namespace {
::std::vector< ::MIR::LValue> vals;
for( const auto cap_idx : node.m_var_captures )
{
+ ASSERT_BUG(node.span(), cap_idx < m_variable_types.size(), "Capture #" << cap_idx << " not in variable set (" << m_variable_types.size() << " total)");
if( node.m_is_move ) {
vals.push_back( ::MIR::LValue::make_Variable(cap_idx) );
}
else {
auto borrow_ty = ::HIR::BorrowType::Shared;
auto lval = m_builder.lvalue_or_temp(
- ::HIR::TypeRef::new_borrow(borrow_ty, m_variable_types.at(cap_idx).clone()),
+ ::HIR::TypeRef::new_borrow(borrow_ty, m_variable_types[cap_idx].clone()),
::MIR::RValue::make_Borrow({ 0, borrow_ty, ::MIR::LValue::make_Variable(cap_idx) })
);
vals.push_back( mv$(lval) );