Skip to content

Commit

Permalink
Inline print_newline function
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 20, 2022
1 parent 224536f commit 51eeb82
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions compiler/rustc_ast_pretty/src/pp.rs
Expand Up @@ -364,11 +364,6 @@ impl Printer {
}
}

fn print_newline(&mut self, amount: isize) {
self.out.push('\n');
self.pending_indentation = amount;
}

fn get_top(&self) -> PrintFrame {
*self
.print_stack
Expand Down Expand Up @@ -396,12 +391,14 @@ impl Printer {
self.space -= token.blank_space;
}
PrintFrame::Broken { offset, breaks: Breaks::Consistent } => {
self.print_newline(offset + token.offset);
self.out.push('\n');
self.pending_indentation = offset + token.offset;
self.space = self.margin - (offset + token.offset);
}
PrintFrame::Broken { offset, breaks: Breaks::Inconsistent } => {
if size > self.space {
self.print_newline(offset + token.offset);
self.out.push('\n');
self.pending_indentation = offset + token.offset;
self.space = self.margin - (offset + token.offset);
} else {
self.pending_indentation += token.blank_space;
Expand Down

0 comments on commit 51eeb82

Please sign in to comment.