Skip to content

Commit ee43aa3

Browse files
committed
Fix some pretty printing indents.
Indents for `cbox` and `ibox` are 0 or `INDENT_UNIT` (4) except for a couple of places which are `INDENT_UNIT - 1` for no clear reason. This commit changes the three space indents to four spaces.
1 parent 3d488f8 commit ee43aa3

File tree

6 files changed

+57
-57
lines changed

6 files changed

+57
-57
lines changed

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'a> State<'a> {
2121
match &_else.kind {
2222
// Another `else if` block.
2323
ast::ExprKind::If(i, then, e) => {
24-
self.cbox(INDENT_UNIT - 1);
24+
self.cbox(INDENT_UNIT);
2525
self.ibox(0);
2626
self.word(" else if ");
2727
self.print_expr_as_cond(i);
@@ -31,7 +31,7 @@ impl<'a> State<'a> {
3131
}
3232
// Final `else` block.
3333
ast::ExprKind::Block(b, _) => {
34-
self.cbox(INDENT_UNIT - 1);
34+
self.cbox(INDENT_UNIT);
3535
self.ibox(0);
3636
self.word(" else ");
3737
self.print_block(b)

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ impl<'a> State<'a> {
10651065
match els_inner.kind {
10661066
// Another `else if` block.
10671067
hir::ExprKind::If(i, then, e) => {
1068-
self.cbox(INDENT_UNIT - 1);
1068+
self.cbox(INDENT_UNIT);
10691069
self.ibox(0);
10701070
self.word(" else if ");
10711071
self.print_expr_as_cond(i);
@@ -1075,7 +1075,7 @@ impl<'a> State<'a> {
10751075
}
10761076
// Final `else` block.
10771077
hir::ExprKind::Block(b, _) => {
1078-
self.cbox(INDENT_UNIT - 1);
1078+
self.cbox(INDENT_UNIT);
10791079
self.ibox(0);
10801080
self.word(" else ");
10811081
self.print_block(b);

tests/pretty/hir-if-else.pp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616
{
1717
a = 1;
1818
} else if x < 2
19-
{
20-
a = 2;
21-
} else if x < 3
22-
{
23-
a = 3;
24-
} else if x < 4 { a = 4; } else { a = 5; }
19+
{
20+
a = 2;
21+
} else if x < 3
22+
{
23+
a = 3;
24+
} else if x < 4 { a = 4; } else { a = 5; }
2525

26-
if x < y
27-
{
28-
a += 1;
29-
a += 1;
30-
a += 1;
31-
a += 1;
32-
a += 1;
33-
a += 1;
34-
} else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; }
26+
if x < y
27+
{
28+
a += 1;
29+
a += 1;
30+
a += 1;
31+
a += 1;
32+
a += 1;
33+
a += 1;
34+
} else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; }
3535

36-
if x < 1
37-
{
38-
if x < 2
39-
{
40-
if x < 3
41-
{
42-
a += 1;
43-
} else if x < 4
44-
{ a += 1; if x < 5 { a += 1; } }
45-
} else if x < 6 { a += 1; } }
46-
}
36+
if x < 1
37+
{
38+
if x < 2
39+
{
40+
if x < 3
41+
{
42+
a += 1;
43+
} else if x < 4
44+
{ a += 1; if x < 5 { a += 1; } }
45+
} else if x < 6 { a += 1; } }
46+
}
4747

48-
fn main() { f(3, 4); }
48+
fn main() { f(3, 4); }

tests/pretty/if-else.pp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@
1515
if x < 1 {
1616
a = 1;
1717
} else if x < 2 {
18-
a = 2;
19-
} else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; }
18+
a = 2;
19+
} else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; }
2020

2121
if x < y {
2222
a += 1;
2323
a += 1;
2424
a += 1;
2525
} else {
26-
a += 1;
27-
a += 1;
28-
a += 1;
29-
a += 1;
30-
a += 1;
31-
a += 1;
32-
a += 1;
33-
a += 1;
34-
a += 1;
35-
a += 1;
36-
a += 1;
37-
a += 1;
38-
a += 1;
39-
a += 1;
40-
a += 1;
41-
}
26+
a += 1;
27+
a += 1;
28+
a += 1;
29+
a += 1;
30+
a += 1;
31+
a += 1;
32+
a += 1;
33+
a += 1;
34+
a += 1;
35+
a += 1;
36+
a += 1;
37+
a += 1;
38+
a += 1;
39+
a += 1;
40+
a += 1;
41+
}
4242

4343
if x < 1 {
4444
if x < 2 {

tests/ui/match/issue-82392.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() ({
1111
(if (true as bool)
1212
({ } as
1313
()) else if (let Some(a) =
14-
((Some as
15-
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
16-
Option<i32>) as bool) ({ } as ()) as ())
17-
} as ())
14+
((Some as
15+
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
16+
Option<i32>) as bool) ({ } as ()) as ())
17+
} as ())

tests/ui/proc-macro/quote/debug.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ fn main() {
3636
lit.set_span(crate::Span::recover_proc_macro_span(2));
3737
lit
3838
} else {
39-
::core::panicking::panic("internal error: entered unreachable code")
40-
}
39+
::core::panicking::panic("internal error: entered unreachable code")
40+
}
4141
}), &mut ts);
4242
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
4343
crate::Spacing::Alone)), &mut ts);
@@ -55,8 +55,8 @@ fn main() {
5555
lit.set_span(crate::Span::recover_proc_macro_span(5));
5656
lit
5757
} else {
58-
::core::panicking::panic("internal error: entered unreachable code")
59-
}
58+
::core::panicking::panic("internal error: entered unreachable code")
59+
}
6060
}), &mut ts);
6161
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
6262
crate::Spacing::Alone)), &mut ts);

0 commit comments

Comments
 (0)