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.
This commit is contained in:
Nicholas Nethercote
2025-04-25 13:06:03 +10:00
parent 3d488f8e0c
commit ee43aa356a
6 changed files with 57 additions and 57 deletions

View File

@@ -21,7 +21,7 @@ impl<'a> State<'a> {
match &_else.kind { match &_else.kind {
// Another `else if` block. // Another `else if` block.
ast::ExprKind::If(i, then, e) => { ast::ExprKind::If(i, then, e) => {
self.cbox(INDENT_UNIT - 1); self.cbox(INDENT_UNIT);
self.ibox(0); self.ibox(0);
self.word(" else if "); self.word(" else if ");
self.print_expr_as_cond(i); self.print_expr_as_cond(i);
@@ -31,7 +31,7 @@ impl<'a> State<'a> {
} }
// Final `else` block. // Final `else` block.
ast::ExprKind::Block(b, _) => { ast::ExprKind::Block(b, _) => {
self.cbox(INDENT_UNIT - 1); self.cbox(INDENT_UNIT);
self.ibox(0); self.ibox(0);
self.word(" else "); self.word(" else ");
self.print_block(b) self.print_block(b)

View File

@@ -1065,7 +1065,7 @@ impl<'a> State<'a> {
match els_inner.kind { match els_inner.kind {
// Another `else if` block. // Another `else if` block.
hir::ExprKind::If(i, then, e) => { hir::ExprKind::If(i, then, e) => {
self.cbox(INDENT_UNIT - 1); self.cbox(INDENT_UNIT);
self.ibox(0); self.ibox(0);
self.word(" else if "); self.word(" else if ");
self.print_expr_as_cond(i); self.print_expr_as_cond(i);
@@ -1075,7 +1075,7 @@ impl<'a> State<'a> {
} }
// Final `else` block. // Final `else` block.
hir::ExprKind::Block(b, _) => { hir::ExprKind::Block(b, _) => {
self.cbox(INDENT_UNIT - 1); self.cbox(INDENT_UNIT);
self.ibox(0); self.ibox(0);
self.word(" else "); self.word(" else ");
self.print_block(b); self.print_block(b);

View File

@@ -16,33 +16,33 @@ fn f(x: u32,
{ {
a = 1; a = 1;
} else if x < 2 } else if x < 2
{ {
a = 2; a = 2;
} else if x < 3 } else if x < 3
{ {
a = 3; a = 3;
} else if x < 4 { a = 4; } else { a = 5; } } else if x < 4 { a = 4; } else { a = 5; }
if x < y if x < y
{ {
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
} else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; } } else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; }
if x < 1 if x < 1
{ {
if x < 2 if x < 2
{ {
if x < 3 if x < 3
{ {
a += 1; a += 1;
} else if x < 4 } else if x < 4
{ a += 1; if x < 5 { a += 1; } } { a += 1; if x < 5 { a += 1; } }
} else if x < 6 { a += 1; } } } else if x < 6 { a += 1; } }
} }
fn main() { f(3, 4); } fn main() { f(3, 4); }

View File

@@ -15,30 +15,30 @@ fn f(x: u32, y: u32) {
if x < 1 { if x < 1 {
a = 1; a = 1;
} else if x < 2 { } else if x < 2 {
a = 2; a = 2;
} else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; } } else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; }
if x < y { if x < y {
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
} else { } else {
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
a += 1; a += 1;
} }
if x < 1 { if x < 1 {
if x < 2 { if x < 2 {

View File

@@ -11,7 +11,7 @@ fn main() ({
(if (true as bool) (if (true as bool)
({ } as ({ } as
()) else if (let Some(a) = ()) else if (let Some(a) =
((Some as ((Some as
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
Option<i32>) as bool) ({ } as ()) as ()) Option<i32>) as bool) ({ } as ()) as ())
} as ()) } as ())

View File

@@ -36,8 +36,8 @@ fn main() {
lit.set_span(crate::Span::recover_proc_macro_span(2)); lit.set_span(crate::Span::recover_proc_macro_span(2));
lit lit
} else { } else {
::core::panicking::panic("internal error: entered unreachable code") ::core::panicking::panic("internal error: entered unreachable code")
} }
}), &mut ts); }), &mut ts);
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';', crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
crate::Spacing::Alone)), &mut ts); crate::Spacing::Alone)), &mut ts);
@@ -55,8 +55,8 @@ fn main() {
lit.set_span(crate::Span::recover_proc_macro_span(5)); lit.set_span(crate::Span::recover_proc_macro_span(5));
lit lit
} else { } else {
::core::panicking::panic("internal error: entered unreachable code") ::core::panicking::panic("internal error: entered unreachable code")
} }
}), &mut ts); }), &mut ts);
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';', crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
crate::Spacing::Alone)), &mut ts); crate::Spacing::Alone)), &mut ts);