From 224536f4fee75a9825e7da0a8a332786cc1f52f8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 19 Jan 2022 18:55:24 -0800 Subject: [PATCH] Inline indent function --- compiler/rustc_ast_pretty/src/pp.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index de57820d261..726c114b10b 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -366,12 +366,7 @@ impl Printer { fn print_newline(&mut self, amount: isize) { self.out.push('\n'); - self.pending_indentation = 0; - self.indent(amount); - } - - fn indent(&mut self, amount: isize) { - self.pending_indentation += amount; + self.pending_indentation = amount; } fn get_top(&self) -> PrintFrame { @@ -397,7 +392,7 @@ impl Printer { fn print_break(&mut self, token: BreakToken, size: isize) { match self.get_top() { PrintFrame::Fits => { - self.indent(token.blank_space); + self.pending_indentation += token.blank_space; self.space -= token.blank_space; } PrintFrame::Broken { offset, breaks: Breaks::Consistent } => { @@ -409,7 +404,7 @@ impl Printer { self.print_newline(offset + token.offset); self.space = self.margin - (offset + token.offset); } else { - self.indent(token.blank_space); + self.pending_indentation += token.blank_space; self.space -= token.blank_space; } }