diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-25 13:51:49 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-25 14:33:16 +1000 |
| commit | e37c3674828a75ffdc2b94d9d273e9c02a9ee11f (patch) | |
| tree | 12a729811c4bc54b7f0bde32a81f246cb1efe68b /compiler/rustc_ast_pretty | |
| parent | ee43aa356aa228b5cc8da41622855f4f2c07f8ab (diff) | |
| download | rust-e37c3674828a75ffdc2b94d9d273e9c02a9ee11f.tar.gz rust-e37c3674828a75ffdc2b94d9d273e9c02a9ee11f.zip | |
Improve pretty printing of if/else.
By removing some of the over-indenting. AST pretty printing now looks correct. HIR pretty printing is better, but still over-indents some.
Diffstat (limited to 'compiler/rustc_ast_pretty')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 37df567081f..f2a9a688d8b 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -21,7 +21,7 @@ impl<'a> State<'a> { match &_else.kind { // Another `else if` block. ast::ExprKind::If(i, then, e) => { - self.cbox(INDENT_UNIT); + self.cbox(0); self.ibox(0); self.word(" else if "); self.print_expr_as_cond(i); @@ -31,7 +31,7 @@ impl<'a> State<'a> { } // Final `else` block. ast::ExprKind::Block(b, _) => { - self.cbox(INDENT_UNIT); + self.cbox(0); self.ibox(0); self.word(" else "); self.print_block(b) @@ -45,7 +45,9 @@ impl<'a> State<'a> { } fn print_if(&mut self, test: &ast::Expr, blk: &ast::Block, elseopt: Option<&ast::Expr>) { - self.head("if"); + self.cbox(0); + self.ibox(0); + self.word_nbsp("if"); self.print_expr_as_cond(test); self.space(); self.print_block(blk); |
