Skip to content

Commit ceac155

Browse files
committed
For #2229, recognize 'again' in place of 'cont', final change pending snapshot.
1 parent e20f63d commit ceac155

File tree

19 files changed

+34
-34
lines changed

19 files changed

+34
-34
lines changed

doc/rust.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ import export use mod
209209
The keywords in [source files](#source-files) are the following strings:
210210

211211
~~~~~~~~ {.keyword}
212-
alt assert
212+
alt again assert
213213
break
214-
check claim class const cont copy
214+
check claim class const copy
215215
drop
216216
else enum export extern
217217
fail false fn for
@@ -2034,19 +2034,19 @@ break_expr : "break" ;
20342034
Executing a `break` expression immediately terminates the innermost loop
20352035
enclosing it. It is only permitted in the body of a loop.
20362036

2037-
### Continue expressions
2037+
### Again expressions
20382038

20392039
~~~~~~~~{.ebnf .gram}
2040-
break_expr : "cont" ;
2040+
again_expr : "again" ;
20412041
~~~~~~~~
20422042

2043-
Evaluating a `cont` expression immediately terminates the current iteration of
2043+
Evaluating an `again` expression immediately terminates the current iteration of
20442044
the innermost loop enclosing it, returning control to the loop *head*. In the
20452045
case of a `while` loop, the head is the conditional expression controlling the
2046-
loop. In the case of a `for` loop, the head is the vector-element increment
2047-
controlling the loop.
2046+
loop. In the case of a `for` loop, the head is the call-expression controlling
2047+
the loop.
20482048

2049-
A `cont` expression is only permitted in the body of a loop.
2049+
An `again` expression is only permitted in the body of a loop.
20502050

20512051

20522052
### For expressions

doc/tutorial.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ a specific value, are not allowed.
783783
784784
`while` produces a loop that runs as long as its given condition
785785
(which must have type `bool`) evaluates to true. Inside a loop, the
786-
keyword `break` can be used to abort the loop, and `cont` can be used
786+
keyword `break` can be used to abort the loop, and `again` can be used
787787
to abort the current iteration and continue with the next.
788788
789789
~~~~
@@ -1187,7 +1187,7 @@ Empty argument lists can be omitted from `do` expressions.
11871187
11881188
Most iteration in Rust is done with `for` loops. Like `do`,
11891189
`for` is a nice syntax for doing control flow with closures.
1190-
Additionally, within a `for` loop, `break, `cont`, and `ret`
1190+
Additionally, within a `for` loop, `break, `again`, and `ret`
11911191
work just as they do with `while` and `loop`.
11921192
11931193
Consider again our `each` function, this time improved to
@@ -1221,8 +1221,8 @@ each(~[2, 4, 8, 5, 16], |n| {
12211221
With `for`, functions like `each` can be treated more
12221222
like builtin looping structures. When calling `each`
12231223
in a `for` loop, instead of returning `false` to break
1224-
out of the loop, you just write `break`. To continue
1225-
to the next iteration, write `cont`.
1224+
out of the loop, you just write `break`. To skip ahead
1225+
to the next iteration, write `again`.
12261226
12271227
~~~~
12281228
# import each = vec::each;

src/etc/emacs/rust-mode.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
"trait" "fn" "enum" "iface"
5757
"impl"))
5858
(puthash word 'def table))
59-
(dolist (word '("assert"
59+
(dolist (word '("again" "assert"
6060
"break"
61-
"check" "claim" "cont" "copy"
61+
"check" "claim" "copy"
6262
"do" "drop"
6363
"else" "export" "extern"
6464
"fail" "for"

src/fuzzer/fuzzer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn common_exprs() -> ~[ast::expr] {
4242
}
4343

4444
~[dse(ast::expr_break),
45-
dse(ast::expr_cont),
45+
dse(ast::expr_again),
4646
dse(ast::expr_fail(option::none)),
4747
dse(ast::expr_fail(option::some(
4848
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),

src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ enum expr_ {
336336
expr_addr_of(mutability, @expr),
337337
expr_fail(option<@expr>),
338338
expr_break,
339-
expr_cont,
339+
expr_again,
340340
expr_ret(option<@expr>),
341341
expr_log(int, @expr, @expr),
342342

src/libsyntax/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
464464
}
465465
expr_path(pth) { expr_path(fld.fold_path(pth)) }
466466
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
467-
expr_break | expr_cont { copy e }
467+
expr_break | expr_again { copy e }
468468
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
469469
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
470470
fld.fold_expr(e)) }

src/libsyntax/parse/parser.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,9 @@ class parser {
966966
} else if self.eat_keyword("break") {
967967
ex = expr_break;
968968
hi = self.span.hi;
969-
} else if self.eat_keyword("cont") {
970-
ex = expr_cont;
969+
} else if self.eat_keyword("cont") ||
970+
self.eat_keyword("again") {
971+
ex = expr_again;
971972
hi = self.span.hi;
972973
} else if self.eat_keyword("copy") {
973974
let e = self.parse_expr();

src/libsyntax/parse/token.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ fn contextual_keyword_table() -> hashmap<str, ()> {
304304
fn restricted_keyword_table() -> hashmap<str, ()> {
305305
let words = str_hash();
306306
let keys = ~[
307-
"alt",
308-
"assert",
307+
"alt", "again", "assert",
309308
"break",
310309
"check", "claim", "class", "const", "cont", "copy",
311310
"do", "drop",

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
10631063
}
10641064
}
10651065
ast::expr_break { word(s.s, "break"); }
1066-
ast::expr_cont { word(s.s, "cont"); }
1066+
ast::expr_again { word(s.s, "again"); }
10671067
ast::expr_ret(result) {
10681068
word(s.s, "ret");
10691069
alt result {

src/libsyntax/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
421421
expr_path(p) { visit_path(p, e, v); }
422422
expr_fail(eo) { visit_expr_opt(eo, e, v); }
423423
expr_break { }
424-
expr_cont { }
424+
expr_again { }
425425
expr_ret(eo) { visit_expr_opt(eo, e, v); }
426426
expr_log(_, lv, x) {
427427
v.visit_expr(lv, e, v);

src/rustc/middle/borrowck/categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl public_methods for borrowck_ctxt {
176176
ast::expr_new(*) | ast::expr_binary(*) | ast::expr_while(*) |
177177
ast::expr_block(*) | ast::expr_loop(*) | ast::expr_alt(*) |
178178
ast::expr_lit(*) | ast::expr_break | ast::expr_mac(*) |
179-
ast::expr_cont | ast::expr_rec(*) {
179+
ast::expr_again | ast::expr_rec(*) {
180180
ret self.cat_rvalue(expr, expr_ty);
181181
}
182182
}

src/rustc/middle/check_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
3333
tcx.sess.span_err(e.span, "`break` outside of loop");
3434
}
3535
}
36-
expr_cont {
36+
expr_again {
3737
if !cx.in_loop {
3838
tcx.sess.span_err(e.span, "`cont` outside of loop");
3939
}

src/rustc/middle/liveness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) {
470470
expr_assert(*) | expr_check(*) | expr_addr_of(*) | expr_copy(*) |
471471
expr_loop_body(*) | expr_do_body(*) | expr_cast(*) |
472472
expr_unary(*) | expr_fail(*) |
473-
expr_break | expr_cont | expr_lit(_) | expr_ret(*) |
473+
expr_break | expr_again | expr_lit(_) | expr_ret(*) |
474474
expr_block(*) | expr_move(*) | expr_assign(*) | expr_swap(*) |
475475
expr_assign_op(*) | expr_mac(*) {
476476
visit::visit_expr(expr, self, vt);
@@ -1009,7 +1009,7 @@ class liveness {
10091009
self.break_ln
10101010
}
10111011

1012-
expr_cont {
1012+
expr_again {
10131013
if !self.cont_ln.is_valid() {
10141014
self.tcx.sess.span_bug(
10151015
expr.span, "cont with invalid cont_ln");
@@ -1457,7 +1457,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
14571457
expr_assert(*) | expr_check(*) | expr_copy(*) |
14581458
expr_loop_body(*) | expr_do_body(*) |
14591459
expr_cast(*) | expr_unary(*) | expr_fail(*) |
1460-
expr_ret(*) | expr_break | expr_cont | expr_lit(_) |
1460+
expr_ret(*) | expr_break | expr_again | expr_lit(_) |
14611461
expr_block(*) | expr_swap(*) | expr_mac(*) | expr_addr_of(*) {
14621462
visit::visit_expr(expr, self, vt);
14631463
}

src/rustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3644,7 +3644,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
36443644
assert dest == ignore;
36453645
ret trans_break(bcx);
36463646
}
3647-
ast::expr_cont {
3647+
ast::expr_again {
36483648
assert dest == ignore;
36493649
ret trans_cont(bcx);
36503650
}

src/rustc/middle/trans/type_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
242242
})
243243
}
244244
expr_alt(_, _, _) | expr_block(_) | expr_if(_, _, _) |
245-
expr_while(_, _) | expr_fail(_) | expr_break | expr_cont |
245+
expr_while(_, _) | expr_fail(_) | expr_break | expr_again |
246246
expr_unary(_, _) | expr_lit(_) | expr_assert(_) | expr_check(_, _) |
247247
expr_if_check(_, _, _) | expr_mac(_) | expr_addr_of(_, _) |
248248
expr_ret(_) | expr_loop(_) |

src/rustc/middle/tstate/pre_post_conditions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
446446
join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check);
447447
}
448448
expr_break { clear_pp(expr_pp(fcx.ccx, e)); }
449-
expr_cont { clear_pp(expr_pp(fcx.ccx, e)); }
449+
expr_again { clear_pp(expr_pp(fcx.ccx, e)); }
450450
expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); }
451451
}
452452
}

src/rustc/middle/tstate/states.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
498498
ret join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check, pres);
499499
}
500500
expr_break { ret pure_exp(fcx.ccx, e.id, pres); }
501-
expr_cont { ret pure_exp(fcx.ccx, e.id, pres); }
501+
expr_again { ret pure_exp(fcx.ccx, e.id, pres); }
502502
}
503503
}
504504

src/rustc/middle/typeck/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
12201220
fcx.write_bot(id);
12211221
}
12221222
ast::expr_break { fcx.write_bot(id); bot = true; }
1223-
ast::expr_cont { fcx.write_bot(id); bot = true; }
1223+
ast::expr_again { fcx.write_bot(id); bot = true; }
12241224
ast::expr_ret(expr_opt) {
12251225
bot = true;
12261226
let ret_ty = alt fcx.indirect_ret_ty {

src/rustc/util/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
5757

5858
fn has_nonlocal_exits(b: ast::blk) -> bool {
5959
do loop_query(b) |e| { alt e {
60-
ast::expr_break | ast::expr_cont { true }
60+
ast::expr_break | ast::expr_again { true }
6161
_ { false }}}
6262
}
6363

0 commit comments

Comments
 (0)