Skip to content

Commit a5f1b08

Browse files
committed
---
yaml --- r: 3032 b: refs/heads/master c: 774c6d0 h: refs/heads/master v: v3
1 parent d368d6b commit a5f1b08

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e5eacf8ea9e59777d6c7d4939d91d2e96dfff838
2+
refs/heads/master: 774c6d01984b608047afedb5d8c579c00d69823f

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5691,11 +5691,11 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output)
56915691
}
56925692

56935693
case (ast::expr_break(?a)) {
5694-
ret trans_break(cx);
5694+
ret trans_break(e.span, cx);
56955695
}
56965696

56975697
case (ast::expr_cont(?a)) {
5698-
ret trans_cont(cx);
5698+
ret trans_cont(e.span, cx);
56995699
}
57005700

57015701
case (ast::expr_ret(?e, _)) {
@@ -5972,7 +5972,7 @@ fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
59725972
ret res(bcx, bcx.build.FastCall(llcallee, llargs));
59735973
}
59745974

5975-
fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
5975+
fn trans_break_cont(&span sp, &@block_ctxt cx, bool to_end) -> result {
59765976
auto bcx = cx;
59775977
// Locate closest loop block, outputting cleanup as we go.
59785978
auto cleanup_cx = cx;
@@ -5998,6 +5998,11 @@ fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
59985998
case (_) {
59995999
alt ({cleanup_cx.parent}) {
60006000
case (parent_some(?cx)) { cleanup_cx = cx; }
6001+
case (parent_none) {
6002+
cx.fcx.lcx.ccx.sess.span_err(sp,
6003+
(if (to_end) { "Break" } else { "Cont" })
6004+
+ " outside a loop");
6005+
}
60016006
}
60026007
}
60036008
}
@@ -6007,12 +6012,12 @@ fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
60076012
cx.fcx.lcx.ccx.sess.bug("in trans::trans_break_cont()");
60086013
}
60096014

6010-
fn trans_break(&@block_ctxt cx) -> result {
6011-
ret trans_break_cont(cx, true);
6015+
fn trans_break(&span sp, &@block_ctxt cx) -> result {
6016+
ret trans_break_cont(sp, cx, true);
60126017
}
60136018

6014-
fn trans_cont(&@block_ctxt cx) -> result {
6015-
ret trans_break_cont(cx, false);
6019+
fn trans_cont(&span sp, &@block_ctxt cx) -> result {
6020+
ret trans_break_cont(sp, cx, false);
60166021
}
60176022

60186023

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// error-pattern:Break outside a loop
2+
fn main() {
3+
auto pth = break;
4+
5+
let rec(str t) res = rec(t=pth);
6+
7+
}

0 commit comments

Comments
 (0)