Skip to content

Commit b4bd0a7

Browse files
committed
---
yaml --- r: 24540 b: refs/heads/try2 c: ae6ea06 h: refs/heads/master v: v3
1 parent 5cc3b4c commit b4bd0a7

File tree

22 files changed

+36
-33
lines changed

22 files changed

+36
-33
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: e000d1db0ab047b8d2949de4ab221718905ce3b1
8+
refs/heads/try2: ae6ea068a12877742247b848ceeaa39c41e981c6
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,12 @@ 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):
246248
stmt_expr(@expr, node_id),
249+
250+
// expr with trailing semi-colon (may have any type):
251+
stmt_semi(@expr, node_id),
247252
}
248253

249254
#[auto_serialize]

branches/try2/src/libsyntax/ast_util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ 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 }
4142
}
4243
}
4344

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_expr(expr, self.next_id()),
209+
@{node: ast::stmt_semi(expr, self.next_id()),
210210
span: expr.span}
211211
}
212212

branches/try2/src/libsyntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ 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)) }
318319
};
319320
}
320321

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ 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+
}
3033
}
3134
}
3235

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_expr(e, stmt_id) with *stmt});
1851+
@{node: stmt_semi(e, stmt_id) with *stmt});
18521852
}
18531853
token::RBRACE {
18541854
expr = some(e);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,11 @@ 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-
if expr_requires_semi_to_be_stmt(expr) {
686-
word(s.s, ";");
687-
}
685+
}
686+
ast::stmt_semi(expr, _) {
687+
space_if_not_bol(s);
688+
print_expr(s, expr);
689+
word(s.s, ";");
688690
}
689691
}
690692
if parse::classify::stmt_ends_with_semi(st) { word(s.s, ";"); }

branches/try2/src/libsyntax/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ 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); }
323324
}
324325
}
325326

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_expr(@call_expr, cx.sess.next_node_id()));
362+
ast::stmt_semi(@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(_, _) |
232+
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
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_expr(@{id: id,
408+
ast::stmt_semi(@{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, _) {
846+
stmt_expr(expr, _) | stmt_semi(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, _) {
4134+
ast::stmt_expr(e, _) | ast::stmt_semi(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) {
18+
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, 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) {
281+
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, 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) {
523+
stmt_expr(e, id) | stmt_semi(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, _) {
540+
stmt_expr(ex, _) | stmt_semi(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) {
2258+
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
22592259
ret id;
22602260
}
22612261
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,10 @@ 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) {
17211725
node_id = id;
17221726
bot = check_expr(fcx, expr, none);
17231727
}
@@ -1749,7 +1753,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
17491753
if bot && !warned &&
17501754
alt s.node {
17511755
ast::stmt_decl(@{node: ast::decl_local(_), _}, _) |
1752-
ast::stmt_expr(_, _) {
1756+
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) {
17531757
true
17541758
}
17551759
_ { false }

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
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
75
do vec::foldl(0f, v) |x, y| { x + y } - 10f
6+
//~^ ERROR mismatched types: expected `()`
87
}
98

109
fn main() {
1110
let x = compute1();
1211
log(debug, x);
13-
assert(x == -10f);
12+
assert(x == -4f);
1413
}

branches/try2/src/test/run-pass/typed-statements-dont-need-semis.rs

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

0 commit comments

Comments
 (0)