Skip to content

Commit 6abe5b6

Browse files
committed
---
yaml --- r: 24537 b: refs/heads/try2 c: 0f5eaef h: refs/heads/master i: 24535: 7543aeb v: v3
1 parent a985211 commit 6abe5b6

File tree

22 files changed

+33
-36
lines changed

22 files changed

+33
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3f59a4bc64f46c5f44621327c697c5314b2f4358
8+
refs/heads/try2: 0f5eaef5fb2443acd3ea67250c953839c3d04d38
99
refs/heads/incoming: 05543fd04dfb3f63b453a331e239ceb1a9a219f9
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libsyntax/ast.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,7 @@ type stmt = spanned<stmt_>;
243243
#[auto_serialize]
244244
enum stmt_ {
245245
stmt_decl(@decl, node_id),
246-
247-
// expr without trailing semi-colon (must have unit type):
248246
stmt_expr(@expr, node_id),
249-
250-
// expr with trailing semi-colon (may have any type):
251-
stmt_semi(@expr, node_id),
252247
}
253248

254249
#[auto_serialize]

branches/try2/src/libsyntax/ast_util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pure fn stmt_id(s: stmt) -> node_id {
3838
alt s.node {
3939
stmt_decl(_, id) { id }
4040
stmt_expr(_, id) { id }
41-
stmt_semi(_, id) { id }
4241
}
4342
}
4443

branches/try2/src/libsyntax/ext/auto_serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl helpers for ext_ctxt {
206206
}
207207

208208
fn stmt(expr: @ast::expr) -> @ast::stmt {
209-
@{node: ast::stmt_semi(expr, self.next_id()),
209+
@{node: ast::stmt_expr(expr, self.next_id()),
210210
span: expr.span}
211211
}
212212

branches/try2/src/libsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
315315
ret alt s {
316316
stmt_decl(d, nid) { stmt_decl(fld.fold_decl(d), fld.new_id(nid)) }
317317
stmt_expr(e, nid) { stmt_expr(fld.fold_expr(e), fld.new_id(nid)) }
318-
stmt_semi(e, nid) { stmt_semi(fld.fold_expr(e), fld.new_id(nid)) }
319318
};
320319
}
321320

branches/try2/src/libsyntax/parse/classify.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ fn stmt_ends_with_semi(stmt: ast::stmt) -> bool {
2727
ast::stmt_expr(e, _) {
2828
ret expr_requires_semi_to_be_stmt(e);
2929
}
30-
ast::stmt_semi(e, _) {
31-
ret false;
32-
}
3330
}
3431
}
3532

branches/try2/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ class parser {
18481848
token::SEMI {
18491849
self.bump();
18501850
push(stmts,
1851-
@{node: stmt_semi(e, stmt_id) with *stmt});
1851+
@{node: stmt_expr(e, stmt_id) with *stmt});
18521852
}
18531853
token::RBRACE {
18541854
expr = some(e);

branches/try2/src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,9 @@ fn print_stmt(s: ps, st: ast::stmt) {
682682
ast::stmt_expr(expr, _) {
683683
space_if_not_bol(s);
684684
print_expr(s, expr);
685-
}
686-
ast::stmt_semi(expr, _) {
687-
space_if_not_bol(s);
688-
print_expr(s, expr);
689-
word(s.s, ";");
685+
if expr_requires_semi_to_be_stmt(expr) {
686+
word(s.s, ";");
687+
}
690688
}
691689
}
692690
if parse::classify::stmt_ends_with_semi(st) { word(s.s, ";"); }

branches/try2/src/libsyntax/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
320320
alt s.node {
321321
stmt_decl(d, _) { v.visit_decl(d, e, v); }
322322
stmt_expr(ex, _) { v.visit_expr(ex, e, v); }
323-
stmt_semi(ex, _) { v.visit_expr(ex, e, v); }
324323
}
325324
}
326325

branches/try2/src/rustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn mk_test_wrapper(cx: test_ctxt,
359359
};
360360

361361
let call_stmt: ast::stmt = nospan(
362-
ast::stmt_semi(@call_expr, cx.sess.next_node_id()));
362+
ast::stmt_expr(@call_expr, cx.sess.next_node_id()));
363363

364364
let wrapper_decl: ast::fn_decl = {
365365
inputs: ~[],

branches/try2/src/rustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
229229
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
230230
let stmts_sans_items = do vec::filter(blk.stmts) |stmt| {
231231
alt stmt.node {
232-
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
232+
ast::stmt_expr(_, _) |
233233
ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) { true }
234234
ast::stmt_decl(@{node: ast::decl_item(_), span: _}, _) { false }
235235
}

branches/try2/src/rustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
405405
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
406406
visit_stmt: fn@(s: @ast::stmt) {
407407
alt s.node {
408-
ast::stmt_semi(@{id: id,
408+
ast::stmt_expr(@{id: id,
409409
node: ast::expr_path(@path),
410410
span: _}, _) {
411411
cx.sess.span_lint(

branches/try2/src/rustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class liveness {
843843
ret self.propagate_through_decl(decl, succ);
844844
}
845845

846-
stmt_expr(expr, _) | stmt_semi(expr, _) {
846+
stmt_expr(expr, _) {
847847
ret self.propagate_through_expr(expr, succ);
848848
}
849849
}

branches/try2/src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4131,7 +4131,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
41314131
debuginfo::update_source_pos(cx, s.span);
41324132

41334133
alt s.node {
4134-
ast::stmt_expr(e, _) | ast::stmt_semi(e, _) {
4134+
ast::stmt_expr(e, _) {
41354135
bcx = trans_expr(cx, e, ignore);
41364136
}
41374137
ast::stmt_decl(d, _) {

branches/try2/src/rustc/middle/tstate/annotate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn collect_ids_block(b: blk, rs: @mut ~[node_id]) {
1515

1616
fn collect_ids_stmt(s: @stmt, rs: @mut ~[node_id]) {
1717
alt s.node {
18-
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
18+
stmt_decl(_, id) | stmt_expr(_, id) {
1919
#debug["node_id %s", int::str(id)];
2020
#debug["%s", stmt_to_str(*s)];
2121
vec::push(*rs, id);

branches/try2/src/rustc/middle/tstate/auxiliary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate {
278278
fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann {
279279
#debug("stmt_to_ann");
280280
alt s.node {
281-
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
281+
stmt_decl(_, id) | stmt_expr(_, id) {
282282
ret node_id_to_ts_ann(ccx, id);
283283
}
284284
}

branches/try2/src/rustc/middle/tstate/pre_post_conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
520520
}
521521
}
522522
}
523-
stmt_expr(e, id) | stmt_semi(e, id) {
523+
stmt_expr(e, id) {
524524
find_pre_post_expr(fcx, e);
525525
copy_pre_post(fcx.ccx, id, e);
526526
}

branches/try2/src/rustc/middle/tstate/states.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
537537
}
538538
}
539539
}
540-
stmt_expr(ex, _) | stmt_semi(ex, _) {
540+
stmt_expr(ex, _) {
541541
let mut changed =
542542
find_pre_post_state_expr(fcx, pres, ex) |
543543
set_prestate(stmt_ann, expr_prestate(fcx.ccx, ex)) |

branches/try2/src/rustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
22552255

22562256
fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
22572257
alt s.node {
2258-
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
2258+
ast::stmt_decl(_, id) | stmt_expr(_, id) {
22592259
ret id;
22602260
}
22612261
}

branches/try2/src/rustc/middle/typeck/check.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,10 +1718,6 @@ fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
17181718
}
17191719
}
17201720
ast::stmt_expr(expr, id) {
1721-
node_id = id;
1722-
bot = check_expr_with(fcx, expr, ty::mk_nil(fcx.ccx.tcx));
1723-
}
1724-
ast::stmt_semi(expr, id) {
17251721
node_id = id;
17261722
bot = check_expr(fcx, expr, none);
17271723
}
@@ -1753,7 +1749,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
17531749
if bot && !warned &&
17541750
alt s.node {
17551751
ast::stmt_decl(@{node: ast::decl_local(_), _}, _) |
1756-
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) {
1752+
ast::stmt_expr(_, _) {
17571753
true
17581754
}
17591755
_ { false }

branches/try2/src/test/compile-fail/block-arg-as-stmt-with-value.rs renamed to branches/try2/src/test/run-pass/block-arg-as-stmt-with-value.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
fn compute1() -> float {
33
let v = ~[0f, 1f, 2f, 3f];
44

5+
// This is actually a (block-style) statement followed by
6+
// a unary tail expression
57
do vec::foldl(0f, v) |x, y| { x + y } - 10f
6-
//~^ ERROR mismatched types: expected `()`
78
}
89

910
fn main() {
1011
let x = compute1();
1112
log(debug, x);
12-
assert(x == -4f);
13+
assert(x == -10f);
1314
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn f(f: fn()) -> int {
2+
f(); 0
3+
}
4+
5+
fn main() {
6+
// Testing that the old rule that statements (even control
7+
// structures) that have non-nil type be semi-terminated _no
8+
// longer_ is required
9+
do f {
10+
}
11+
if true { 0 } else { 0 }
12+
let _x = 0;
13+
}

0 commit comments

Comments
 (0)