syntax: match variants use 4 space indent by default
This commit is contained in:
parent
11f5f73b2b
commit
74807b1594
3 changed files with 13 additions and 14 deletions
|
@ -95,7 +95,6 @@ pub fn rust_printer(writer: @io::Writer, intr: @ident_interner) -> @ps {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static indent_unit: uint = 4u;
|
pub static indent_unit: uint = 4u;
|
||||||
pub static match_indent_unit: uint = 2u;
|
|
||||||
|
|
||||||
pub static default_columns: uint = 78u;
|
pub static default_columns: uint = 78u;
|
||||||
|
|
||||||
|
@ -1227,16 +1226,16 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
||||||
print_block(s, blk);
|
print_block(s, blk);
|
||||||
}
|
}
|
||||||
ast::expr_match(expr, ref arms) => {
|
ast::expr_match(expr, ref arms) => {
|
||||||
cbox(s, match_indent_unit);
|
cbox(s, indent_unit);
|
||||||
ibox(s, 4);
|
ibox(s, 4);
|
||||||
word_nbsp(s, ~"match");
|
word_nbsp(s, ~"match");
|
||||||
print_expr(s, expr);
|
print_expr(s, expr);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
bopen(s);
|
bopen(s);
|
||||||
let len = (*arms).len();
|
let len = arms.len();
|
||||||
for (*arms).eachi |i, arm| {
|
for arms.eachi |i, arm| {
|
||||||
space(s.s);
|
space(s.s);
|
||||||
cbox(s, match_indent_unit);
|
cbox(s, indent_unit);
|
||||||
ibox(s, 0u);
|
ibox(s, 0u);
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for arm.pats.each |p| {
|
for arm.pats.each |p| {
|
||||||
|
@ -1269,7 +1268,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
||||||
ast::expr_block(ref blk) => {
|
ast::expr_block(ref blk) => {
|
||||||
// the block will close the pattern's ibox
|
// the block will close the pattern's ibox
|
||||||
print_block_unclosed_indent(
|
print_block_unclosed_indent(
|
||||||
s, blk, match_indent_unit);
|
s, blk, indent_unit);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
end(s); // close the ibox for the pattern
|
end(s); // close the ibox for the pattern
|
||||||
|
@ -1286,10 +1285,10 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the block will close the pattern's ibox
|
// 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) => {
|
ast::expr_fn_block(ref decl, ref body) => {
|
||||||
// in do/for blocks we don't want to show an empty
|
// in do/for blocks we don't want to show an empty
|
||||||
|
|
|
@ -17,9 +17,9 @@ fn main() {
|
||||||
let x = Some(3);
|
let x = Some(3);
|
||||||
let y =
|
let y =
|
||||||
match x {
|
match x {
|
||||||
Some(_) =>
|
Some(_) =>
|
||||||
~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very"
|
~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" +
|
||||||
+ ~"very" + ~"very" + ~"long" + ~"string",
|
~"very" + ~"very" + ~"very" + ~"long" + ~"string",
|
||||||
None => ~"none"
|
None => ~"none"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ fn main() {
|
||||||
let x = Some(3);
|
let x = Some(3);
|
||||||
let _y =
|
let _y =
|
||||||
match x {
|
match x {
|
||||||
Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
|
Some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"],
|
||||||
None => ~[~"none"]
|
None => ~[~"none"]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue