summaryrefslogtreecommitdiff
path: root/src/mir/from_hir_match.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-07-02 18:34:34 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-07-02 18:34:34 +0800
commitb7bb1f4f9c918e128f7ad83476790830c3f98c4d (patch)
treea48a989aff0bef394dd389089f9274f76dfc4649 /src/mir/from_hir_match.cpp
parent11d2a7732c5d1c53aee384b2ca4fdc672c2cc1ae (diff)
downloadmrust-b7bb1f4f9c918e128f7ad83476790830c3f98c4d.tar.gz
MIR Gen - Make mutating state (other than the if condition) within a match guard an error
Diffstat (limited to 'src/mir/from_hir_match.cpp')
-rw-r--r--src/mir/from_hir_match.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index cbb39b34..c10f170b 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -372,17 +372,18 @@ void MIR_LowerHIR_Match( MirBuilder& builder, MirConverter& conv, ::HIR::ExprNod
ac.cond_start = builder.new_bb_unlinked();
builder.set_cur_block( ac.cond_start );
+ auto freeze_scope = builder.new_scope_freeze(arm.m_cond->span());
auto tmp_scope = builder.new_scope_temp(arm.m_cond->span());
conv.visit_node_ptr( arm.m_cond );
auto cond_lval = builder.get_result_in_if_cond(arm.m_cond->span());
builder.terminate_scope( arm.m_code->span(), mv$(tmp_scope) );
ac.cond_false = builder.new_bb_unlinked();
builder.end_block(::MIR::Terminator::make_If({ mv$(cond_lval), ac.code, ac.cond_false }));
- // TODO: Emit the `if` (to new blocks) and insert an early termination of the this split arm
builder.set_cur_block(ac.cond_false);
builder.end_split_arm(arm.m_cond->span(), match_scope, true, true);
builder.pause_cur_block();
+ builder.terminate_scope( arm.m_code->span(), mv$(freeze_scope) );
// NOTE: Paused so that later code (which knows what the false branch will be) can end it correctly