提交 8e001618 编写于 作者: J Jesse Ruderman

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 518dc52f).
上级 ce432d4c
......@@ -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 expr_is_ambig(ex: @ast::expr) -> bool {
alt ex.node {
ast::expr_unary(_, _) { true }
ast::expr_tup(_) { true }
ast::expr_vec(_, _) { true }
_ { false }
}
}
......
......@@ -31,3 +31,5 @@ fn test10() -> int {
alt true { true { } };
(*regs)[0]
}
fn test11() -> [int] { if true { }; [1, 2] }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册