diff options
| author | Jesse Ruderman <jruderman@gmail.com> | 2011-09-09 19:47:40 -0700 |
|---|---|---|
| committer | Jesse Ruderman <jruderman@gmail.com> | 2011-09-09 19:47:40 -0700 |
| commit | 8e001618192bbcbe34b8f539ab7d8fa87090700b (patch) | |
| tree | ad71a41fa4417ad24e647a95310007cb9b3867f9 | |
| parent | ce432d4cf913fcfc522c2a9233f8855b1cf77545 (diff) | |
Make the pretty printer disambiguatae blocks followed by vec expressions.
Semicolons are needed here now that postfix [] is used for vec indexing (the syntax change made in rev 518dc52f85c2efb67aaa1208c02e9a7e0bdaca49).
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 6 | ||||
| -rw-r--r-- | src/test/pretty/block-disambig.rs | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 442756a790d..b1b2d8d9129 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -612,8 +612,9 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type, tag expr_or_stmt { stmt_(@ast::stmt); expr_(@ast::expr); } // The Rust syntax has an ambiguity when an if, alt, or block statement is - // followed by a unary op or paren. In those cases we have to add an - // extra semi to make sure the output retains the same meaning. + // followed by a unary op, square bracket, or paren. In those cases we + // have to add an extra semi to make sure the output retains the same + // meaning. fn maybe_protect_block(s: &ps, last: &option::t<@ast::stmt>, next: &expr_or_stmt) { let last_expr_is_block = @@ -684,6 +685,7 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type, alt ex.node { ast::expr_unary(_, _) { true } ast::expr_tup(_) { true } + ast::expr_vec(_, _) { true } _ { false } } } diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 252eb0270da..f5af4b5df57 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -31,3 +31,5 @@ fn test10() -> int { alt true { true { } }; (*regs)[0] } + +fn test11() -> [int] { if true { }; [1, 2] } |
