Skip to content

Commit b8880e3

Browse files
committed
Remove be keyword.
Closes rust-lang#2227.
1 parent 452fc46 commit b8880e3

27 files changed

+40
-104
lines changed

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ The keywords in [source files](#source-files) are the following strings:
210210

211211
~~~~~~~~ {.keyword}
212212
alt assert
213-
be break
213+
break
214214
check claim class const cont copy crust
215215
do
216216
else enum export

src/librustsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ enum expr_ {
336336
expr_break,
337337
expr_cont,
338338
expr_ret(option<@expr>),
339-
expr_be(@expr),
340339
expr_log(int, @expr, @expr),
341340

342341
expr_new(/* arena */ @expr,

src/librustsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
488488
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
489489
expr_break | expr_cont { e }
490490
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
491-
expr_be(e) { expr_be(fld.fold_expr(e)) }
492491
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
493492
fld.fold_expr(e)) }
494493
expr_assert(e) { expr_assert(fld.fold_expr(e)) }

src/librustsyntax/parse/classify.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool {
4242
ast::expr_swap(_, _) { true }
4343
ast::expr_assign_op(_, _, _) { true }
4444
ast::expr_ret(_) { true }
45-
ast::expr_be(_) { true }
4645
ast::expr_assert(_) { true }
4746
ast::expr_check(_, _) { true }
4847
ast::expr_log(_, _, _) { true }
@@ -55,7 +54,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
5554
ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i), _}) { true }
5655
ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
5756
ast::expr_move(_, sub) | ast::expr_copy(sub) |
58-
ast::expr_assign(_, sub) | ast::expr_be(sub) |
57+
ast::expr_assign(_, sub) |
5958
ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
6059
ast::expr_log(_, _, sub) | ast::expr_assert(sub) |
6160
ast::expr_check(_, sub) { ends_in_lit_int(sub) }

src/librustsyntax/parse/lexer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn is_bin_digit(c: char) -> bool { ret c == '0' || c == '1'; }
104104

105105
fn consume_whitespace_and_comments(rdr: reader) {
106106
while is_whitespace(rdr.curr) { rdr.bump(); }
107-
be consume_any_line_comment(rdr);
107+
ret consume_any_line_comment(rdr);
108108
}
109109

110110
fn consume_any_line_comment(rdr: reader) {
@@ -114,9 +114,9 @@ fn consume_any_line_comment(rdr: reader) {
114114
while rdr.curr != '\n' && !rdr.is_eof() { rdr.bump(); }
115115
// Restart whitespace munch.
116116

117-
be consume_whitespace_and_comments(rdr);
117+
ret consume_whitespace_and_comments(rdr);
118118
}
119-
'*' { rdr.bump(); rdr.bump(); be consume_block_comment(rdr); }
119+
'*' { rdr.bump(); rdr.bump(); ret consume_block_comment(rdr); }
120120
_ { ret; }
121121
}
122122
}
@@ -140,7 +140,7 @@ fn consume_block_comment(rdr: reader) {
140140
}
141141
// restart whitespace munch.
142142

143-
be consume_whitespace_and_comments(rdr);
143+
ret consume_whitespace_and_comments(rdr);
144144
}
145145

146146
fn scan_exponent(rdr: reader) -> option<str> {

src/librustsyntax/parse/parser.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,6 @@ fn parse_bottom_expr(p: parser) -> pexpr {
825825
} else if eat_keyword(p, "cont") {
826826
ex = expr_cont;
827827
hi = p.span.hi;
828-
} else if eat_keyword(p, "be") {
829-
let e = parse_expr(p);
830-
hi = e.span.hi;
831-
ex = expr_be(e);
832828
} else if eat_keyword(p, "copy") {
833829
let e = parse_expr(p);
834830
ex = expr_copy(e);

src/librustsyntax/print/pprust.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,24 @@ fn print_crate_(s: ps, &&crate: @ast::crate) {
8080
eof(s.s);
8181
}
8282

83-
fn ty_to_str(ty: @ast::ty) -> str { be to_str(ty, print_type); }
83+
fn ty_to_str(ty: @ast::ty) -> str { ret to_str(ty, print_type); }
8484

85-
fn pat_to_str(pat: @ast::pat) -> str { be to_str(pat, print_pat); }
85+
fn pat_to_str(pat: @ast::pat) -> str { ret to_str(pat, print_pat); }
8686

87-
fn expr_to_str(e: @ast::expr) -> str { be to_str(e, print_expr); }
87+
fn expr_to_str(e: @ast::expr) -> str { ret to_str(e, print_expr); }
8888

89-
fn stmt_to_str(s: ast::stmt) -> str { be to_str(s, print_stmt); }
89+
fn stmt_to_str(s: ast::stmt) -> str { ret to_str(s, print_stmt); }
9090

91-
fn item_to_str(i: @ast::item) -> str { be to_str(i, print_item); }
91+
fn item_to_str(i: @ast::item) -> str { ret to_str(i, print_item); }
9292

93-
fn attr_to_str(i: ast::attribute) -> str { be to_str(i, print_attribute); }
93+
fn attr_to_str(i: ast::attribute) -> str { ret to_str(i, print_attribute); }
9494

9595
fn typarams_to_str(tps: [ast::ty_param]) -> str {
96-
be to_str(tps, print_type_params)
96+
ret to_str(tps, print_type_params)
9797
}
9898

9999
fn path_to_str(&&p: @ast::path) -> str {
100-
be to_str(p, bind print_path(_, _, false));
100+
ret to_str(p, bind print_path(_, _, false));
101101
}
102102

103103
fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
@@ -174,11 +174,11 @@ fn meta_item_to_str(mi: ast::meta_item) -> str {
174174
}
175175

176176
fn attribute_to_str(attr: ast::attribute) -> str {
177-
be to_str(attr, print_attribute);
177+
ret to_str(attr, print_attribute);
178178
}
179179

180180
fn variant_to_str(var: ast::variant) -> str {
181-
be to_str(var, print_variant);
181+
ret to_str(var, print_variant);
182182
}
183183

184184
#[test]
@@ -1102,7 +1102,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
11021102
_ { }
11031103
}
11041104
}
1105-
ast::expr_be(result) { word_nbsp(s, "be"); print_expr(s, result); }
11061105
ast::expr_log(lvl, lexp, expr) {
11071106
alt check lvl {
11081107
1 { word_nbsp(s, "log"); print_expr(s, expr); }
@@ -1149,7 +1148,7 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
11491148
ast::expr_fail(_) | ast::expr_ret(_) |
11501149
ast::expr_binary(_, _, _) | ast::expr_unary(_, _) |
11511150
ast::expr_move(_, _) | ast::expr_copy(_) |
1152-
ast::expr_assign(_, _) | ast::expr_be(_) |
1151+
ast::expr_assign(_, _) |
11531152
ast::expr_assign_op(_, _, _) | ast::expr_swap(_, _) |
11541153
ast::expr_log(_, _, _) | ast::expr_assert(_) |
11551154
ast::expr_call(_, _, true) |
@@ -1623,7 +1622,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
16231622
}
16241623
}
16251624

1626-
fn lit_to_str(l: @ast::lit) -> str { be to_str(l, print_literal); }
1625+
fn lit_to_str(l: @ast::lit) -> str { ret to_str(l, print_literal); }
16271626

16281627
fn next_lit(s: ps, pos: uint) -> option<comments::lit> {
16291628
alt s.literals {

src/librustsyntax/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
422422
expr_break { }
423423
expr_cont { }
424424
expr_ret(eo) { visit_expr_opt(eo, e, v); }
425-
expr_be(x) { v.visit_expr(x, e, v); }
426425
expr_log(_, lv, x) {
427426
v.visit_expr(lv, e, v);
428427
v.visit_expr(x, e, v);

src/libstd/ufind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn grow(ufnd: ufind, n: uint) {
2828
fn find(ufnd: ufind, n: uint) -> uint {
2929
alt ufnd.nodes[n] {
3030
none { ret n; }
31-
some(m) { let m_ = m; be find(ufnd, m_); }
31+
some(m) { let m_ = m; ret find(ufnd, m_); }
3232
}
3333
}
3434

src/rustc/middle/borrowck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ impl categorize_methods for borrowck_ctxt {
972972
ast::expr_swap(*) | ast::expr_move(*) | ast::expr_assign(*) |
973973
ast::expr_assign_op(*) | ast::expr_fn(*) | ast::expr_fn_block(*) |
974974
ast::expr_assert(*) | ast::expr_check(*) | ast::expr_ret(*) |
975-
ast::expr_be(*) | ast::expr_loop_body(*) | ast::expr_unary(*) |
975+
ast::expr_loop_body(*) | ast::expr_unary(*) |
976976
ast::expr_copy(*) | ast::expr_cast(*) | ast::expr_fail(*) |
977977
ast::expr_vstore(*) | ast::expr_vec(*) | ast::expr_tup(*) |
978978
ast::expr_if_check(*) | ast::expr_if(*) | ast::expr_log(*) |

src/rustc/middle/check_loop.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
4444
}
4545
visit::visit_expr_opt(oe, cx, v);
4646
}
47-
expr_be(re) {
48-
if !cx.can_ret {
49-
tcx.sess.span_err(e.span, "`be` in block function");
50-
}
51-
v.visit_expr(re, cx, v);
52-
}
5347
_ { visit::visit_expr(e, cx, v); }
5448
}
5549
}

src/rustc/middle/trans/base.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,9 +3267,6 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
32673267
assert dest == ignore;
32683268
ret trans_ret(bcx, ex);
32693269
}
3270-
ast::expr_be(ex) {
3271-
ret trans_be(bcx, ex);
3272-
}
32733270
ast::expr_fail(expr) {
32743271
assert dest == ignore;
32753272
ret trans_fail_expr(bcx, some(e.span), expr);
@@ -3641,13 +3638,6 @@ fn build_return(bcx: block) {
36413638
Br(bcx, bcx.fcx.llreturn);
36423639
}
36433640

3644-
fn trans_be(cx: block, e: @ast::expr) -> block {
3645-
// FIXME: Turn this into a real tail call once
3646-
// calling convention issues are settled
3647-
let _icx = cx.insn_ctxt("trans_be");
3648-
ret trans_ret(cx, some(e));
3649-
}
3650-
36513641
fn init_local(bcx: block, local: @ast::local) -> block {
36523642
let _icx = bcx.insn_ctxt("init_local");
36533643
let ty = node_id_type(bcx, local.node.id);

src/rustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
172172
}
173173
}
174174
expr_assign(val, _) | expr_swap(val, _) | expr_assign_op(_, val, _) |
175-
expr_ret(some(val)) | expr_be(val) {
175+
expr_ret(some(val)) {
176176
node_type_needs(cx, use_repr, val.id);
177177
}
178178
expr_index(base, _) | expr_field(base, _, _) {

src/rustc/middle/tstate/ann.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ type pre_and_post_state = {prestate: prestate, poststate: poststate};
4141

4242
type ts_ann = @{conditions: pre_and_post, states: pre_and_post_state};
4343

44-
fn true_precond(num_vars: uint) -> precond { be create_tritv(num_vars); }
44+
fn true_precond(num_vars: uint) -> precond { ret create_tritv(num_vars); }
4545

46-
fn true_postcond(num_vars: uint) -> postcond { be true_precond(num_vars); }
46+
fn true_postcond(num_vars: uint) -> postcond { ret true_precond(num_vars); }
4747

48-
fn empty_prestate(num_vars: uint) -> prestate { be true_precond(num_vars); }
48+
fn empty_prestate(num_vars: uint) -> prestate { ret true_precond(num_vars); }
4949

50-
fn empty_poststate(num_vars: uint) -> poststate { be true_precond(num_vars); }
50+
fn empty_poststate(num_vars: uint) -> poststate {
51+
ret true_precond(num_vars);
52+
}
5153

5254
fn false_postcond(num_vars: uint) -> postcond {
5355
let rslt = create_tritv(num_vars);

src/rustc/middle/tstate/pre_post_conditions.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,6 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
391391
}
392392
}
393393
}
394-
expr_be(val) {
395-
find_pre_post_expr(fcx, val);
396-
set_pre_and_post(fcx.ccx, e.id, expr_prestate(fcx.ccx, val),
397-
false_postcond(num_local_vars));
398-
}
399394
expr_if(antec, conseq, maybe_alt) {
400395
join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if);
401396
}

src/rustc/middle/tstate/states.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
483483
}
484484
ret changed;
485485
}
486-
expr_be(val) {
487-
let mut changed = set_prestate_ann(fcx.ccx, e.id, pres);
488-
let post = false_postcond(num_constrs);
489-
// except for the "diverges" bit...
490-
kill_poststate_(fcx, fcx.enclosing.i_diverge, post);
491-
set_poststate_ann(fcx.ccx, e.id, post);
492-
ret changed | find_pre_post_state_expr(fcx, pres, val);
493-
}
494486
expr_if(antec, conseq, maybe_alt) {
495487
ret join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if,
496488
pres);

src/rustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
14561456
ty_box(mt) |
14571457
ty_uniq(mt) |
14581458
ty_rptr(_, mt) {
1459-
be type_requires(cx, seen, r_ty, mt.ty);
1459+
ret type_requires(cx, seen, r_ty, mt.ty);
14601460
}
14611461

14621462
ty_ptr(mt) {

src/rustc/middle/typeck.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,15 +3364,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
33643364
}
33653365
fcx.write_bot(id);
33663366
}
3367-
ast::expr_be(e) {
3368-
if !ast_util::is_call_expr(e) {
3369-
tcx.sess.span_err(expr.span,
3370-
"non-call expression in tail call");
3371-
}
3372-
check_expr_with(fcx, e, fcx.ret_ty);
3373-
bot = true;
3374-
fcx.write_nil(id);
3375-
}
33763367
ast::expr_log(_, lv, e) {
33773368
bot = check_expr_with(fcx, lv, ty::mk_mach_uint(tcx, ast::ty_u32));
33783369
// Note: this does not always execute, so do not propagate bot:

src/test/bench/99bob-tail.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ fn main() {
1212
#debug("Take one down and pass it around, %d \
1313
bottles of beer on the wall.", n-1);
1414
#debug("");
15-
if n > 3 { be multiple(n - 1); } else { be dual(); }
15+
if n > 3 { ret multiple(n - 1); } else { ret dual(); }
1616
}
1717
fn dual() {
1818
#debug("2 bottles of beer on the wall, 2 bottles of beer,");
1919
#debug("Take one down and pass it around, \
2020
1 bottle of beer on the wall.");
2121
#debug("");
22-
be single();
22+
ret single();
2323
}
2424
fn single() {
2525
#debug("1 bottle of beer on the wall, 1 bottle of beer,");
2626
#debug("Take one down and pass it around, \
2727
no more bottles of beer on the wall.");
2828
#debug("");
29-
be none();
29+
ret none();
3030
}
3131
fn none() {
3232
#debug("No more bottles of beer on the wall, \

src/test/bench/shootout-fasta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn select_random(r: u32, genelist: [aminoacids]) -> char {
3535
if hi > lo + 1u {
3636
let mid: uint = lo + (hi - lo) / 2u;
3737
if target < v[mid].prob {
38-
be bisect(v, lo, mid, target);
39-
} else { be bisect(v, mid, hi, target); }
38+
ret bisect(v, lo, mid, target);
39+
} else { ret bisect(v, mid, hi, target); }
4040
} else { ret v[hi].ch; }
4141
}
4242
ret bisect(genelist, 0u, vec::len::<aminoacids>(genelist) - 1u, r);

src/test/compile-fail/dead-code-be.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/test/compile-fail/forgot-ret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -*- rust -*-
22
// error-pattern: not all control paths return a value
33

4-
fn god_exists(a: int) -> bool { be god_exists(a); }
4+
fn god_exists(a: int) -> bool { ret god_exists(a); }
55

66
fn f(a: int) -> int { if god_exists(a) { ret 5; }; }
77

src/test/compile-fail/tail-non-call.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/compile-fail/tail-typeck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// error-pattern: mismatched types
22

3-
fn f() -> int { be g(); }
3+
fn f() -> int { ret g(); }
44

55
fn g() -> uint { ret 0u; }
66

src/test/run-pass/tail-call-arg-leak.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33

44
// use of tail calls causes arg slot leaks, issue #160.
5-
fn inner(dummy: str, b: bool) { if b { be inner(dummy, false); } }
5+
fn inner(dummy: str, b: bool) { if b { ret inner(dummy, false); } }
66

77
fn main() { inner("hi", true); }

src/test/run-pass/tail-cps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
99
fn evenk(n: int, k: native fn(bool) -> bool) -> bool {
1010
#debug("evenk");
1111
log(debug, n);
12-
if n == 0 { be k(true); } else { be oddk(n - 1, k); }
12+
if n == 0 { ret k(true); } else { ret oddk(n - 1, k); }
1313
}
1414

1515
fn oddk(n: int, k: native fn(bool) -> bool) -> bool {
1616
#debug("oddk");
1717
log(debug, n);
18-
if n == 0 { be k(false); } else { be evenk(n - 1, k); }
18+
if n == 0 { ret k(false); } else { ret evenk(n - 1, k); }
1919
}

0 commit comments

Comments
 (0)