aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-05 15:30:21 +0200
committerMarijn Haverbeke <[email protected]>2011-05-05 20:19:43 +0200
commit3d738e9e0634a4cd6239d1317bd7dad53be68dc8 (patch)
treeb3757c980217884882ef803e484540e9806b6d83 /src/comp
parentEradicate fold from capture.rs (diff)
downloadrust-3d738e9e0634a4cd6239d1317bd7dad53be68dc8.tar.xz
rust-3d738e9e0634a4cd6239d1317bd7dad53be68dc8.zip
Return a fresh, unreachable context after ret, break, and cont
This ensures we don't get compile errors on unreachable code (see test/run-pass/artificial-block.rs for an example of sane code that wasn't compiling). In the future, we might want to warn about non-trivial code appearing in an unreachable context, and/or avoid generating unreachable code altogether (though I'm sure LLVM will weed it out as well).
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index b479efef..0790cf19 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -5488,7 +5488,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
}
}
}
- ret res(bcx, C_nil());
+ ret res(new_sub_block_ctxt(bcx, "unreachable"), C_nil());
}
case (_) {
alt (cleanup_cx.parent) {
@@ -5544,7 +5544,7 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
}
bcx.build.RetVoid();
- ret res(bcx, C_nil());
+ ret res(new_sub_block_ctxt(bcx, "unreachable"), C_nil());
}
fn trans_be(@block_ctxt cx, @ast.expr e) -> result {