Skip to content

Commit d2eb46c

Browse files
committed
Simplify advance_left
1 parent 351011e commit d2eb46c

File tree

1 file changed

+4
-8
lines changed
  • compiler/rustc_ast_pretty/src

1 file changed

+4
-8
lines changed

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,24 +316,20 @@ impl Printer {
316316
}
317317

318318
fn advance_left(&mut self) {
319-
let mut left_size = self.buf.first().unwrap().size;
319+
while self.buf.first().unwrap().size >= 0 {
320+
let left = self.buf.pop_first().unwrap();
320321

321-
while left_size >= 0 {
322-
let left = self.buf.pop_first().unwrap().token;
323-
324-
match &left {
322+
match &left.token {
325323
Token::Break(b) => self.left_total += b.blank_space,
326324
Token::String(s) => self.left_total += s.len() as isize,
327325
_ => {}
328326
}
329327

330-
self.print(left, left_size);
328+
self.print(left.token, left.size);
331329

332330
if self.buf.is_empty() {
333331
break;
334332
}
335-
336-
left_size = self.buf.first().unwrap().size;
337333
}
338334
}
339335

0 commit comments

Comments
 (0)