syntax: match variants use 4 space indent by default

This commit is contained in:
Erick Tryzelaar 2013-04-06 22:29:37 -07:00
parent 11f5f73b2b
commit 74807b1594
3 changed files with 13 additions and 14 deletions

View file

@ -95,7 +95,6 @@ pub fn rust_printer(writer: @io::Writer, intr: @ident_interner) -> @ps {
}
pub static indent_unit: uint = 4u;
pub static match_indent_unit: uint = 2u;
pub static default_columns: uint = 78u;
@ -1227,16 +1226,16 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
print_block(s, blk);
}
ast::expr_match(expr, ref arms) => {
cbox(s, match_indent_unit);
cbox(s, indent_unit);
ibox(s, 4);
word_nbsp(s, ~"match");
print_expr(s, expr);
space(s.s);
bopen(s);
let len = (*arms).len();
for (*arms).eachi |i, arm| {
let len = arms.len();
for arms.eachi |i, arm| {
space(s.s);
cbox(s, match_indent_unit);
cbox(s, indent_unit);
ibox(s, 0u);
let mut first = true;
for arm.pats.each |p| {
@ -1269,7 +1268,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
ast::expr_block(ref blk) => {
// the block will close the pattern's ibox
print_block_unclosed_indent(
s, blk, match_indent_unit);
s, blk, indent_unit);
}
_ => {
end(s); // close the ibox for the pattern
@ -1286,10 +1285,10 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
}
} else {
// the block will close the pattern's ibox
print_block_unclosed_indent(s, &arm.body, match_indent_unit);
print_block_unclosed_indent(s, &arm.body, indent_unit);
}
}
bclose_(s, expr.span, match_indent_unit);
bclose_(s, expr.span, indent_unit);
}
ast::expr_fn_block(ref decl, ref body) => {
// in do/for blocks we don't want to show an empty

View file

@ -17,9 +17,9 @@ fn main() {
let x = Some(3);
let y =
match x {
Some(_) =>
~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very"
+ ~"very" + ~"very" + ~"long" + ~"string",
None => ~"none"
Some(_) =>
~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" +
~"very" + ~"very" + ~"very" + ~"long" + ~"string",
None => ~"none"
};
}

View file

@ -14,7 +14,7 @@ fn main() {
let x = Some(3);
let _y =
match x {
Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
None => ~[~"none"]
Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
None => ~[~"none"]
};
}