Skip to content

Pretty printing brackets on match arms #3194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ fn print_block_unclosed(s: ps, blk: ast::blk) {
false);
}

fn print_block_unclosed_indent(s: ps, blk: ast::blk, indented: uint) {
print_possibly_embedded_block_(s, blk, block_normal, indented, ~[],
false);
}

fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: ~[ast::attribute]) {
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs,
true);
Expand Down Expand Up @@ -1178,8 +1183,16 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
assert arm.body.node.rules == ast::default_blk;
match arm.body.node.expr {
some(expr) => {
end(s); // close the ibox for the pattern
print_expr(s, expr);
match expr.node {
ast::expr_block(blk) => {
// the block will close the pattern's ibox
print_block_unclosed_indent(s, blk, alt_indent_unit);
}
_ => {
end(s); // close the ibox for the pattern
print_expr(s, expr);
}
}
if !expr_is_simple_block(expr)
&& i < len - 1 {
word(s.s, ~",");
Expand Down