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 518dc52f85).
This commit is contained in:
Jesse Ruderman 2011-09-09 19:47:40 -07:00
parent ce432d4cf9
commit 8e00161819
2 changed files with 6 additions and 2 deletions

View file

@ -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 }
}
}

View file

@ -31,3 +31,5 @@ fn test10() -> int {
alt true { true { } };
(*regs)[0]
}
fn test11() -> [int] { if true { }; [1, 2] }