Skip to content

Commit b46017b

Browse files
committed
---
yaml --- r: 5303 b: refs/heads/master c: 8c83ea5 h: refs/heads/master i: 5301: 3f3b9b5 5299: 828606e 5295: 112b79f v: v3
1 parent 27f680d commit b46017b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d0d322ac9378ddda52a1c7112cd6809f1bbffa6e
2+
refs/heads/master: 8c83ea564bb7da5300c2e39afc87fcffb1e1d252

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

+21-5
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,10 @@ fn print_expr(s: ps, expr: @ast::expr) {
882882
}
883883
ast::expr_field(expr, id) {
884884
// Deal with '10.x'
885-
alt expr.node {
886-
ast::expr_lit(@{node: ast::lit_int(_), _}) {
885+
if ends_in_lit_int(expr) {
887886
popen(s); print_expr(s, expr); pclose(s);
888-
}
889-
_ {
887+
} else {
890888
print_expr_parens_if_unary_or_ret(s, expr);
891-
}
892889
}
893890
word(s.s, ".");
894891
word(s.s, id);
@@ -1638,6 +1635,25 @@ fn ast_ty_constrs_str(constrs: [@ast::ty_constr]) -> str {
16381635
ret s;
16391636
}
16401637

1638+
fn ends_in_lit_int(ex: @ast::expr) -> bool {
1639+
alt ex.node {
1640+
ast::expr_lit(@{node: ast::lit_int(_), _}) { true }
1641+
ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
1642+
ast::expr_ternary(_, _, sub) | ast::expr_move(_, sub) |
1643+
ast::expr_copy(sub) | ast::expr_assign(_, sub) | ast::expr_be(sub) |
1644+
ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
1645+
ast::expr_log(_, sub) | ast::expr_assert(sub) | ast::expr_uniq(sub) |
1646+
ast::expr_check(_, sub) { ends_in_lit_int(sub) }
1647+
ast::expr_fail(osub) | ast::expr_ret(osub) | ast::expr_put(osub) {
1648+
alt osub {
1649+
some(ex) { ends_in_lit_int(ex) }
1650+
_ { false }
1651+
}
1652+
}
1653+
_ { false }
1654+
}
1655+
}
1656+
16411657
//
16421658
// Local Variables:
16431659
// mode: rust

0 commit comments

Comments
 (0)