Skip to content

Commit a7e00a9

Browse files
committed
---
yaml --- r: 7052 b: refs/heads/master c: e1a0d0f h: refs/heads/master v: v3
1 parent c3ab6d5 commit a7e00a9

File tree

4 files changed

+12
-37
lines changed

4 files changed

+12
-37
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: 810927824ce13a56bc80d47a7a71802777dde7d5
2+
refs/heads/master: e1a0d0f03db1bbeb7bb70b48477c97b9cb33240d

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ fn print_stmt(s: ps, st: ast::stmt) {
567567
}
568568
ast::stmt_expr(expr, _) {
569569
space_if_not_bol(s);
570-
print_tl_expr(s, expr);
570+
print_expr(s, expr);
571571
}
572572
ast::stmt_semi(expr, _) {
573573
space_if_not_bol(s);
574-
print_tl_expr(s, expr);
574+
print_expr(s, expr);
575575
word(s.s, ";");
576576
}
577577
}
@@ -609,7 +609,7 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
609609
alt blk.node.expr {
610610
some(expr) {
611611
space_if_not_bol(s);
612-
print_tl_expr(s, expr);
612+
print_expr(s, expr);
613613
maybe_print_trailing_comment(s, expr.span, some(blk.span.hi));
614614
}
615615
_ { }
@@ -697,37 +697,6 @@ fn print_mac(s: ps, m: ast::mac) {
697697
}
698698
}
699699

700-
// An expression that begins with a dual-form statement/expression like `{
701-
// ... }-10` would be parsed as `{ ... };-10` unless parentheses are used (ie,
702-
// `({...}-10)`). These parentheses are not, however, preserved by the
703-
// parser. This function specifies whether parentheses must be inserted.
704-
fn print_tl_expr(s: ps, &&expr: @ast::expr) {
705-
fn stmt_expr_requires_parens(ex: @ast::expr) -> bool {
706-
fn helper(ex: @ast::expr, inner: bool) -> bool {
707-
log(debug, ("helper", ex, inner));
708-
if inner && !parse::parser::expr_requires_semi_to_be_stmt(ex) {
709-
ret true;
710-
}
711-
alt ex.node {
712-
ast::expr_call(subex, _, _) | ast::expr_binary(_, subex, _) {
713-
be helper(subex, true);
714-
}
715-
_ { ret false; }
716-
}
717-
}
718-
ret helper(ex, false);
719-
}
720-
721-
#debug("print_tl_expr %s", expr_to_str(expr));
722-
if stmt_expr_requires_parens(expr) {
723-
popen(s);
724-
print_expr(s, expr);
725-
pclose(s);
726-
} else {
727-
print_expr(s, expr);
728-
}
729-
}
730-
731700
fn print_expr(s: ps, &&expr: @ast::expr) {
732701
maybe_print_comment(s, expr.span.lo);
733702
ibox(s, indent_unit);
@@ -1062,6 +1031,7 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
10621031
ast::expr_copy(_) | ast::expr_assign(_, _) | ast::expr_be(_) |
10631032
ast::expr_assign_op(_, _, _) | ast::expr_swap(_, _) |
10641033
ast::expr_log(_, _, _) | ast::expr_assert(_) |
1034+
ast::expr_call(_, _, true) |
10651035
ast::expr_check(_, _) { true }
10661036
_ { false }
10671037
};
@@ -1404,7 +1374,7 @@ fn need_parens(expr: @ast::expr, outer_prec: int) -> bool {
14041374
ast::expr_assert(_) { true }
14051375
ast::expr_check(_, _) { true }
14061376
ast::expr_log(_, _, _) { true }
1407-
_ { false }
1377+
_ { !parse::parser::expr_requires_semi_to_be_stmt(expr) }
14081378
}
14091379
}
14101380

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn blk1(b: block()) -> fn@() { ret fn@() { }; }
2+
3+
fn test1() { (blk1 {|| #debug["hi"]; })(); }
4+
5+
fn test2() { (blk1 {|| #debug["hi"]; }) {|| #debug["ho"]; }; }

trunk/src/test/pretty/disamb-stmt-expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
// preserved. They are needed to disambiguate `{ret n+1}; - 0` from
55
// `({ret n+1}-0)`.
66

7-
fn wsucc(n: int) -> int { ({ ret n + 1 } - 0); }
7+
fn wsucc(n: int) -> int { ({ ret n + 1 }) - 0; }
88
fn main() { }

0 commit comments

Comments
 (0)